diff options
author | Arne Juul <arnej@yahoo-inc.com> | 2018-10-08 12:14:32 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahoo-inc.com> | 2018-10-08 12:18:11 +0000 |
commit | cb7752e077eb6f648eaeab2c4302345160e8af5e (patch) | |
tree | c8d61007d2af5f001810940147b8436c13127108 | |
parent | b568099cd11227ce015841594d0b2a050355f051 (diff) |
drop MetricPointId struct
14 files changed, 28 insertions, 66 deletions
diff --git a/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp b/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp index 7ef57415416..03ed9dc2cf7 100644 --- a/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp +++ b/staging_vespalib/src/tests/metrics/simple_metrics_test.cpp @@ -15,7 +15,7 @@ using namespace vespalib::metrics; TEST("require that simple metrics gauge merge works") { - MetricPointId id(MetricId(42), Point(17)); + std::pair<MetricId, Point> id(MetricId(42), Point(17)); Gauge::Measurement a1(id, 0.0); Gauge::Measurement b1(id, 7.0); Gauge::Measurement b2(id, 9.0); diff --git a/staging_vespalib/src/vespa/vespalib/metrics/CMakeLists.txt b/staging_vespalib/src/vespa/vespalib/metrics/CMakeLists.txt index 5112286b359..6015ea8c621 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/CMakeLists.txt +++ b/staging_vespalib/src/vespa/vespalib/metrics/CMakeLists.txt @@ -13,7 +13,6 @@ vespa_add_library(staging_vespalib_vespalib_metrics OBJECT handle.cpp json_formatter.cpp label.cpp - metric_point_id.cpp metric_id.cpp metrics_manager.cpp metric_types.cpp diff --git a/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp b/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp index af942a48fb9..fdca2b1a9cc 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp +++ b/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp @@ -14,12 +14,13 @@ mergeFromSamples(const StableStore<typename T::sample_type> &source) { using Aggregator = typename T::aggregator_type; using Sample = typename T::sample_type; - using Map = std::map<MetricPointId, Aggregator>; + using Key = std::pair<MetricId, Point>; + using Map = std::map<Key, Aggregator>; using MapValue = typename Map::value_type; Map map; source.for_each([&map] (const Sample &sample) { - MetricPointId id = sample.idx; + Key id = sample.idx; auto iter_check = map.emplace(id, sample); if (!iter_check.second) { iter_check.first->second.merge(sample); diff --git a/staging_vespalib/src/vespa/vespalib/metrics/bucket.h b/staging_vespalib/src/vespa/vespalib/metrics/bucket.h index e358080b73b..a1d0dff49f3 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/bucket.h +++ b/staging_vespalib/src/vespa/vespalib/metrics/bucket.h @@ -3,7 +3,8 @@ #include <mutex> #include "stable_store.h" -#include "metric_point_id.h" +#include "metric_id.h" +#include "point.h" #include "counter.h" #include "gauge.h" #include "clock.h" diff --git a/staging_vespalib/src/vespa/vespalib/metrics/counter.cpp b/staging_vespalib/src/vespa/vespalib/metrics/counter.cpp index c04a21a0020..a44fca245eb 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/counter.cpp +++ b/staging_vespalib/src/vespa/vespalib/metrics/counter.cpp @@ -10,8 +10,7 @@ void Counter::add(size_t count, Point point) const { if (_manager) { - MetricPointId fullId(_id, point); - _manager->add(Increment(fullId, count)); + _manager->add(Increment(std::make_pair(_id, point), count)); } } diff --git a/staging_vespalib/src/vespa/vespalib/metrics/counter.h b/staging_vespalib/src/vespa/vespalib/metrics/counter.h index 192a08aba66..18a40b4e344 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/counter.h +++ b/staging_vespalib/src/vespa/vespalib/metrics/counter.h @@ -2,7 +2,7 @@ #pragma once #include <memory> -#include "metric_point_id.h" +#include "metric_id.h" #include "point.h" namespace vespalib { @@ -42,10 +42,11 @@ public: // internal struct Increment { - MetricPointId idx; + using Key = std::pair<MetricId, Point>; + Key idx; size_t value; Increment() = delete; - Increment(MetricPointId id, size_t v) : idx(id), value(v) {} + Increment(Key k, size_t v) : idx(k), value(v) {} }; typedef CounterAggregator aggregator_type; diff --git a/staging_vespalib/src/vespa/vespalib/metrics/counter_aggregator.h b/staging_vespalib/src/vespa/vespalib/metrics/counter_aggregator.h index e7f9ab1c9ab..4e3524f9cc8 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/counter_aggregator.h +++ b/staging_vespalib/src/vespa/vespalib/metrics/counter_aggregator.h @@ -1,7 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "metric_point_id.h" +#include "metric_id.h" +#include "point.h" #include "counter.h" namespace vespalib { @@ -9,7 +10,7 @@ namespace metrics { // internal struct CounterAggregator { - MetricPointId idx; + std::pair<MetricId, Point> idx; size_t count; CounterAggregator(const Counter::Increment &other); diff --git a/staging_vespalib/src/vespa/vespalib/metrics/gauge.cpp b/staging_vespalib/src/vespa/vespalib/metrics/gauge.cpp index f2afc87f16f..a1ab9d25078 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/gauge.cpp +++ b/staging_vespalib/src/vespa/vespalib/metrics/gauge.cpp @@ -9,8 +9,7 @@ void Gauge::sample(double value, Point point) const { if (_manager) { - MetricPointId fullId(_id, point); - _manager->sample(Measurement(fullId, value)); + _manager->sample(Measurement(std::make_pair(_id, point), value)); } } diff --git a/staging_vespalib/src/vespa/vespalib/metrics/gauge.h b/staging_vespalib/src/vespa/vespalib/metrics/gauge.h index c4542ac87e4..7eb223ecf44 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/gauge.h +++ b/staging_vespalib/src/vespa/vespalib/metrics/gauge.h @@ -2,7 +2,7 @@ #pragma once #include <memory> -#include "metric_point_id.h" +#include "metric_id.h" #include "point.h" namespace vespalib { @@ -32,10 +32,11 @@ public: // internal struct Measurement { - MetricPointId idx; + using Key = std::pair<MetricId, Point>; + Key idx; double value; Measurement() = delete; - Measurement(MetricPointId id, double v) : idx(id), value(v) {} + Measurement(Key k, double v) : idx(k), value(v) {} }; typedef GaugeAggregator aggregator_type; diff --git a/staging_vespalib/src/vespa/vespalib/metrics/gauge_aggregator.h b/staging_vespalib/src/vespa/vespalib/metrics/gauge_aggregator.h index ae3365bc7f0..980a68899ce 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/gauge_aggregator.h +++ b/staging_vespalib/src/vespa/vespalib/metrics/gauge_aggregator.h @@ -1,7 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "metric_point_id.h" +#include "metric_id.h" +#include "point.h" #include "gauge.h" namespace vespalib { @@ -9,7 +10,7 @@ namespace metrics { // internal struct GaugeAggregator { - MetricPointId idx; + std::pair<MetricId, Point> idx; size_t observedCount; double sumValue; double minValue; diff --git a/staging_vespalib/src/vespa/vespalib/metrics/metric_point_id.cpp b/staging_vespalib/src/vespa/vespalib/metrics/metric_point_id.cpp deleted file mode 100644 index 90ecabdb75f..00000000000 --- a/staging_vespalib/src/vespa/vespalib/metrics/metric_point_id.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "metric_point_id.h" diff --git a/staging_vespalib/src/vespa/vespalib/metrics/metric_point_id.h b/staging_vespalib/src/vespa/vespalib/metrics/metric_point_id.h deleted file mode 100644 index f9d788a0f92..00000000000 --- a/staging_vespalib/src/vespa/vespalib/metrics/metric_point_id.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include "metric_id.h" -#include "point.h" -#include <functional> - -namespace vespalib { -namespace metrics { - -/** class to use as a map key, identifying a metric and a point */ -struct MetricPointId { - const MetricId _name; - const Point _point; - - MetricPointId() = delete; - - MetricPointId(MetricId name, Point point) - : _name(name), _point(point) {} - - bool operator< (const MetricPointId &other) const { - if (_name != other._name) { - return _name < other._name; - } - return _point < other._point; - } - bool operator== (const MetricPointId &other) const { - return (_name == other._name && - _point == other._point); - } - - MetricId name() const { return _name; } - Point point() const { return _point; } - -}; - -} // namespace vespalib::metrics -} // namespace vespalib diff --git a/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics.h b/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics.h index 34959146928..537b98a0618 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics.h +++ b/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics.h @@ -13,7 +13,6 @@ #include "gauge.h" #include "json_formatter.h" #include "label.h" -#include "metric_point_id.h" #include "metric_id.h" #include "metrics_manager.h" #include "point_builder.h" diff --git a/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics_manager.cpp b/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics_manager.cpp index 50dd30efc5a..a98c34b8622 100644 --- a/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics_manager.cpp +++ b/staging_vespalib/src/vespa/vespalib/metrics/simple_metrics_manager.cpp @@ -101,10 +101,10 @@ SimpleMetricsManager::snapshotFrom(const Bucket &bucket) size_t max_point_id = 0; for (const CounterAggregator& entry : bucket.counters) { - max_point_id = std::max(max_point_id, entry.idx.point().id()); + max_point_id = std::max(max_point_id, entry.idx.second.id()); } for (const GaugeAggregator& entry : bucket.gauges) { - max_point_id = std::max(max_point_id, entry.idx.point().id()); + max_point_id = std::max(max_point_id, entry.idx.second.id()); } Snapshot snap(s, e); { @@ -118,15 +118,15 @@ SimpleMetricsManager::snapshotFrom(const Bucket &bucket) } } for (const CounterAggregator& entry : bucket.counters) { - MetricId mn = entry.idx.name(); - size_t pi = entry.idx.point().id(); + MetricId mn = entry.idx.first; + size_t pi = entry.idx.second.id(); const vespalib::string &name = mn.as_name(); CounterSnapshot val(name, snap.points()[pi], entry); snap.add(val); } for (const GaugeAggregator& entry : bucket.gauges) { - MetricId mn = entry.idx.name(); - size_t pi = entry.idx.point().id(); + MetricId mn = entry.idx.first; + size_t pi = entry.idx.second.id(); const vespalib::string &name = mn.as_name(); GaugeSnapshot val(name, snap.points()[pi], entry); snap.add(val); |