aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorNikita Slyusarev <nslus@yandex-team.com>2022-02-10 16:46:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:52 +0300
commitcd77cecfc03a3eaf87816af28a33067c4f0cdb59 (patch)
tree1308e0bae862d52e0020d881fe758080437fe389 /util/generic
parentcdae02d225fb5b3afbb28990e79a7ac6c9125327 (diff)
downloadydb-cd77cecfc03a3eaf87816af28a33067c4f0cdb59.tar.gz
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/benchmark/fastclp2/metrics/ya.make4
-rw-r--r--util/generic/benchmark/log2/metrics/ya.make4
-rw-r--r--util/generic/benchmark/rotate_bits/metrics/ya.make4
-rw-r--r--util/generic/benchmark/vector_count_ctor/metrics/ya.make4
-rw-r--r--util/generic/bitmap.h44
-rw-r--r--util/generic/bitmap_ut.cpp140
-rw-r--r--util/generic/fuzz/vector/ya.make8
-rw-r--r--util/generic/is_in.h6
-rw-r--r--util/generic/is_in_ut.cpp14
9 files changed, 114 insertions, 114 deletions
diff --git a/util/generic/benchmark/fastclp2/metrics/ya.make b/util/generic/benchmark/fastclp2/metrics/ya.make
index b2d17ebad3..079d0ce5e3 100644
--- a/util/generic/benchmark/fastclp2/metrics/ya.make
+++ b/util/generic/benchmark/fastclp2/metrics/ya.make
@@ -14,8 +14,8 @@ TAG(
ya:fat
)
-TEST_SRCS(main.py)
+TEST_SRCS(main.py)
-DEPENDS(util/generic/benchmark/fastclp2)
+DEPENDS(util/generic/benchmark/fastclp2)
END()
diff --git a/util/generic/benchmark/log2/metrics/ya.make b/util/generic/benchmark/log2/metrics/ya.make
index eb987e38d2..afef38ed11 100644
--- a/util/generic/benchmark/log2/metrics/ya.make
+++ b/util/generic/benchmark/log2/metrics/ya.make
@@ -14,8 +14,8 @@ TAG(
ya:fat
)
-TEST_SRCS(main.py)
+TEST_SRCS(main.py)
-DEPENDS(util/generic/benchmark/log2)
+DEPENDS(util/generic/benchmark/log2)
END()
diff --git a/util/generic/benchmark/rotate_bits/metrics/ya.make b/util/generic/benchmark/rotate_bits/metrics/ya.make
index ac27d2f845..1e08b6019c 100644
--- a/util/generic/benchmark/rotate_bits/metrics/ya.make
+++ b/util/generic/benchmark/rotate_bits/metrics/ya.make
@@ -14,8 +14,8 @@ TAG(
ya:fat
)
-TEST_SRCS(main.py)
+TEST_SRCS(main.py)
-DEPENDS(util/generic/benchmark/rotate_bits)
+DEPENDS(util/generic/benchmark/rotate_bits)
END()
diff --git a/util/generic/benchmark/vector_count_ctor/metrics/ya.make b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
index c48f89b564..edbf2a463b 100644
--- a/util/generic/benchmark/vector_count_ctor/metrics/ya.make
+++ b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
@@ -14,8 +14,8 @@ TAG(
ya:fat
)
-TEST_SRCS(main.py)
+TEST_SRCS(main.py)
-DEPENDS(util/generic/benchmark/vector_count_ctor)
+DEPENDS(util/generic/benchmark/vector_count_ctor)
END()
diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h
index f77d182460..4e65dd9036 100644
--- a/util/generic/bitmap.h
+++ b/util/generic/bitmap.h
@@ -9,7 +9,7 @@
#include <util/system/yassert.h>
#include <util/system/defaults.h>
-#include <util/str_stl.h>
+#include <util/str_stl.h>
#include <util/ysaveload.h>
namespace NBitMapPrivate {
@@ -985,21 +985,21 @@ public:
}
Mask.Sanitize();
}
-
- inline size_t Hash() const {
- THash<TChunk> chunkHasher;
-
- size_t hash = chunkHasher(0);
- bool tailSkipped = false;
- for (size_t i = Mask.GetChunkCapacity(); i > 0; --i) {
- if (tailSkipped || Mask.Data[i - 1]) {
- hash = ::CombineHashes(hash, chunkHasher(Mask.Data[i - 1]));
- tailSkipped = true;
- }
- }
-
- return hash;
- }
+
+ inline size_t Hash() const {
+ THash<TChunk> chunkHasher;
+
+ size_t hash = chunkHasher(0);
+ bool tailSkipped = false;
+ for (size_t i = Mask.GetChunkCapacity(); i > 0; --i) {
+ if (tailSkipped || Mask.Data[i - 1]) {
+ hash = ::CombineHashes(hash, chunkHasher(Mask.Data[i - 1]));
+ tailSkipped = true;
+ }
+ }
+
+ return hash;
+ }
inline const TChunk* GetChunks() const {
return Mask.Data;
@@ -1105,10 +1105,10 @@ public:
using TDynBitMap = TBitMapOps<TDynamicBitMapTraits<ui64>>;
#define Y_FOR_EACH_BIT(var, bitmap) for (size_t var = (bitmap).FirstNonZeroBit(); var != (bitmap).Size(); var = (bitmap).NextNonZeroBit(var))
-
-template <typename TTraits>
+
+template <typename TTraits>
struct THash<TBitMapOps<TTraits>> {
- size_t operator()(const TBitMapOps<TTraits>& elem) const {
- return elem.Hash();
- }
-};
+ size_t operator()(const TBitMapOps<TTraits>& elem) const {
+ return elem.Hash();
+ }
+};
diff --git a/util/generic/bitmap_ut.cpp b/util/generic/bitmap_ut.cpp
index 087d34a8dc..bf139cda08 100644
--- a/util/generic/bitmap_ut.cpp
+++ b/util/generic/bitmap_ut.cpp
@@ -474,80 +474,80 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap4.NextNonZeroBit(127), bitmap4.Size());
UNIT_ASSERT_EQUAL(bitmap4.NextNonZeroBit(533), bitmap4.Size());
}
-
+
Y_UNIT_TEST(TestHashFixed) {
- TBitMap<32, ui8> bitmap32;
- TBitMap<32, ui8> bitmap322;
- TBitMap<64, ui8> bitmap64;
-
- bitmap32.Clear();
- bitmap322.Clear();
- UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap322.Hash());
- bitmap32.Set(0);
- UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap322.Hash());
- bitmap322.Set(0);
- UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap322.Hash());
- bitmap32.Set(8).Set(31);
- UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap322.Hash());
- bitmap322.Set(8).Set(31);
- UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap322.Hash());
-
- bitmap32.Clear();
- bitmap64.Clear();
- UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap64.Hash());
- bitmap32.Set(0);
- UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
- bitmap64.Set(0);
- UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap64.Hash());
- bitmap32.Set(8).Set(31);
- UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
- bitmap64.Set(8).Set(31);
- UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap64.Hash());
- bitmap64.Set(32);
- UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
- }
-
+ TBitMap<32, ui8> bitmap32;
+ TBitMap<32, ui8> bitmap322;
+ TBitMap<64, ui8> bitmap64;
+
+ bitmap32.Clear();
+ bitmap322.Clear();
+ UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap322.Hash());
+ bitmap32.Set(0);
+ UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap322.Hash());
+ bitmap322.Set(0);
+ UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap322.Hash());
+ bitmap32.Set(8).Set(31);
+ UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap322.Hash());
+ bitmap322.Set(8).Set(31);
+ UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap322.Hash());
+
+ bitmap32.Clear();
+ bitmap64.Clear();
+ UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap64.Hash());
+ bitmap32.Set(0);
+ UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
+ bitmap64.Set(0);
+ UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap64.Hash());
+ bitmap32.Set(8).Set(31);
+ UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
+ bitmap64.Set(8).Set(31);
+ UNIT_ASSERT_EQUAL(bitmap32.Hash(), bitmap64.Hash());
+ bitmap64.Set(32);
+ UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
+ }
+
Y_UNIT_TEST(TestHashDynamic) {
- TDynBitMap bitmap1;
- TDynBitMap bitmap2;
-
- bitmap1.Clear();
- bitmap2.Clear();
- UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
- bitmap1.Set(0);
- UNIT_ASSERT_UNEQUAL(bitmap1.Hash(), bitmap2.Hash());
- bitmap2.Set(0);
- UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
- bitmap1.Set(8).Set(31);
- UNIT_ASSERT_UNEQUAL(bitmap1.Hash(), bitmap2.Hash());
- bitmap2.Set(8).Set(31);
- UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
- bitmap1.Set(64);
- UNIT_ASSERT_UNEQUAL(bitmap1.Hash(), bitmap2.Hash());
- bitmap2.Set(64);
- UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
- }
-
+ TDynBitMap bitmap1;
+ TDynBitMap bitmap2;
+
+ bitmap1.Clear();
+ bitmap2.Clear();
+ UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
+ bitmap1.Set(0);
+ UNIT_ASSERT_UNEQUAL(bitmap1.Hash(), bitmap2.Hash());
+ bitmap2.Set(0);
+ UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
+ bitmap1.Set(8).Set(31);
+ UNIT_ASSERT_UNEQUAL(bitmap1.Hash(), bitmap2.Hash());
+ bitmap2.Set(8).Set(31);
+ UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
+ bitmap1.Set(64);
+ UNIT_ASSERT_UNEQUAL(bitmap1.Hash(), bitmap2.Hash());
+ bitmap2.Set(64);
+ UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
+ }
+
Y_UNIT_TEST(TestHashMixed) {
static_assert((std::is_same<TDynBitMap::TChunk, ui64>::value), "expect (TSameType<TDynBitMap::TChunk, ui64>::Result)");
-
- TBitMap<sizeof(ui64) * 16, ui64> bitmapFixed;
- TDynBitMap bitmapDynamic;
-
- bitmapFixed.Clear();
- bitmapDynamic.Clear();
- UNIT_ASSERT_EQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
- bitmapFixed.Set(0);
- UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
- bitmapDynamic.Set(0);
- UNIT_ASSERT_EQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
- bitmapFixed.Set(8).Set(127);
- UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
- bitmapDynamic.Set(8).Set(127);
- UNIT_ASSERT_EQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
- bitmapDynamic.Set(128);
- UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
- }
+
+ TBitMap<sizeof(ui64) * 16, ui64> bitmapFixed;
+ TDynBitMap bitmapDynamic;
+
+ bitmapFixed.Clear();
+ bitmapDynamic.Clear();
+ UNIT_ASSERT_EQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
+ bitmapFixed.Set(0);
+ UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
+ bitmapDynamic.Set(0);
+ UNIT_ASSERT_EQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
+ bitmapFixed.Set(8).Set(127);
+ UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
+ bitmapDynamic.Set(8).Set(127);
+ UNIT_ASSERT_EQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
+ bitmapDynamic.Set(128);
+ UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
+ }
Y_UNIT_TEST(TestSetResetRange) {
// Single chunk
diff --git a/util/generic/fuzz/vector/ya.make b/util/generic/fuzz/vector/ya.make
index b8614f6411..6b41dd8a0b 100644
--- a/util/generic/fuzz/vector/ya.make
+++ b/util/generic/fuzz/vector/ya.make
@@ -1,9 +1,9 @@
FUZZ()
-OWNER(
- pg
- g:util
-)
+OWNER(
+ pg
+ g:util
+)
SUBSCRIBER(g:util-subscribers)
SRCS(
diff --git a/util/generic/is_in.h b/util/generic/is_in.h
index 4f175ea5eb..e452d9f96a 100644
--- a/util/generic/is_in.h
+++ b/util/generic/is_in.h
@@ -3,7 +3,7 @@
#include "typetraits.h"
#include <algorithm>
-#include <initializer_list>
+#include <initializer_list>
template <class I, class T>
static inline bool IsIn(I f, I l, const T& v);
@@ -46,8 +46,8 @@ static inline bool IsIn(const C& c, const T& e) {
using namespace NIsInHelper;
return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e);
}
-
+
template <class T, class U>
static inline bool IsIn(std::initializer_list<T> l, const U& e) {
return ::IsIn(l.begin(), l.end(), e);
-}
+}
diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp
index c668bce807..247f5df4dd 100644
--- a/util/generic/is_in_ut.cpp
+++ b/util/generic/is_in_ut.cpp
@@ -75,11 +75,11 @@ Y_UNIT_TEST_SUITE(TIsIn) {
const char* abc = "abc";
const char* def = "def";
- UNIT_ASSERT(IsIn({6, 2, 12}, 6));
- UNIT_ASSERT(IsIn({6, 2, 12}, 2));
- UNIT_ASSERT(!IsIn({6, 2, 12}, 7));
- UNIT_ASSERT(IsIn({6}, 6));
- UNIT_ASSERT(!IsIn({6}, 7));
+ UNIT_ASSERT(IsIn({6, 2, 12}, 6));
+ UNIT_ASSERT(IsIn({6, 2, 12}, 2));
+ UNIT_ASSERT(!IsIn({6, 2, 12}, 7));
+ UNIT_ASSERT(IsIn({6}, 6));
+ UNIT_ASSERT(!IsIn({6}, 7));
UNIT_ASSERT(!IsIn(std::initializer_list<int>(), 6));
UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("abc")));
UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("def")));
@@ -92,8 +92,8 @@ Y_UNIT_TEST_SUITE(TIsIn) {
const TStringBuf str = "abc////";
UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf{str.data(), 3}));
- }
-
+ }
+
Y_UNIT_TEST(ConfOfTest) {
UNIT_ASSERT(IsIn({1, 2, 3}, 1));
UNIT_ASSERT(!IsIn({1, 2, 3}, 4));