aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/containers
diff options
context:
space:
mode:
authoralzobnin <alzobnin@yandex-team.ru>2022-02-10 16:46:50 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:50 +0300
commitc9317148cc3e9f1b0bc0ce95172f47e099f2c554 (patch)
tree1e426d905ba97d8c281c5cc53389faaced3832c7 /library/cpp/containers
parent6170310e8721e225f64ddabf7a7358253d7a1249 (diff)
downloadydb-c9317148cc3e9f1b0bc0ce95172f47e099f2c554.tar.gz
Restoring authorship annotation for <alzobnin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers')
-rw-r--r--library/cpp/containers/comptrie/comptrie_builder.h10
-rw-r--r--library/cpp/containers/comptrie/comptrie_builder.inl26
-rw-r--r--library/cpp/containers/comptrie/comptrie_trie.h28
-rw-r--r--library/cpp/containers/comptrie/comptrie_ut.cpp46
4 files changed, 55 insertions, 55 deletions
diff --git a/library/cpp/containers/comptrie/comptrie_builder.h b/library/cpp/containers/comptrie/comptrie_builder.h
index cf7d2e39a3..ab96450010 100644
--- a/library/cpp/containers/comptrie/comptrie_builder.h
+++ b/library/cpp/containers/comptrie/comptrie_builder.h
@@ -148,12 +148,12 @@ size_t CompactTrieMakeFastLayout(IOutputStream& os, const char* data, size_t dat
template <class TTrieBuilder>
size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false);
-// Composition of minimization and fast layout
-template <class TPacker>
+// Composition of minimization and fast layout
+template <class TPacker>
size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker());
-
-template <class TTrieBuilder>
+
+template <class TTrieBuilder>
size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false);
-
+
// Implementation details moved here.
#include "comptrie_builder.inl"
diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl
index f273fa6571..1e75bbf460 100644
--- a/library/cpp/containers/comptrie/comptrie_builder.inl
+++ b/library/cpp/containers/comptrie/comptrie_builder.inl
@@ -1104,18 +1104,18 @@ size_t CompactTrieMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder,
size_t len = builder.Save(buftmp);
return CompactTrieMakeFastLayout<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose);
}
-
-template <class TPacker>
+
+template <class TPacker>
size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const char* data, size_t datalength, bool verbose/*=false*/, const TPacker& packer/*= TPacker()*/) {
- TBufferStream buftmp;
- size_t len = CompactTrieMinimize(buftmp, data, datalength, verbose, packer);
- return CompactTrieMakeFastLayout(os, buftmp.Buffer().Data(), len, verbose, packer);
-}
-
-template <class TTrieBuilder>
+ TBufferStream buftmp;
+ size_t len = CompactTrieMinimize(buftmp, data, datalength, verbose, packer);
+ return CompactTrieMakeFastLayout(os, buftmp.Buffer().Data(), len, verbose, packer);
+}
+
+template <class TTrieBuilder>
size_t CompactTrieMinimizeAndMakeFastLayout(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) {
- TBufferStream buftmp;
- size_t len = CompactTrieMinimize(buftmp, builder, verbose);
- return CompactTrieMakeFastLayout<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose);
-}
-
+ TBufferStream buftmp;
+ size_t len = CompactTrieMinimize(buftmp, builder, verbose);
+ return CompactTrieMakeFastLayout<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose);
+}
+
diff --git a/library/cpp/containers/comptrie/comptrie_trie.h b/library/cpp/containers/comptrie/comptrie_trie.h
index 40ec1e52b3..d3c2d2e352 100644
--- a/library/cpp/containers/comptrie/comptrie_trie.h
+++ b/library/cpp/containers/comptrie/comptrie_trie.h
@@ -197,11 +197,11 @@ protected:
explicit TCompactTrie(const char* emptyValue);
TCompactTrie(const TBlob& data, const char* emptyValue, TPacker packer = TPacker());
- bool LookupLongestPrefix(const TSymbol* key, size_t keylen, size_t& prefixLen, const char*& valuepos, bool& hasNext) const;
- bool LookupLongestPrefix(const TSymbol* key, size_t keylen, size_t& prefixLen, const char*& valuepos) const {
- bool hasNext;
- return LookupLongestPrefix(key, keylen, prefixLen, valuepos, hasNext);
- }
+ bool LookupLongestPrefix(const TSymbol* key, size_t keylen, size_t& prefixLen, const char*& valuepos, bool& hasNext) const;
+ bool LookupLongestPrefix(const TSymbol* key, size_t keylen, size_t& prefixLen, const char*& valuepos) const {
+ bool hasNext;
+ return LookupLongestPrefix(key, keylen, prefixLen, valuepos, hasNext);
+ }
void LookupPhrases(const char* datapos, size_t len, const TSymbol* key, size_t keylen, TVector<TPhraseMatch>& matches, TSymbol separator) const;
};
@@ -327,8 +327,8 @@ template <class T, class D, class S>
bool TCompactTrie<T, D, S>::Find(const TSymbol* key, size_t keylen, TData* value) const {
size_t prefixLen = 0;
const char* valuepos = nullptr;
- bool hasNext;
- if (!LookupLongestPrefix(key, keylen, prefixLen, valuepos, hasNext) || prefixLen != keylen)
+ bool hasNext;
+ if (!LookupLongestPrefix(key, keylen, prefixLen, valuepos, hasNext) || prefixLen != keylen)
return false;
if (value)
Packer.UnpackLeaf(valuepos, *value);
@@ -463,14 +463,14 @@ template <class T, class D, class S>
bool TCompactTrie<T, D, S>::FindLongestPrefix(const TSymbol* key, size_t keylen, size_t* prefixLen, TData* value, bool* hasNext) const {
const char* valuepos = nullptr;
size_t tempPrefixLen = 0;
- bool tempHasNext;
- bool found = LookupLongestPrefix(key, keylen, tempPrefixLen, valuepos, tempHasNext);
+ bool tempHasNext;
+ bool found = LookupLongestPrefix(key, keylen, tempPrefixLen, valuepos, tempHasNext);
if (prefixLen)
*prefixLen = tempPrefixLen;
if (found && value)
Packer.UnpackLeaf(valuepos, *value);
- if (hasNext)
- *hasNext = tempHasNext;
+ if (hasNext)
+ *hasNext = tempHasNext;
return found;
}
@@ -482,7 +482,7 @@ bool TCompactTrie<T, D, S>::LookupLongestPrefix(const TSymbol* key, size_t keyle
size_t len = DataHolder.Length();
prefixLen = 0;
- hasNext = false;
+ hasNext = false;
bool found = false;
if (EmptyValue) {
@@ -506,9 +506,9 @@ bool TCompactTrie<T, D, S>::LookupLongestPrefix(const TSymbol* key, size_t keyle
Y_ASSERT(datapos <= dataend);
if ((flags & MT_FINAL)) {
- prefixLen = keylen - (keyend - key) - (i ? 1 : 0);
+ prefixLen = keylen - (keyend - key) - (i ? 1 : 0);
valuepos = datapos;
- hasNext = flags & MT_NEXT;
+ hasNext = flags & MT_NEXT;
found = true;
if (!i && key == keyend) { // last byte, and got a match
diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp
index 74bee09b5d..98d880bc25 100644
--- a/library/cpp/containers/comptrie/comptrie_ut.cpp
+++ b/library/cpp/containers/comptrie/comptrie_ut.cpp
@@ -228,8 +228,8 @@ public:
void TestTrieForPairWtrokaVectorInt64();
void TestEmptyValueOutOfOrder();
- void TestFindLongestPrefixWithEmptyValue();
-
+ void TestFindLongestPrefixWithEmptyValue();
+
void TestSearchIterChar();
void TestSearchIterWchar();
void TestSearchIterWchar32();
@@ -1109,7 +1109,7 @@ TVector<TUtf16String> TCompactTrieTest::GetSampleKeys(size_t nKeys) const {
TString sampleKeys[] = {"a", "b", "ac", "bd", "abe", "bcf", "deg", "ah", "xy", "abc"};
TVector<TUtf16String> result;
for (size_t i = 0; i < nKeys; i++)
- result.push_back(ASCIIToWide(sampleKeys[i]));
+ result.push_back(ASCIIToWide(sampleKeys[i]));
return result;
}
@@ -1167,7 +1167,7 @@ void TCompactTrieTest::TestTrieWithContainers(const TVector<TUtf16String>& keys,
for (; p != value.end(); p++, p1++)
CheckEquality<typename TContainer::value_type>(*p, *p1);
}
-
+
unlink(fileName.data());
}
@@ -1189,7 +1189,7 @@ void TCompactTrieTest::TestTrieWithContainers<std::pair<TUtf16String, TVector<i6
CheckEquality<TContainer::first_type>(value.first, sampleData[i].first);
CheckEquality<TContainer::second_type>(value.second, sampleData[i].second);
}
-
+
unlink(fileName.data());
}
@@ -1252,7 +1252,7 @@ void TCompactTrieTest::TestTrieForPairWtrokaVectorInt64() {
data.push_back(std::pair<TUtf16String, TVector<i64>>(keys[i] + u"_v", values[i]));
TestTrieWithContainers<std::pair<TUtf16String, TVector<i64>>>(keys, data, "pair-str-v-i64");
}
-
+
void TCompactTrieTest::TestEmptyValueOutOfOrder() {
TBufferOutput buffer;
using TSymbol = ui32;
@@ -1269,29 +1269,29 @@ void TCompactTrieTest::TestEmptyValueOutOfOrder() {
}
}
-void TCompactTrieTest::TestFindLongestPrefixWithEmptyValue() {
- TBufferOutput buffer;
- {
- TCompactTrieBuilder<wchar16, ui32> builder;
+void TCompactTrieTest::TestFindLongestPrefixWithEmptyValue() {
+ TBufferOutput buffer;
+ {
+ TCompactTrieBuilder<wchar16, ui32> builder;
builder.Add(u"", 42);
builder.Add(u"yandex", 271828);
builder.Add(u"ya", 31415);
- builder.Save(buffer);
- }
- {
- TCompactTrie<wchar16, ui32> trie(buffer.Buffer().Data(), buffer.Buffer().Size());
+ builder.Save(buffer);
+ }
+ {
+ TCompactTrie<wchar16, ui32> trie(buffer.Buffer().Data(), buffer.Buffer().Size());
size_t prefixLen = 123;
- ui32 value = 0;
-
+ ui32 value = 0;
+
UNIT_ASSERT(trie.FindLongestPrefix(u"google", &prefixLen, &value));
- UNIT_ASSERT(prefixLen == 0);
- UNIT_ASSERT(value == 42);
-
+ UNIT_ASSERT(prefixLen == 0);
+ UNIT_ASSERT(value == 42);
+
UNIT_ASSERT(trie.FindLongestPrefix(u"yahoo", &prefixLen, &value));
- UNIT_ASSERT(prefixLen == 2);
- UNIT_ASSERT(value == 31415);
- }
-}
+ UNIT_ASSERT(prefixLen == 2);
+ UNIT_ASSERT(value == 31415);
+ }
+}
template <typename TChar>
struct TConvertKey {