aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorIvan Korostelev <ivan.korostelev@gmail.com>2022-02-10 16:46:41 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:41 +0300
commitb5e813096385b2d9e16b572711fec5bf2eb5058d (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp
parentf3a52f9d3e18d1159abbc85fa65eeda69d971657 (diff)
downloadydb-b5e813096385b2d9e16b572711fec5bf2eb5058d.tar.gz
Restoring authorship annotation for Ivan Korostelev <ivan.korostelev@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/cache/cache.h124
-rw-r--r--library/cpp/cache/ut/cache_ut.cpp14
-rw-r--r--library/cpp/coroutine/engine/events.h2
-rw-r--r--library/cpp/getopt/small/modchooser.h8
-rw-r--r--library/cpp/histogram/adaptive/adaptive_histogram.cpp180
-rw-r--r--library/cpp/histogram/adaptive/adaptive_histogram.h54
-rw-r--r--library/cpp/histogram/adaptive/auto_histogram.h8
-rw-r--r--library/cpp/histogram/adaptive/histogram.h4
-rw-r--r--library/cpp/histogram/adaptive/multi_histogram.h14
-rw-r--r--library/cpp/json/domscheme_traits.h344
-rw-r--r--library/cpp/scheme/domscheme_traits.h338
11 files changed, 545 insertions, 545 deletions
diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h
index eed990bf97..6dc997076d 100644
--- a/library/cpp/cache/cache.h
+++ b/library/cpp/cache/cache.h
@@ -24,8 +24,8 @@ public:
, ItemsAmount(0)
, TotalSize(0)
, MaxSize(maxSize)
- {
- }
+ {
+ }
public:
struct TItem: public TIntrusiveListItem<TItem> {
@@ -34,20 +34,20 @@ public:
: TBase()
, Key(key)
, Value(value)
- {
- }
+ {
+ }
TItem(const TItem& rhs)
: TBase()
, Key(rhs.Key)
, Value(rhs.Value)
- {
- }
+ {
+ }
bool operator<(const TItem& rhs) const {
return Key < rhs.Key;
}
-
+
bool operator==(const TItem& rhs) const {
return Key == rhs.Key;
}
@@ -58,13 +58,13 @@ public:
struct THash {
size_t operator()(const TItem& item) const {
return ::THash<TKey>()(item.Key);
- }
+ }
};
};
public:
TItem* Insert(TItem* item) {
- List.PushBack(item);
+ List.PushBack(item);
++ItemsAmount;
TotalSize += SizeProvider(item->Value);
@@ -74,32 +74,32 @@ public:
TItem* RemoveIfOverflown() {
TItem* deleted = nullptr;
if (TotalSize > MaxSize && ItemsAmount > 1) {
- deleted = GetOldest();
- Erase(deleted);
+ deleted = GetOldest();
+ Erase(deleted);
}
- return deleted;
+ return deleted;
}
-
+
TItem* GetOldest() {
typename TListType::TIterator it = List.Begin();
Y_ASSERT(it != List.End());
return &*it;
}
-
+
void Erase(TItem* item) {
item->Unlink();
--ItemsAmount;
TotalSize -= SizeProvider(item->Value);
}
-
+
void Promote(TItem* item) {
item->Unlink();
- List.PushBack(item);
+ List.PushBack(item);
}
-
- size_t GetSize() const {
+
+ size_t GetSize() const {
return ItemsAmount;
- }
+ }
size_t GetTotalSize() const {
return TotalSize;
@@ -386,13 +386,13 @@ public:
public:
explicit TIterator(const TIndexConstIterator& iter)
: Iter(iter)
- {
- }
-
+ {
+ }
+
TValue& operator*() {
return const_cast<TValue&>(Iter->Value);
}
-
+
TValue* operator->() {
return const_cast<TValue*>(&Iter->Value);
}
@@ -400,11 +400,11 @@ public:
bool operator==(const TIterator& rhs) const {
return Iter == rhs.Iter;
}
-
+
bool operator!=(const TIterator& rhs) const {
return Iter != rhs.Iter;
}
-
+
TIterator& operator++() {
++Iter;
return *this;
@@ -431,10 +431,10 @@ public:
{
}
- ~TCache() {
- Clear();
- }
-
+ ~TCache() {
+ Clear();
+ }
+
size_t Size() const {
return Index.size();
}
@@ -473,8 +473,8 @@ public:
bool Insert(const std::pair<TKey, TValue>& p) {
return Insert(p.first, p.second);
- }
-
+ }
+
bool Insert(const TKey& key, const TValue& value) {
TItem tmpItem(key, value);
if (!MultiValue && Index.find(tmpItem) != Index.end())
@@ -495,42 +495,42 @@ public:
Y_ASSERT(Index.size() == List.GetSize());
return !insertedWasRemoved;
}
-
- void Update(const TKey& key, const TValue& value) {
+
+ void Update(const TKey& key, const TValue& value) {
if (MultiValue)
ythrow yexception() << "TCache: can't \"Update\" in multicache";
- TIterator it = Find(key);
- if (it != End()) {
- Erase(it);
- }
- Insert(key, value);
-
+ TIterator it = Find(key);
+ if (it != End()) {
+ Erase(it);
+ }
+ Insert(key, value);
+
Y_ASSERT(Index.size() == List.GetSize());
- }
-
+ }
+
void Erase(TIterator it) {
- TItem* item = const_cast<TItem*>(&*it.Iter);
- List.Erase(item);
- TDeleter::Destroy(item->Value);
+ TItem* item = const_cast<TItem*>(&*it.Iter);
+ List.Erase(item);
+ TDeleter::Destroy(item->Value);
Index.erase(it.Iter);
-
+
Y_ASSERT(Index.size() == List.GetSize());
}
-
+
bool Empty() const {
return Index.empty();
}
-
- void Clear() {
- for (TIndexIterator it = Index.begin(); it != Index.end(); ++it) {
- TItem* item = const_cast<TItem*>(&*it);
- List.Erase(item);
- TDeleter::Destroy(item->Value);
- }
+
+ void Clear() {
+ for (TIndexIterator it = Index.begin(); it != Index.end(); ++it) {
+ TItem* item = const_cast<TItem*>(&*it);
+ List.Erase(item);
+ TDeleter::Destroy(item->Value);
+ }
Y_ASSERT(List.GetSize() == 0);
- Index.clear();
- }
-
+ Index.clear();
+ }
+
void SetMaxSize(size_t newSize) {
List.SetMaxSize(newSize);
@@ -549,7 +549,7 @@ protected:
TIndex Index;
TListType List;
bool MultiValue;
-
+
TIterator FindByItem(TItem* item) {
std::pair<TIndexIterator, TIndexIterator> p = Index.equal_range(*item);
// we have to delete the exact unlinked item (there may be multiple items for one key)
@@ -560,12 +560,12 @@ protected:
return (it == p.second ? End() : TIterator(it));
}
- void EraseFromIndex(TItem* item) {
- TDeleter::Destroy(item->Value);
+ void EraseFromIndex(TItem* item) {
+ TDeleter::Destroy(item->Value);
TIterator it = FindByItem(item);
Y_ASSERT(it != End());
Index.erase(it.Iter);
- }
+ }
};
struct TNoopDelete {
@@ -582,8 +582,8 @@ class TLRUCache: public TCache<TKey, TValue, TLRUList<TKey, TValue, TSizeProvide
public:
TLRUCache(size_t maxSize, bool multiValue = false, const TSizeProvider& sizeProvider = TSizeProvider())
: TBase(TListType(maxSize, sizeProvider), multiValue)
- {
- }
+ {
+ }
public:
typedef typename TBase::TIterator TIterator;
diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp
index 7491b76c9d..329872cfde 100644
--- a/library/cpp/cache/ut/cache_ut.cpp
+++ b/library/cpp/cache/ut/cache_ut.cpp
@@ -131,11 +131,11 @@ Y_UNIT_TEST_SUITE(TCacheTest) {
UNIT_ASSERT(s.Find(3) != s.End());
UNIT_ASSERT(*s.Find(3) == "hjkl");
- UNIT_ASSERT(!s.Insert(3, "abcd"));
- UNIT_ASSERT(*s.Find(3) == "hjkl");
- s.Update(3, "abcd");
- UNIT_ASSERT(*s.Find(3) == "abcd");
-
+ UNIT_ASSERT(!s.Insert(3, "abcd"));
+ UNIT_ASSERT(*s.Find(3) == "hjkl");
+ s.Update(3, "abcd");
+ UNIT_ASSERT(*s.Find(3) == "abcd");
+
TCache::TIterator it = s.Find(3);
s.Erase(it);
UNIT_ASSERT(s.Find(3) == s.End());
@@ -332,7 +332,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) {
}
};
int TMyDelete::count = 0;
-
+
Y_UNIT_TEST(DeleterTest) {
typedef TLRUCache<int, TString, TMyDelete> TCache;
TCache s(2);
@@ -345,7 +345,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) {
s.Erase(it);
UNIT_ASSERT(TMyDelete::count == 2);
}
-
+
Y_UNIT_TEST(PromoteOnFind) {
typedef TLRUCache<int, TString> TCache;
TCache s(2);
diff --git a/library/cpp/coroutine/engine/events.h b/library/cpp/coroutine/engine/events.h
index 2d7db781ca..07cc4d25e8 100644
--- a/library/cpp/coroutine/engine/events.h
+++ b/library/cpp/coroutine/engine/events.h
@@ -101,7 +101,7 @@ public:
}
void BroadCast(size_t number) noexcept {
- for (size_t i = 0; i < number && !Waiters_.Empty(); ++i) {
+ for (size_t i = 0; i < number && !Waiters_.Empty(); ++i) {
Waiters_.PopFront()->Wake();
}
}
diff --git a/library/cpp/getopt/small/modchooser.h b/library/cpp/getopt/small/modchooser.h
index 67f3fe3fc0..0a8de6d50b 100644
--- a/library/cpp/getopt/small/modchooser.h
+++ b/library/cpp/getopt/small/modchooser.h
@@ -86,14 +86,14 @@ public:
/*! Run appropriate mode.
*
- * In this method following things happen:
+ * In this method following things happen:
* 1) If first argument is -h/--help/-? then print short description of
* all modes and exit with zero code.
* 2) If first argument is -v/--version and version handler is specified,
- * then call it and exit with zero code.
+ * then call it and exit with zero code.
* 3) Find mode with the same name as first argument. If it's found then
- * call it and return its return code.
- * 4) If appropriate mode is not found - return non-zero code.
+ * call it and return its return code.
+ * 4) If appropriate mode is not found - return non-zero code.
*/
int Run(int argc, const char** argv) const;
diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.cpp b/library/cpp/histogram/adaptive/adaptive_histogram.cpp
index 8cc0323135..cbfc494021 100644
--- a/library/cpp/histogram/adaptive/adaptive_histogram.cpp
+++ b/library/cpp/histogram/adaptive/adaptive_histogram.cpp
@@ -1,12 +1,12 @@
#include "adaptive_histogram.h"
-#include <util/generic/algorithm.h>
+#include <util/generic/algorithm.h>
#include <util/generic/yexception.h>
#include <util/generic/ymath.h>
#include <util/string/printf.h>
-#include <util/system/backtrace.h>
-
+#include <util/system/backtrace.h>
+
namespace NKiwiAggr {
TAdaptiveHistogram::TAdaptiveHistogram(size_t intervals, ui64 id, TQualityFunction qualityFunc)
: Id(id)
@@ -64,7 +64,7 @@ namespace NKiwiAggr {
}
TWeightedValue weightedValue(value, weight);
Add(weightedValue, true);
- PrecomputedBins.clear();
+ PrecomputedBins.clear();
}
void TAdaptiveHistogram::Merge(const THistogram& histo, double multiplier) {
@@ -294,25 +294,25 @@ namespace NKiwiAggr {
if (bound > MaxValue) {
return 0.0;
}
-
- if (!PrecomputedBins.empty()) {
- return GetSumAboveBoundImpl(
- bound,
- PrecomputedBins,
- LowerBound(PrecomputedBins.begin(), PrecomputedBins.end(), TFastBin{bound, -1.0, 0, 0}),
+
+ if (!PrecomputedBins.empty()) {
+ return GetSumAboveBoundImpl(
+ bound,
+ PrecomputedBins,
+ LowerBound(PrecomputedBins.begin(), PrecomputedBins.end(), TFastBin{bound, -1.0, 0, 0}),
[](const auto& it) { return it->SumAbove; });
- } else {
- return GetSumAboveBoundImpl(
- bound,
- Bins,
- Bins.lower_bound(TWeightedValue(bound, -1.0)),
- [this](TPairSet::const_iterator rightBin) {
- ++rightBin;
- double sum = 0;
- for (TPairSet::const_iterator it = rightBin; it != Bins.end(); ++it) {
- sum += it->second;
- }
- return sum;
+ } else {
+ return GetSumAboveBoundImpl(
+ bound,
+ Bins,
+ Bins.lower_bound(TWeightedValue(bound, -1.0)),
+ [this](TPairSet::const_iterator rightBin) {
+ ++rightBin;
+ double sum = 0;
+ for (TPairSet::const_iterator it = rightBin; it != Bins.end(); ++it) {
+ sum += it->second;
+ }
+ return sum;
});
}
}
@@ -327,24 +327,24 @@ namespace NKiwiAggr {
if (bound > MaxValue) {
return Sum;
}
-
- if (!PrecomputedBins.empty()) {
- return GetSumBelowBoundImpl(
- bound,
- PrecomputedBins,
- LowerBound(PrecomputedBins.begin(), PrecomputedBins.end(), TFastBin{bound, -1.0, 0, 0}),
+
+ if (!PrecomputedBins.empty()) {
+ return GetSumBelowBoundImpl(
+ bound,
+ PrecomputedBins,
+ LowerBound(PrecomputedBins.begin(), PrecomputedBins.end(), TFastBin{bound, -1.0, 0, 0}),
[](const auto& it) { return it->SumBelow; });
- } else {
- return GetSumBelowBoundImpl(
- bound,
- Bins,
- Bins.lower_bound(TWeightedValue(bound, -1.0)),
- [this](TPairSet::const_iterator rightBin) {
- double sum = 0;
- for (TPairSet::iterator it = Bins.begin(); it != rightBin; ++it) {
- sum += it->second;
- }
- return sum;
+ } else {
+ return GetSumBelowBoundImpl(
+ bound,
+ Bins,
+ Bins.lower_bound(TWeightedValue(bound, -1.0)),
+ [this](TPairSet::const_iterator rightBin) {
+ double sum = 0;
+ for (TPairSet::iterator it = Bins.begin(); it != rightBin; ++it) {
+ sum += it->second;
+ }
+ return sum;
});
}
}
@@ -583,55 +583,55 @@ namespace NKiwiAggr {
Add(newBin, false);
}
- void TAdaptiveHistogram::PrecomputePartialSums() {
- PrecomputedBins.clear();
- PrecomputedBins.reserve(Bins.size());
- double currentSum = 0;
- for (const auto& bin : Bins) {
- PrecomputedBins.emplace_back(bin.first, bin.second, currentSum, Sum - currentSum - bin.second);
- currentSum += bin.second;
- }
- }
-
- template <typename TBins, typename TGetSumAbove>
- double TAdaptiveHistogram::GetSumAboveBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumAbove& getSumAbove) const {
- typename TBins::value_type left(MinValue, 0.0);
- typename TBins::value_type right(MaxValue, 0.0);
- if (rightBin != bins.end()) {
- right = *rightBin;
- }
- if (rightBin != bins.begin()) {
- typename TBins::const_iterator leftBin = rightBin;
- --leftBin;
- left = *leftBin;
- }
- double sum = (right.second / 2) + ((right.first == left.first) ? ((left.second + right.second) / 2) : (((left.second + right.second) / 2) * (right.first - bound) / (right.first - left.first)));
- if (rightBin == bins.end()) {
- return sum;
- }
- sum += getSumAbove(rightBin);
- return sum;
- }
-
- template <typename TBins, typename TGetSumBelow>
- double TAdaptiveHistogram::GetSumBelowBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumBelow& getSumBelow) const {
- typename TBins::value_type left(MinValue, 0.0);
- typename TBins::value_type right(MaxValue, 0.0);
- if (rightBin != bins.end()) {
- right = *rightBin;
- }
- if (rightBin != bins.begin()) {
- typename TBins::const_iterator leftBin = rightBin;
- --leftBin;
- left = *leftBin;
- }
- double sum = (left.second / 2) + ((right.first == left.first) ? ((left.second + right.second) / 2) : (((left.second + right.second) / 2) * (bound - left.first) / (right.first - left.first)));
- if (rightBin == bins.begin()) {
- return sum;
- }
- --rightBin;
- sum += getSumBelow(rightBin);
- return sum;
- }
-
+ void TAdaptiveHistogram::PrecomputePartialSums() {
+ PrecomputedBins.clear();
+ PrecomputedBins.reserve(Bins.size());
+ double currentSum = 0;
+ for (const auto& bin : Bins) {
+ PrecomputedBins.emplace_back(bin.first, bin.second, currentSum, Sum - currentSum - bin.second);
+ currentSum += bin.second;
+ }
+ }
+
+ template <typename TBins, typename TGetSumAbove>
+ double TAdaptiveHistogram::GetSumAboveBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumAbove& getSumAbove) const {
+ typename TBins::value_type left(MinValue, 0.0);
+ typename TBins::value_type right(MaxValue, 0.0);
+ if (rightBin != bins.end()) {
+ right = *rightBin;
+ }
+ if (rightBin != bins.begin()) {
+ typename TBins::const_iterator leftBin = rightBin;
+ --leftBin;
+ left = *leftBin;
+ }
+ double sum = (right.second / 2) + ((right.first == left.first) ? ((left.second + right.second) / 2) : (((left.second + right.second) / 2) * (right.first - bound) / (right.first - left.first)));
+ if (rightBin == bins.end()) {
+ return sum;
+ }
+ sum += getSumAbove(rightBin);
+ return sum;
+ }
+
+ template <typename TBins, typename TGetSumBelow>
+ double TAdaptiveHistogram::GetSumBelowBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumBelow& getSumBelow) const {
+ typename TBins::value_type left(MinValue, 0.0);
+ typename TBins::value_type right(MaxValue, 0.0);
+ if (rightBin != bins.end()) {
+ right = *rightBin;
+ }
+ if (rightBin != bins.begin()) {
+ typename TBins::const_iterator leftBin = rightBin;
+ --leftBin;
+ left = *leftBin;
+ }
+ double sum = (left.second / 2) + ((right.first == left.first) ? ((left.second + right.second) / 2) : (((left.second + right.second) / 2) * (bound - left.first) / (right.first - left.first)));
+ if (rightBin == bins.begin()) {
+ return sum;
+ }
+ --rightBin;
+ sum += getSumBelow(rightBin);
+ return sum;
+ }
+
}
diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.h b/library/cpp/histogram/adaptive/adaptive_histogram.h
index 2c057ff2a1..fa8f48433f 100644
--- a/library/cpp/histogram/adaptive/adaptive_histogram.h
+++ b/library/cpp/histogram/adaptive/adaptive_histogram.h
@@ -17,27 +17,27 @@ namespace NKiwiAggr {
private:
using TPairSet = TSet<TWeightedValue>;
- struct TFastBin {
- // these names are for compatibility with TWeightedValue
- double first;
- double second;
- // both sums do not include current bin
- double SumBelow;
- double SumAbove;
-
+ struct TFastBin {
+ // these names are for compatibility with TWeightedValue
+ double first;
+ double second;
+ // both sums do not include current bin
+ double SumBelow;
+ double SumAbove;
+
TFastBin(double first_, double second_, double sumBelow = 0, double sumAbove = 0)
- : first(first_)
- , second(second_)
- , SumBelow(sumBelow)
- , SumAbove(sumAbove)
- {
- }
-
+ : first(first_)
+ , second(second_)
+ , SumBelow(sumBelow)
+ , SumAbove(sumAbove)
+ {
+ }
+
bool operator<(const TFastBin& rhs) const {
- return first < rhs.first;
- }
- };
-
+ return first < rhs.first;
+ }
+ };
+
ui64 Id;
double MinValue;
double MaxValue;
@@ -48,7 +48,7 @@ namespace NKiwiAggr {
TQualityFunction CalcQuality;
TVector<TFastBin> PrecomputedBins;
-
+
public:
TAdaptiveHistogram(size_t intervals, ui64 id = 0, TQualityFunction qualityFunc = CalcWeightQuality);
TAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = nullptr);
@@ -88,18 +88,18 @@ namespace NKiwiAggr {
double CalcLowerBoundSafe(double sum) final;
void PrecomputePartialSums() final;
-
+
private:
void FromIHistogram(IHistogram* histo);
void Add(const TWeightedValue& weightedValue, bool initial);
void Erase(double value);
void Shrink();
-
- template <typename TBins, typename TGetSumAbove>
- double GetSumAboveBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumAbove& getSumAbove) const;
-
- template <typename TBins, typename TGetSumBelow>
- double GetSumBelowBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumBelow& getSumBelow) const;
+
+ template <typename TBins, typename TGetSumAbove>
+ double GetSumAboveBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumAbove& getSumAbove) const;
+
+ template <typename TBins, typename TGetSumBelow>
+ double GetSumBelowBoundImpl(double bound, const TBins& bins, typename TBins::const_iterator rightBin, const TGetSumBelow& getSumBelow) const;
};
template <TQualityFunction QualityFunction>
diff --git a/library/cpp/histogram/adaptive/auto_histogram.h b/library/cpp/histogram/adaptive/auto_histogram.h
index 4c2c6b8bde..9fdf0b9abe 100644
--- a/library/cpp/histogram/adaptive/auto_histogram.h
+++ b/library/cpp/histogram/adaptive/auto_histogram.h
@@ -139,10 +139,10 @@ namespace NKiwiAggr {
virtual double CalcLowerBoundSafe(double sum) {
return HistogramImpl->CalcLowerBoundSafe(sum);
}
-
- virtual void PrecomputePartialSums() {
- return HistogramImpl->PrecomputePartialSums();
- }
+
+ virtual void PrecomputePartialSums() {
+ return HistogramImpl->PrecomputePartialSums();
+ }
};
}
diff --git a/library/cpp/histogram/adaptive/histogram.h b/library/cpp/histogram/adaptive/histogram.h
index 639a9c0445..360fd9a693 100644
--- a/library/cpp/histogram/adaptive/histogram.h
+++ b/library/cpp/histogram/adaptive/histogram.h
@@ -57,8 +57,8 @@ namespace NKiwiAggr {
double GetValueAtPercentileSafe(double percentile) {
return CalcUpperBoundSafe(percentile * GetSum());
}
-
- // Histogram implementation is supposed to clear all precomputed values() if Add() is called after PrecomputePartialSums()
+
+ // Histogram implementation is supposed to clear all precomputed values() if Add() is called after PrecomputePartialSums()
virtual void PrecomputePartialSums() {
}
};
diff --git a/library/cpp/histogram/adaptive/multi_histogram.h b/library/cpp/histogram/adaptive/multi_histogram.h
index af5778718f..41caac5ba6 100644
--- a/library/cpp/histogram/adaptive/multi_histogram.h
+++ b/library/cpp/histogram/adaptive/multi_histogram.h
@@ -5,7 +5,7 @@
#include <library/cpp/histogram/adaptive/protos/histo.pb.h>
-#include <util/generic/hash.h>
+#include <util/generic/hash.h>
#include <util/generic/ptr.h>
#include <utility>
@@ -119,12 +119,12 @@ namespace NKiwiAggr {
it->second->ToProto(*histo);
}
}
-
- void PrecomputePartialSums() {
- for (auto& it : Histograms) {
- it.second->PrecomputePartialSums();
- }
- }
+
+ void PrecomputePartialSums() {
+ for (auto& it : Histograms) {
+ it.second->PrecomputePartialSums();
+ }
+ }
};
template <class TMerger, class TSomeMultiHistogram>
diff --git a/library/cpp/json/domscheme_traits.h b/library/cpp/json/domscheme_traits.h
index 5d6077f270..a5a99cd8cf 100644
--- a/library/cpp/json/domscheme_traits.h
+++ b/library/cpp/json/domscheme_traits.h
@@ -1,16 +1,16 @@
-#pragma once
-
+#pragma once
+
#include "json_value.h"
#include "json_reader.h"
-#include "json_writer.h"
-#include <util/generic/algorithm.h>
-
-struct TJsonTraits {
+#include "json_writer.h"
+#include <util/generic/algorithm.h>
+
+struct TJsonTraits {
using TValue = NJson::TJsonValue;
using TValueRef = TValue*;
using TConstValueRef = const TValue*;
using TStringType = TStringBuf;
-
+
// anyvalue defaults
template <class T>
static inline TValue Value(T&& t) {
@@ -32,110 +32,110 @@ struct TJsonTraits {
return &v;
}
- // common ops
- static inline bool IsNull(TConstValueRef v) {
- return v->GetType() == NJson::JSON_UNDEFINED || v->IsNull();
- }
-
- static inline TString ToJson(TConstValueRef v) {
- return NJson::WriteJson(v, false);
- }
-
- // struct ops
- static inline TValueRef GetField(TValueRef v, const TStringBuf& name) {
- return &(*v)[name];
- }
-
- static inline TConstValueRef GetField(TConstValueRef v, const TStringBuf& name) {
- return &(*v)[name];
- }
-
- // array ops
- static bool IsArray(TConstValueRef v) {
- return v->IsArray();
- }
-
- static inline void ArrayClear(TValueRef v) {
- v->SetType(NJson::JSON_NULL);
- v->SetType(NJson::JSON_ARRAY);
- }
-
+ // common ops
+ static inline bool IsNull(TConstValueRef v) {
+ return v->GetType() == NJson::JSON_UNDEFINED || v->IsNull();
+ }
+
+ static inline TString ToJson(TConstValueRef v) {
+ return NJson::WriteJson(v, false);
+ }
+
+ // struct ops
+ static inline TValueRef GetField(TValueRef v, const TStringBuf& name) {
+ return &(*v)[name];
+ }
+
+ static inline TConstValueRef GetField(TConstValueRef v, const TStringBuf& name) {
+ return &(*v)[name];
+ }
+
+ // array ops
+ static bool IsArray(TConstValueRef v) {
+ return v->IsArray();
+ }
+
+ static inline void ArrayClear(TValueRef v) {
+ v->SetType(NJson::JSON_NULL);
+ v->SetType(NJson::JSON_ARRAY);
+ }
+
using TArrayIterator = size_t;
static inline TValueRef ArrayElement(TValueRef v, TArrayIterator n) {
- return &(*v)[n];
- }
-
+ return &(*v)[n];
+ }
+
static inline TConstValueRef ArrayElement(TConstValueRef v, TArrayIterator n) {
- return &(*v)[n];
- }
-
- static inline size_t ArraySize(TConstValueRef v) {
- return v->GetArray().size();
- }
-
- static inline TArrayIterator ArrayBegin(TConstValueRef) {
- return 0;
- }
-
- static inline TArrayIterator ArrayEnd(TConstValueRef v) {
- return ArraySize(v);
- }
-
- // dict ops
- static bool IsDict(TConstValueRef v) {
- return v->IsMap();
- }
-
- static inline void DictClear(TValueRef v) {
- v->SetType(NJson::JSON_NULL);
- v->SetType(NJson::JSON_MAP);
- }
-
- static inline TValueRef DictElement(TValueRef v, TStringBuf key) {
- return &(*v)[key];
- }
-
- static inline TConstValueRef DictElement(TConstValueRef v, TStringBuf key) {
- return &(*v)[key];
- }
-
+ return &(*v)[n];
+ }
+
+ static inline size_t ArraySize(TConstValueRef v) {
+ return v->GetArray().size();
+ }
+
+ static inline TArrayIterator ArrayBegin(TConstValueRef) {
+ return 0;
+ }
+
+ static inline TArrayIterator ArrayEnd(TConstValueRef v) {
+ return ArraySize(v);
+ }
+
+ // dict ops
+ static bool IsDict(TConstValueRef v) {
+ return v->IsMap();
+ }
+
+ static inline void DictClear(TValueRef v) {
+ v->SetType(NJson::JSON_NULL);
+ v->SetType(NJson::JSON_MAP);
+ }
+
+ static inline TValueRef DictElement(TValueRef v, TStringBuf key) {
+ return &(*v)[key];
+ }
+
+ static inline TConstValueRef DictElement(TConstValueRef v, TStringBuf key) {
+ return &(*v)[key];
+ }
+
static inline size_t DictSize(TConstValueRef v) {
- return v->GetMap().size();
- }
-
+ return v->GetMap().size();
+ }
+
using TDictIterator = NJson::TJsonValue::TMapType::const_iterator;
-
- static inline TDictIterator DictBegin(TConstValueRef v) {
- return v->GetMap().begin();
- }
-
- static inline TDictIterator DictEnd(TConstValueRef v) {
- return v->GetMap().end();
- }
-
- static inline TStringBuf DictIteratorKey(TConstValueRef /*dict*/, const TDictIterator& it) {
- return it->first;
- }
-
- static inline TConstValueRef DictIteratorValue(TConstValueRef /*dict*/, const TDictIterator& it) {
- return &it->second;
- }
-
- // boolean ops
- static inline void Get(TConstValueRef v, bool def, bool& b) {
- b =
+
+ static inline TDictIterator DictBegin(TConstValueRef v) {
+ return v->GetMap().begin();
+ }
+
+ static inline TDictIterator DictEnd(TConstValueRef v) {
+ return v->GetMap().end();
+ }
+
+ static inline TStringBuf DictIteratorKey(TConstValueRef /*dict*/, const TDictIterator& it) {
+ return it->first;
+ }
+
+ static inline TConstValueRef DictIteratorValue(TConstValueRef /*dict*/, const TDictIterator& it) {
+ return &it->second;
+ }
+
+ // boolean ops
+ static inline void Get(TConstValueRef v, bool def, bool& b) {
+ b =
v->GetType() == NJson::JSON_UNDEFINED ? def : v->IsNull() ? def : v->GetBooleanRobust();
- }
-
- static inline void Get(TConstValueRef v, bool& b) {
- Get(v, false, b);
- }
-
- static inline bool IsValidPrimitive(const bool&, TConstValueRef v) {
- return v->IsBoolean();
- }
-
+ }
+
+ static inline void Get(TConstValueRef v, bool& b) {
+ Get(v, false, b);
+ }
+
+ static inline bool IsValidPrimitive(const bool&, TConstValueRef v) {
+ return v->IsBoolean();
+ }
+
#define INTEGER_OPS(type, checkOp, getOp) \
static inline void Get(TConstValueRef v, type def, type& i) { \
i = v->checkOp() ? v->getOp() : def; \
@@ -144,73 +144,73 @@ struct TJsonTraits {
i = v->getOp(); \
} \
static inline bool IsValidPrimitive(const type&, TConstValueRef v) { \
- return v->checkOp() && v->getOp() >= Min<type>() && v->getOp() <= Max<type>(); \
- }
-
- INTEGER_OPS(i8, IsInteger, GetInteger)
- INTEGER_OPS(i16, IsInteger, GetInteger)
- INTEGER_OPS(i32, IsInteger, GetInteger)
- INTEGER_OPS(i64, IsInteger, GetInteger)
- INTEGER_OPS(ui8, IsUInteger, GetUInteger)
- INTEGER_OPS(ui16, IsUInteger, GetUInteger)
- INTEGER_OPS(ui32, IsUInteger, GetUInteger)
- INTEGER_OPS(ui64, IsUInteger, GetUInteger)
-
-#undef INTEGER_OPS
-
- // double ops
- static inline bool Get(TConstValueRef v, double def, double& d) {
- if (v->IsDouble()) {
- d = v->GetDouble();
- return true;
- }
- d = def;
- return false;
- }
-
- static inline void Get(TConstValueRef v, double& d) {
- d = v->GetDouble();
- }
-
- static inline bool IsValidPrimitive(const double&, TConstValueRef v) {
- return v->IsDouble();
- }
-
- // string ops
- static inline void Get(TConstValueRef v, TStringBuf def, TStringBuf& s) {
- s = v->IsString() ? v->GetString() : def;
- }
-
- static inline void Get(TConstValueRef v, TStringBuf& s) {
- s = v->GetString();
- }
-
- static inline bool IsValidPrimitive(const TStringBuf&, TConstValueRef v) {
- return v->IsString();
- }
-
- // generic set
- template <class T>
- static inline void Set(TValueRef v, T&& t) {
- v->SetValue(t);
- }
-
- static inline void Clear(TValueRef v) {
- v->SetType(NJson::JSON_NULL);
- }
-
- // validation ops
+ return v->checkOp() && v->getOp() >= Min<type>() && v->getOp() <= Max<type>(); \
+ }
+
+ INTEGER_OPS(i8, IsInteger, GetInteger)
+ INTEGER_OPS(i16, IsInteger, GetInteger)
+ INTEGER_OPS(i32, IsInteger, GetInteger)
+ INTEGER_OPS(i64, IsInteger, GetInteger)
+ INTEGER_OPS(ui8, IsUInteger, GetUInteger)
+ INTEGER_OPS(ui16, IsUInteger, GetUInteger)
+ INTEGER_OPS(ui32, IsUInteger, GetUInteger)
+ INTEGER_OPS(ui64, IsUInteger, GetUInteger)
+
+#undef INTEGER_OPS
+
+ // double ops
+ static inline bool Get(TConstValueRef v, double def, double& d) {
+ if (v->IsDouble()) {
+ d = v->GetDouble();
+ return true;
+ }
+ d = def;
+ return false;
+ }
+
+ static inline void Get(TConstValueRef v, double& d) {
+ d = v->GetDouble();
+ }
+
+ static inline bool IsValidPrimitive(const double&, TConstValueRef v) {
+ return v->IsDouble();
+ }
+
+ // string ops
+ static inline void Get(TConstValueRef v, TStringBuf def, TStringBuf& s) {
+ s = v->IsString() ? v->GetString() : def;
+ }
+
+ static inline void Get(TConstValueRef v, TStringBuf& s) {
+ s = v->GetString();
+ }
+
+ static inline bool IsValidPrimitive(const TStringBuf&, TConstValueRef v) {
+ return v->IsString();
+ }
+
+ // generic set
+ template <class T>
+ static inline void Set(TValueRef v, T&& t) {
+ v->SetValue(t);
+ }
+
+ static inline void Clear(TValueRef v) {
+ v->SetType(NJson::JSON_NULL);
+ }
+
+ // validation ops
static inline TVector<TString> GetKeys(TConstValueRef v) {
TVector<TString> res;
- for (const auto& it : v->GetMap()) {
- res.push_back(it.first);
- }
- Sort(res.begin(), res.end());
- return res;
- }
-
- template <typename T>
- static inline bool IsValidPrimitive(const T&, TConstValueRef) {
- return false;
- }
-};
+ for (const auto& it : v->GetMap()) {
+ res.push_back(it.first);
+ }
+ Sort(res.begin(), res.end());
+ return res;
+ }
+
+ template <typename T>
+ static inline bool IsValidPrimitive(const T&, TConstValueRef) {
+ return false;
+ }
+};
diff --git a/library/cpp/scheme/domscheme_traits.h b/library/cpp/scheme/domscheme_traits.h
index 500cadf9c8..a11c4dd444 100644
--- a/library/cpp/scheme/domscheme_traits.h
+++ b/library/cpp/scheme/domscheme_traits.h
@@ -1,14 +1,14 @@
-#pragma once
-
+#pragma once
+
#include "scheme.h"
#include <util/string/cast.h>
-
-struct TSchemeTraits {
+
+struct TSchemeTraits {
using TValue = NSc::TValue;
using TValueRef = TValue*;
using TConstValueRef = const TValue*;
using TStringType = TStringBuf;
-
+
// anyvalue defaults
template <class T>
static inline TValue Value(T&& t) {
@@ -28,113 +28,113 @@ struct TSchemeTraits {
return &v;
}
- // common ops
- static inline bool IsNull(TConstValueRef v) {
- return v->IsNull();
- }
-
- static inline TString ToJson(TConstValueRef v) {
- return v->ToJson();
- }
-
- // struct ops
- static inline TValueRef GetField(TValueRef v, const TStringBuf& name) {
- return &(*v)[name];
- }
-
- static inline TConstValueRef GetField(TConstValueRef v, const TStringBuf& name) {
- return &(*v)[name];
- }
-
- // array ops
- static bool IsArray(TConstValueRef v) {
- return v->IsArray();
- }
-
- static inline void ArrayClear(TValueRef v) {
+ // common ops
+ static inline bool IsNull(TConstValueRef v) {
+ return v->IsNull();
+ }
+
+ static inline TString ToJson(TConstValueRef v) {
+ return v->ToJson();
+ }
+
+ // struct ops
+ static inline TValueRef GetField(TValueRef v, const TStringBuf& name) {
+ return &(*v)[name];
+ }
+
+ static inline TConstValueRef GetField(TConstValueRef v, const TStringBuf& name) {
+ return &(*v)[name];
+ }
+
+ // array ops
+ static bool IsArray(TConstValueRef v) {
+ return v->IsArray();
+ }
+
+ static inline void ArrayClear(TValueRef v) {
v->SetArray();
- v->ClearArray();
- }
-
+ v->ClearArray();
+ }
+
using TArrayIterator = size_t;
static inline TValueRef ArrayElement(TValueRef v, TArrayIterator n) {
- return &(*v)[n];
- }
-
+ return &(*v)[n];
+ }
+
static inline TConstValueRef ArrayElement(TConstValueRef v, TArrayIterator n) {
- return &(*v)[n];
- }
-
- static inline size_t ArraySize(TConstValueRef v) {
- return v->GetArray().size();
- }
-
- static inline TArrayIterator ArrayBegin(TConstValueRef) {
- return 0;
- }
-
- static inline TArrayIterator ArrayEnd(TConstValueRef v) {
- return ArraySize(v);
- }
-
- // dict ops
- static bool IsDict(TConstValueRef v) {
- return v->IsDict();
- }
-
- static inline void DictClear(TValueRef v) {
+ return &(*v)[n];
+ }
+
+ static inline size_t ArraySize(TConstValueRef v) {
+ return v->GetArray().size();
+ }
+
+ static inline TArrayIterator ArrayBegin(TConstValueRef) {
+ return 0;
+ }
+
+ static inline TArrayIterator ArrayEnd(TConstValueRef v) {
+ return ArraySize(v);
+ }
+
+ // dict ops
+ static bool IsDict(TConstValueRef v) {
+ return v->IsDict();
+ }
+
+ static inline void DictClear(TValueRef v) {
v->SetDict();
- v->ClearDict();
- }
-
- static inline TValueRef DictElement(TValueRef v, TStringBuf key) {
- return &(*v)[key];
- }
-
- static inline TConstValueRef DictElement(TConstValueRef v, TStringBuf key) {
- return &(*v)[key];
- }
-
+ v->ClearDict();
+ }
+
+ static inline TValueRef DictElement(TValueRef v, TStringBuf key) {
+ return &(*v)[key];
+ }
+
+ static inline TConstValueRef DictElement(TConstValueRef v, TStringBuf key) {
+ return &(*v)[key];
+ }
+
static inline size_t DictSize(TConstValueRef v) {
return v->GetDict().size();
- }
-
- using TDictIterator = NSc::TDict::const_iterator;
-
- static inline TDictIterator DictBegin(TConstValueRef v) {
- return v->GetDict().begin();
- }
-
- static inline TDictIterator DictEnd(TConstValueRef v) {
- return v->GetDict().end();
- }
-
- static inline TStringBuf DictIteratorKey(TConstValueRef /*dict*/, const TDictIterator& it) {
- return it->first;
- }
-
- static inline TConstValueRef DictIteratorValue(TConstValueRef /*dict*/, const TDictIterator& it) {
- return &it->second;
- }
-
- // boolean ops
- static inline void Get(TConstValueRef v, bool def, bool& b) {
- b = def == true ? !v->IsExplicitFalse() : v->IsTrue();
- }
-
- static inline void Get(TConstValueRef v, bool& b) {
- b = v->IsTrue();
- }
-
- static inline void Set(TValueRef v, bool b) {
- v->SetIntNumber(b ? 1 : 0);
- }
-
- static inline bool IsValidPrimitive(const bool&, TConstValueRef v) {
- return v->IsTrue() || v->IsExplicitFalse();
- }
-
+ }
+
+ using TDictIterator = NSc::TDict::const_iterator;
+
+ static inline TDictIterator DictBegin(TConstValueRef v) {
+ return v->GetDict().begin();
+ }
+
+ static inline TDictIterator DictEnd(TConstValueRef v) {
+ return v->GetDict().end();
+ }
+
+ static inline TStringBuf DictIteratorKey(TConstValueRef /*dict*/, const TDictIterator& it) {
+ return it->first;
+ }
+
+ static inline TConstValueRef DictIteratorValue(TConstValueRef /*dict*/, const TDictIterator& it) {
+ return &it->second;
+ }
+
+ // boolean ops
+ static inline void Get(TConstValueRef v, bool def, bool& b) {
+ b = def == true ? !v->IsExplicitFalse() : v->IsTrue();
+ }
+
+ static inline void Get(TConstValueRef v, bool& b) {
+ b = v->IsTrue();
+ }
+
+ static inline void Set(TValueRef v, bool b) {
+ v->SetIntNumber(b ? 1 : 0);
+ }
+
+ static inline bool IsValidPrimitive(const bool&, TConstValueRef v) {
+ return v->IsTrue() || v->IsExplicitFalse();
+ }
+
#define INTEGER_OPS_EX(type, min, max, isUnsigned) \
static inline void Get(TConstValueRef v, type def, type& i) { \
if (isUnsigned) { \
@@ -157,72 +157,72 @@ struct TSchemeTraits {
} \
static inline void Set(TValueRef v, type i) { \
v->SetIntNumber(i); \
- }
-
-#define INTEGER_OPS(type, isUnsigned) INTEGER_OPS_EX(type, Min<type>(), Max<type>(), isUnsigned)
-
- INTEGER_OPS(i8, false)
- INTEGER_OPS(i16, false)
- INTEGER_OPS(i32, false)
- INTEGER_OPS(i64, false)
- INTEGER_OPS(ui8, true)
- INTEGER_OPS(ui16, true)
- INTEGER_OPS(ui32, true)
+ }
+
+#define INTEGER_OPS(type, isUnsigned) INTEGER_OPS_EX(type, Min<type>(), Max<type>(), isUnsigned)
+
+ INTEGER_OPS(i8, false)
+ INTEGER_OPS(i16, false)
+ INTEGER_OPS(i32, false)
+ INTEGER_OPS(i64, false)
+ INTEGER_OPS(ui8, true)
+ INTEGER_OPS(ui16, true)
+ INTEGER_OPS(ui32, true)
INTEGER_OPS_EX(ui64, 0, (i64)(Max<i64>() >> 1), true)
-
-#undef INTEGER_OPS
-#undef INTEGER_OPS_EX
-
- // double ops
- static inline bool Get(TConstValueRef v, double def, double& d) {
- if (v->IsNumber()) {
- d = v->GetNumber(def);
- return true;
- }
- d = def;
- return false;
- }
-
- static inline void Get(TConstValueRef v, double& d) {
- d = v->GetNumber();
- }
-
- static inline void Set(TValueRef v, double d) {
- v->SetNumber(d);
- }
-
- static inline bool IsValidPrimitive(const double&, TConstValueRef v) {
- return v->IsNumber();
- }
-
- // string ops
- static inline void Get(TConstValueRef v, TStringBuf def, TStringBuf& s) {
- s = v->GetString(def);
- }
-
- static inline void Get(TConstValueRef v, TStringBuf& s) {
- s = v->GetString();
- }
-
- static inline void Set(TValueRef v, TStringBuf s) {
- v->SetString(s);
- }
-
- static inline bool IsValidPrimitive(const TStringBuf&, TConstValueRef v) {
- return v->IsString();
- }
-
- // validation ops
+
+#undef INTEGER_OPS
+#undef INTEGER_OPS_EX
+
+ // double ops
+ static inline bool Get(TConstValueRef v, double def, double& d) {
+ if (v->IsNumber()) {
+ d = v->GetNumber(def);
+ return true;
+ }
+ d = def;
+ return false;
+ }
+
+ static inline void Get(TConstValueRef v, double& d) {
+ d = v->GetNumber();
+ }
+
+ static inline void Set(TValueRef v, double d) {
+ v->SetNumber(d);
+ }
+
+ static inline bool IsValidPrimitive(const double&, TConstValueRef v) {
+ return v->IsNumber();
+ }
+
+ // string ops
+ static inline void Get(TConstValueRef v, TStringBuf def, TStringBuf& s) {
+ s = v->GetString(def);
+ }
+
+ static inline void Get(TConstValueRef v, TStringBuf& s) {
+ s = v->GetString();
+ }
+
+ static inline void Set(TValueRef v, TStringBuf s) {
+ v->SetString(s);
+ }
+
+ static inline bool IsValidPrimitive(const TStringBuf&, TConstValueRef v) {
+ return v->IsString();
+ }
+
+ // validation ops
static inline TVector<TString> GetKeys(TConstValueRef v) {
TVector<TString> res;
- for (const auto& key : v->DictKeys(true)) {
+ for (const auto& key : v->DictKeys(true)) {
res.push_back(ToString(key));
- }
- return res;
- }
-
- template <typename T>
- static inline bool IsValidPrimitive(const T&, TConstValueRef) {
- return false;
- }
-};
+ }
+ return res;
+ }
+
+ template <typename T>
+ static inline bool IsValidPrimitive(const T&, TConstValueRef) {
+ return false;
+ }
+};