aboutsummaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2018-10-01 09:08:35 +0000
committerArne Juul <arnej@yahoo-inc.com>2018-10-01 09:09:22 +0000
commited6c3aa9bf6deeeb5595dd9fc25f5a679448e283 (patch)
treeb53e67dd5c3f77ae3ef3364b5a7bebe729698525 /staging_vespalib
parent1cb9459c3540aed9431b4824f19766555d00d1c3 (diff)
extend API to allow lvalues also
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/tests/metrics/simple_metrics_test.cpp9
-rw-r--r--staging_vespalib/src/vespa/vespalib/metrics/point_builder.cpp34
-rw-r--r--staging_vespalib/src/vespa/vespalib/metrics/point_builder.h3
3 files changed, 35 insertions, 11 deletions
diff --git a/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp b/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp
index da2502f7ed7..d0163f922b3 100644
--- a/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp
+++ b/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp
@@ -153,10 +153,11 @@ TEST("use simple_metrics_collector")
.bind("chain", "default")
.bind("documenttype", "music")
.bind("thread", "0").build();
- Point two = manager->pointBuilder()
- .bind("chain", "vespa")
- .bind("documenttype", "blogpost")
- .bind("thread", "1");
+ PointBuilder b2 = manager->pointBuilder();
+ b2.bind("chain", "vespa")
+ .bind("documenttype", "blogpost");
+ b2.bind("thread", "1");
+ Point two = b2.build();
EXPECT_EQUAL(one.id(), 1u);
EXPECT_EQUAL(two.id(), 2u);
diff --git a/staging_vespalib/src/vespa/vespalib/metrics/point_builder.cpp b/staging_vespalib/src/vespa/vespalib/metrics/point_builder.cpp
index 7ee4ca35d0e..a89336b4399 100644
--- a/staging_vespalib/src/vespa/vespalib/metrics/point_builder.cpp
+++ b/staging_vespalib/src/vespa/vespalib/metrics/point_builder.cpp
@@ -14,27 +14,47 @@ PointBuilder::PointBuilder(std::shared_ptr<MetricsManager> m,
: _owner(std::move(m)), _map(copyFrom)
{}
-PointBuilder &&
-PointBuilder::bind(Dimension dimension, Label label) &&
+PointBuilder &
+PointBuilder::bind(Dimension dimension, Label label) &
{
_map.erase(dimension);
_map.emplace(dimension, label);
+ return *this;
+}
+PointBuilder &
+PointBuilder::bind(Dimension dimension, LabelValue label) &
+{
+ Label c = _owner->label(label);
+ return bind(dimension, c);
+}
+
+PointBuilder &
+PointBuilder::bind(DimensionName dimension, LabelValue label) &
+{
+ Dimension a = _owner->dimension(dimension);
+ Label c = _owner->label(label);
+ return bind(a, c);
+}
+
+PointBuilder &&
+PointBuilder::bind(Dimension dimension, Label label) &&
+{
+ bind(dimension, label);
return std::move(*this);
}
PointBuilder &&
PointBuilder::bind(Dimension dimension, LabelValue label) &&
{
- Label c = _owner->label(label);
- return std::move(*this).bind(dimension, c);
+ bind(dimension, label);
+ return std::move(*this);
}
PointBuilder &&
PointBuilder::bind(DimensionName dimension, LabelValue label) &&
{
- Dimension a = _owner->dimension(dimension);
- Label c = _owner->label(label);
- return std::move(*this).bind(a, c);
+ bind(dimension, label);
+ return std::move(*this);
}
Point
diff --git a/staging_vespalib/src/vespa/vespalib/metrics/point_builder.h b/staging_vespalib/src/vespa/vespalib/metrics/point_builder.h
index 83b804228dd..923238ec385 100644
--- a/staging_vespalib/src/vespa/vespalib/metrics/point_builder.h
+++ b/staging_vespalib/src/vespa/vespalib/metrics/point_builder.h
@@ -31,18 +31,21 @@ public:
* Overwrites any label already bound to that dimension.
**/
PointBuilder &&bind(Dimension dimension, Label label) &&;
+ PointBuilder &bind(Dimension dimension, Label label) &;
/**
* Bind a dimension to a label.
* Convenience method that converts the label value.
**/
PointBuilder &&bind(Dimension dimension, LabelValue label) &&;
+ PointBuilder &bind(Dimension dimension, LabelValue label) &;
/**
* Bind a dimension to a label.
* Convenience method that converts both the dimension name and the label value.
**/
PointBuilder &&bind(DimensionName dimension, LabelValue label) &&;
+ PointBuilder &bind(DimensionName dimension, LabelValue label) &;
/** make a Point from the builder */
Point build();