diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp/lwtrace/mon/analytics | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/lwtrace/mon/analytics')
-rw-r--r-- | library/cpp/lwtrace/mon/analytics/csv_output.h | 16 | ||||
-rw-r--r-- | library/cpp/lwtrace/mon/analytics/data.h | 14 | ||||
-rw-r--r-- | library/cpp/lwtrace/mon/analytics/html_output.h | 14 | ||||
-rw-r--r-- | library/cpp/lwtrace/mon/analytics/json_output.h | 14 | ||||
-rw-r--r-- | library/cpp/lwtrace/mon/analytics/transform.h | 26 | ||||
-rw-r--r-- | library/cpp/lwtrace/mon/analytics/util.h | 26 |
6 files changed, 55 insertions, 55 deletions
diff --git a/library/cpp/lwtrace/mon/analytics/csv_output.h b/library/cpp/lwtrace/mon/analytics/csv_output.h index 90ded32f5d..47e0805e1e 100644 --- a/library/cpp/lwtrace/mon/analytics/csv_output.h +++ b/library/cpp/lwtrace/mon/analytics/csv_output.h @@ -7,9 +7,9 @@ namespace NAnalytics { -inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = true) +inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = true) { - TSet<TString> cols; + TSet<TString> cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); @@ -22,11 +22,11 @@ inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = if (head) { bool first = true; if (hasName) { - ss << (first? TString(): sep) << "Name"; + ss << (first? TString(): sep) << "Name"; first = false; } - for (const TString& c : cols) { - ss << (first? TString(): sep) << c; + for (const TString& c : cols) { + ss << (first? TString(): sep) << c; first = false; } ss << Endl; @@ -35,11 +35,11 @@ inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = for (const TRow& row : in) { bool first = true; if (hasName) { - ss << (first? TString(): sep) << row.Name; + ss << (first? TString(): sep) << row.Name; first = false; } - for (const TString& c : cols) { - ss << (first? TString(): sep); + for (const TString& c : cols) { + ss << (first? TString(): sep); first = false; TString value; ss << (row.GetAsString(c, value) ? value : TString("-")); diff --git a/library/cpp/lwtrace/mon/analytics/data.h b/library/cpp/lwtrace/mon/analytics/data.h index 4b643fe20b..fe635d4209 100644 --- a/library/cpp/lwtrace/mon/analytics/data.h +++ b/library/cpp/lwtrace/mon/analytics/data.h @@ -1,8 +1,8 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/hash.h> -#include <util/generic/vector.h> +#include <util/generic/vector.h> #include <util/string/builder.h> #include <util/string/cast.h> @@ -21,7 +21,7 @@ TString ToString(const TRowValue& val) { } struct TRow : public THashMap<TString, TRowValue> { - TString Name; + TString Name; template<typename T> bool Get(const TString& name, T& value) const { @@ -57,18 +57,18 @@ struct TRow : public THashMap<TString, TRowValue> { } }; -using TAttributes = THashMap<TString, TString>; +using TAttributes = THashMap<TString, TString>; -struct TTable : public TVector<TRow> { +struct TTable : public TVector<TRow> { TAttributes Attributes; }; -struct TMatrix : public TVector<double> { +struct TMatrix : public TVector<double> { size_t Rows; size_t Cols; explicit TMatrix(size_t rows = 0, size_t cols = 0) - : TVector<double>(rows * cols) + : TVector<double>(rows * cols) , Rows(rows) , Cols(cols) {} diff --git a/library/cpp/lwtrace/mon/analytics/html_output.h b/library/cpp/lwtrace/mon/analytics/html_output.h index f775f216b9..3b63a1ce5f 100644 --- a/library/cpp/lwtrace/mon/analytics/html_output.h +++ b/library/cpp/lwtrace/mon/analytics/html_output.h @@ -7,9 +7,9 @@ namespace NAnalytics { -inline TString ToHtml(const TTable& in) +inline TString ToHtml(const TTable& in) { - TSet<TString> cols; + TSet<TString> cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); @@ -24,7 +24,7 @@ inline TString ToHtml(const TTable& in) if (hasName) { ss << "<th>Name</th>"; } - for (const TString& c : cols) { + for (const TString& c : cols) { ss << "<th>" << c << "</th>"; } ss << "</tr></thead><tbody>"; @@ -34,7 +34,7 @@ inline TString ToHtml(const TTable& in) if (hasName) { ss << "<th>" << row.Name << "</th>"; } - for (const TString& c : cols) { + for (const TString& c : cols) { TString value; ss << "<td>" << (row.GetAsString(c, value) ? value : TString("-")) << "</td>"; } @@ -45,9 +45,9 @@ inline TString ToHtml(const TTable& in) return ss.Str(); } -inline TString ToTransposedHtml(const TTable& in) +inline TString ToTransposedHtml(const TTable& in) { - TSet<TString> cols; + TSet<TString> cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); @@ -69,7 +69,7 @@ inline TString ToTransposedHtml(const TTable& in) ss << "</thead><tbody>"; - for (const TString& c : cols) { + for (const TString& c : cols) { ss << "<tr>"; ss << "<th>" << c << "</th>"; for (const TRow& row : in) { diff --git a/library/cpp/lwtrace/mon/analytics/json_output.h b/library/cpp/lwtrace/mon/analytics/json_output.h index 189f9802d3..b03392e162 100644 --- a/library/cpp/lwtrace/mon/analytics/json_output.h +++ b/library/cpp/lwtrace/mon/analytics/json_output.h @@ -10,26 +10,26 @@ namespace NAnalytics { -inline TString ToJsonFlot(const TTable& in, const TString& xno, const TVector<TString>& ynos, const TString& opts = TString()) +inline TString ToJsonFlot(const TTable& in, const TString& xno, const TVector<TString>& ynos, const TString& opts = TString()) { TStringStream ss; ss << "[ "; bool first = true; - TString xn; - THashSet<TString> xopts; + TString xn; + THashSet<TString> xopts; ParseNameAndOpts(xno, xn, xopts); bool xstack = xopts.contains("stack"); - for (const TString& yno : ynos) { - TString yn; - THashSet<TString> yopts; + for (const TString& yno : ynos) { + TString yn; + THashSet<TString> yopts; ParseNameAndOpts(yno, yn, yopts); bool ystackOpt = yopts.contains("stack"); ss << (first? "": ",\n ") << "{ " << opts << (opts? ", ": "") << "\"label\": \"" << yn << "\", \"data\": [ "; bool first2 = true; - using TPt = std::tuple<double, double, TString>; + using TPt = std::tuple<double, double, TString>; std::vector<TPt> pts; for (const TRow& row : in) { double x, y; diff --git a/library/cpp/lwtrace/mon/analytics/transform.h b/library/cpp/lwtrace/mon/analytics/transform.h index f7dc9adb5b..60f7aac379 100644 --- a/library/cpp/lwtrace/mon/analytics/transform.h +++ b/library/cpp/lwtrace/mon/analytics/transform.h @@ -6,14 +6,14 @@ namespace NAnalytics { template <class TSkip, class TX, class TY> inline TTable Histogram(const TTable& in, TSkip skip, - const TString& xn_out, TX x_in, - const TString& yn_out, TY y_in, + const TString& xn_out, TX x_in, + const TString& yn_out, TY y_in, double x1, double x2, double dx) { long buckets = (x2 - x1) / dx; TTable out; - TString yn_sum = yn_out + "_sum"; - TString yn_share = yn_out + "_share"; + TString yn_sum = yn_out + "_sum"; + TString yn_share = yn_out + "_share"; double ysum = 0.0; out.resize(buckets); for (size_t i = 0; i < out.size(); i++) { @@ -46,14 +46,14 @@ inline TTable Histogram(const TTable& in, TSkip skip, return out; } -inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, double x2, double dx) +inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, double x2, double dx) { long buckets = (dx == 0.0? 1: (x2 - x1) / dx); TTable out; - THashMap<TString, double> colSum; + THashMap<TString, double> colSum; out.resize(buckets); - TSet<TString> cols; + TSet<TString> cols; for (auto& row : in) { for (auto& kv : row) { cols.insert(kv.first); @@ -62,7 +62,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl cols.insert("_count"); cols.erase(xn); - for (const TString& col : cols) { + for (const TString& col : cols) { colSum[col] = 0.0; } @@ -72,7 +72,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl TRow& row = out[i]; row.Name = "[" + ToString(lb) + ";" + ToString(ub) + (ub==x2? "]": ")"); row[xn] = (lb + ub) / 2; - for (const TString& col : cols) { + for (const TString& col : cols) { row[col + "_sum"] = 0.0; } } @@ -86,7 +86,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl i--; } for (const auto& kv : row_in) { - const TString& yn = kv.first; + const TString& yn = kv.first; if (yn == xn) { continue; } @@ -116,7 +116,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl } } for (TRow& row : out) { - for (const TString& col : cols) { + for (const TString& col : cols) { double ysum = colSum[col]; if (col != "_count") { if (row.GetOrDefault(col + "_cnt") != 0.0) { @@ -133,7 +133,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl inline TMatrix CovarianceMatrix(const TTable& in) { - TSet<TString> cols; + TSet<TString> cols; for (auto& row : in) { for (auto& kv : row) { cols.insert(kv.first); @@ -147,7 +147,7 @@ inline TMatrix CovarianceMatrix(const TTable& in) double Mean = 0; }; - THashMap<TString, TAggregate> colAggr; + THashMap<TString, TAggregate> colAggr; size_t colCount = 0; for (const TString& col : cols) { diff --git a/library/cpp/lwtrace/mon/analytics/util.h b/library/cpp/lwtrace/mon/analytics/util.h index e07d06cc43..e4b067f8a9 100644 --- a/library/cpp/lwtrace/mon/analytics/util.h +++ b/library/cpp/lwtrace/mon/analytics/util.h @@ -13,7 +13,7 @@ inline double Finitize(double x, double notFiniteValue = 0.0) return isfinite(x)? x: notFiniteValue; } -inline void ParseNameAndOpts(const TString& nameAndOpts, TString& name, THashSet<TString>& opts) +inline void ParseNameAndOpts(const TString& nameAndOpts, TString& name, THashSet<TString>& opts) { name.clear(); opts.clear(); @@ -29,18 +29,18 @@ inline void ParseNameAndOpts(const TString& nameAndOpts, TString& name, THashSet } } -inline TString ParseName(const TString& nameAndOpts) +inline TString ParseName(const TString& nameAndOpts) { auto vs = SplitString(nameAndOpts, "-"); if (vs.empty()) { - return TString(); + return TString(); } else { return vs[0]; } } template <class R, class T> -inline R AccumulateIfExist(const TString& name, const TTable& table, R r, T t) +inline R AccumulateIfExist(const TString& name, const TTable& table, R r, T t) { ForEach(table.begin(), table.end(), [=,&r] (const TRow& row) { double value; @@ -51,10 +51,10 @@ inline R AccumulateIfExist(const TString& name, const TTable& table, R r, T t) return r; } -inline double MinValue(const TString& nameAndOpts, const TTable& table) +inline double MinValue(const TString& nameAndOpts, const TTable& table) { - TString name; - THashSet<TString> opts; + TString name; + THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); bool stack = opts.contains("stack"); if (stack) { @@ -68,10 +68,10 @@ inline double MinValue(const TString& nameAndOpts, const TTable& table) } } -inline double MaxValue(const TString& nameAndOpts, const TTable& table) +inline double MaxValue(const TString& nameAndOpts, const TTable& table) { - TString name; - THashSet<TString> opts; + TString name; + THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); bool stack = opts.contains("stack"); if (stack) { @@ -88,14 +88,14 @@ inline double MaxValue(const TString& nameAndOpts, const TTable& table) } template <class T> -inline void Map(TTable& table, const TString& rname, T t) +inline void Map(TTable& table, const TString& rname, T t) { ForEach(table.begin(), table.end(), [=] (TRow& row) { row[rname] = t(row); }); } -inline std::function<bool(const TRow&)> HasNoValueFor(TString name) +inline std::function<bool(const TRow&)> HasNoValueFor(TString name) { return [=] (const TRow& row) -> bool { double value; @@ -104,7 +104,7 @@ inline std::function<bool(const TRow&)> HasNoValueFor(TString name) } -inline std::function<double(const TRow&)> GetValueFor(TString name, double defVal = 0.0) +inline std::function<double(const TRow&)> GetValueFor(TString name, double defVal = 0.0) { return [=] (const TRow& row) -> double { double value; |