diff options
author | kelarev <kelarev@yandex-team.ru> | 2022-02-10 16:50:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:25 +0300 |
commit | 2b7a11999a854601a22b47b483fd03a7de5bfd90 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | 3f71754853b8ed102c9371ac075aa81274a39b9b (diff) | |
download | ydb-2b7a11999a854601a22b47b483fd03a7de5bfd90.tar.gz |
Restoring authorship annotation for <kelarev@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_builder.inl | 106 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/minimize.cpp | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/minimize.h | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/write_trie_backwards.cpp | 18 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/write_trie_backwards.h | 8 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value.cpp | 8 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value_ut.cpp | 50 |
7 files changed, 97 insertions, 97 deletions
diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index aad2607200..f273fa6571 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -85,7 +85,7 @@ public: size_t Save(IOutputStream& os) const; size_t SaveAndDestroy(IOutputStream& os); - + void Clear(); // lies if some key was added at least twice @@ -171,11 +171,11 @@ public: } ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { - ui64 result = SaveRangeAndDestroy(builder, 0, this->size(), os); - Destroy(builder); - return result; - } - + ui64 result = SaveRangeAndDestroy(builder, 0, this->size(), os); + Destroy(builder); + return result; + } + ui64 SaveRange(const TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) const { if (from >= to) return 0; @@ -189,17 +189,17 @@ public: } ui64 SaveRangeAndDestroy(TBuilderImpl* builder, size_t from, size_t to, IOutputStream& os) { - if (from >= to) - return 0; - - size_t median = (from + to) / 2; - - ui64 written = builder->ArcSaveAndDestroy(&(*this)[median], os); - written += SaveRangeAndDestroy(builder, from, median, os); - written += SaveRangeAndDestroy(builder, median + 1, to, os); - return written; - } - + if (from >= to) + return 0; + + size_t median = (from + to) / 2; + + ui64 written = builder->ArcSaveAndDestroy(&(*this)[median], os); + written += SaveRangeAndDestroy(builder, from, median, os); + written += SaveRangeAndDestroy(builder, median + 1, to, os); + return written; + } + void Destroy(TBuilderImpl* builder) override { // Delete all nodes down the stream. for (iterator it = this->begin(); it != this->end(); ++it) { @@ -259,12 +259,12 @@ public: os.Write(Buffer.Get(), Buffer.Size()); return Buffer.Size(); } - + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { - ui64 result = Save(builder, os); - TArrayWithSizeHolder<char>().Swap(Buffer); - return result; - } + ui64 result = Save(builder, os); + TArrayWithSizeHolder<char>().Swap(Buffer); + return result; + } }; struct TSubtreeInFile: public ISubtree { @@ -327,10 +327,10 @@ public: ythrow yexception() << "file " << Data->FileName.Quote() << " size changed"; return written; } - + ui64 SaveAndDestroy(TBuilderImpl* builder, IOutputStream& os) override { - return Save(builder, os); - } + return Save(builder, os); + } }; union { @@ -463,10 +463,10 @@ size_t TCompactTrieBuilder<T, D, S>::Save(IOutputStream& os) const { template <class T, class D, class S> size_t TCompactTrieBuilder<T, D, S>::SaveAndDestroy(IOutputStream& os) { - return Impl->SaveAndDestroy(os); -} - -template <class T, class D, class S> + return Impl->SaveAndDestroy(os); +} + +template <class T, class D, class S> void TCompactTrieBuilder<T, D, S>::Clear() { Impl->Clear(); } @@ -760,14 +760,14 @@ size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Save(IOutputStream template <class T, class D, class S> size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::SaveAndDestroy(IOutputStream& os) { - const size_t len = NodeMeasureSubtree(Root); - if (len != NodeSaveSubtreeAndDestroy(Root, os)) - ythrow yexception() << "something wrong"; - - return len; -} - -template <class T, class D, class S> + const size_t len = NodeMeasureSubtree(Root); + if (len != NodeSaveSubtreeAndDestroy(Root, os)) + ythrow yexception() << "something wrong"; + + return len; +} + +template <class T, class D, class S> size_t TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::GetEntryCount() const { return EntryCount; } @@ -835,10 +835,10 @@ ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtree(TNod template <class T, class D, class S> ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeSaveSubtreeAndDestroy(TNode* thiz, IOutputStream& os) { - return thiz->Subtree()->SaveAndDestroy(this, os); -} - -template <class T, class D, class S> + return thiz->Subtree()->SaveAndDestroy(this, os); +} + +template <class T, class D, class S> void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::NodeBufferSubtree(TNode* thiz) { typedef typename TNode::TArcSet TArcSet; @@ -958,23 +958,23 @@ ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveSelf(const TA } written += NodeSaveLeafValue(thiz->Node, os); - return written; -} - -template <class T, class D, class S> + return written; +} + +template <class T, class D, class S> ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSave(const TArc* thiz, IOutputStream& os) const { - ui64 written = ArcSaveSelf(thiz, os); + ui64 written = ArcSaveSelf(thiz, os); written += NodeSaveSubtree(thiz->Node, os); return written; } -template <class T, class D, class S> +template <class T, class D, class S> ui64 TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::ArcSaveAndDestroy(const TArc* thiz, IOutputStream& os) { - ui64 written = ArcSaveSelf(thiz, os); - written += NodeSaveSubtreeAndDestroy(thiz->Node, os); - return written; -} - + ui64 written = ArcSaveSelf(thiz, os); + written += NodeSaveSubtreeAndDestroy(thiz->Node, os); + return written; +} + // TCompactTrieBuilder::TCompactTrieBuilderImpl::TNode::TArcSet template <class T, class D, class S> @@ -1063,7 +1063,7 @@ const typename TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::TNode* template <class TPacker> size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose /*= false*/, const TPacker& packer /*= TPacker()*/, NCompactTrie::EMinimizeMode mode) { using namespace NCompactTrie; - return CompactTrieMinimizeImpl(os, data, datalength, verbose, &packer, mode); + return CompactTrieMinimizeImpl(os, data, datalength, verbose, &packer, mode); } template <class TTrieBuilder> diff --git a/library/cpp/containers/comptrie/minimize.cpp b/library/cpp/containers/comptrie/minimize.cpp index 2837633385..80d0b25217 100644 --- a/library/cpp/containers/comptrie/minimize.cpp +++ b/library/cpp/containers/comptrie/minimize.cpp @@ -270,7 +270,7 @@ namespace NCompactTrie { const size_t len = newNode.Pack(buffer); OffsetIndex.Add(Trie.Length - Get().GetOffset(), resultLength + len); - + return len; } }; diff --git a/library/cpp/containers/comptrie/minimize.h b/library/cpp/containers/comptrie/minimize.h index 36e926e3ab..baaa431d04 100644 --- a/library/cpp/containers/comptrie/minimize.h +++ b/library/cpp/containers/comptrie/minimize.h @@ -16,7 +16,7 @@ namespace NCompactTrie { // Return value: size of the minimized trie. size_t RawCompactTrieMinimizeImpl(IOutputStream& os, TOpaqueTrie& trie, bool verbose, size_t minMergeSize, EMinimizeMode mode); - + // Return value: size of the minimized trie. template <class TPacker> size_t CompactTrieMinimizeImpl(IOutputStream& os, const char* data, size_t datalength, bool verbose, const TPacker* packer, EMinimizeMode mode) { diff --git a/library/cpp/containers/comptrie/write_trie_backwards.cpp b/library/cpp/containers/comptrie/write_trie_backwards.cpp index 905d01cd12..fd8c28b0ed 100644 --- a/library/cpp/containers/comptrie/write_trie_backwards.cpp +++ b/library/cpp/containers/comptrie/write_trie_backwards.cpp @@ -1,8 +1,8 @@ #include "write_trie_backwards.h" #include "comptrie_impl.h" -#include "leaf_skipper.h" - +#include "leaf_skipper.h" + #include <util/generic/buffer.h> #include <util/generic/vector.h> @@ -85,14 +85,14 @@ namespace NCompactTrie { size_t nodeLength = enumerator.RecreateNode(nullptr, end - pos); if (nodeLength > buf.size()) buf.resize(nodeLength); - + size_t realLength = enumerator.RecreateNode(buf.data(), end - pos); Y_ASSERT(realLength == nodeLength); - + pos -= nodeLength; memcpy(pos, buf.data(), nodeLength); } - + switch (mode) { case MM_NOALLOC: os.Write(pos, end - pos); @@ -103,8 +103,8 @@ namespace NCompactTrie { default: Y_VERIFY(false); } - + return end - pos; - } - -} + } + +} diff --git a/library/cpp/containers/comptrie/write_trie_backwards.h b/library/cpp/containers/comptrie/write_trie_backwards.h index dc0e5df81c..634e6b811a 100644 --- a/library/cpp/containers/comptrie/write_trie_backwards.h +++ b/library/cpp/containers/comptrie/write_trie_backwards.h @@ -1,7 +1,7 @@ #pragma once -#include "minimize.h" - +#include "minimize.h" + #include <util/generic/vector.h> #include <util/stream/output.h> #include <cstddef> @@ -15,8 +15,8 @@ namespace NCompactTrie { virtual size_t RecreateNode(char* buffer, size_t resultLength) = 0; }; - struct TOpaqueTrie; - + struct TOpaqueTrie; + size_t WriteTrieBackwards(IOutputStream& os, TReverseNodeEnumerator& enumerator, bool verbose); size_t WriteTrieBackwardsNoAlloc(IOutputStream& os, TReverseNodeEnumerator& enumerator, TOpaqueTrie& trie, EMinimizeMode mode); diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index a21a2f1cc9..c61e8d1dc4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -869,8 +869,8 @@ namespace NJson { return true; } return false; - } - + } + bool TJsonValue::SetValueByPath(const TStringBuf path, TJsonValue&& value, char delimiter) { TJsonValue* const ptr = GetValuePtrByPath<true>(this, path, delimiter); if (ptr) { @@ -878,8 +878,8 @@ namespace NJson { return true; } return false; - } - + } + const TJsonValue* TJsonValue::GetValueByPath(const TStringBuf key, char delim) const noexcept { return GetValuePtrByPath<false>(this, key, delim); } diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index d8c7f00124..dc7f6affdf 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -245,10 +245,10 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { lhs.InsertValue("l", last); TJsonValue result; - UNIT_ASSERT(lhs.GetValueByPath("l/a/c/e", result, '/')); + UNIT_ASSERT(lhs.GetValueByPath("l/a/c/e", result, '/')); UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(!lhs.GetValueByPath("l/a/c/se", result, '/')); - UNIT_ASSERT(lhs.GetValueByPath("l/a/c", result, '/')); + UNIT_ASSERT(!lhs.GetValueByPath("l/a/c/se", result, '/')); + UNIT_ASSERT(lhs.GetValueByPath("l/a/c", result, '/')); UNIT_ASSERT(result.GetStringRobust() == "{\"e\":\"f\"}"); // faster TStringBuf version @@ -260,28 +260,28 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT_EQUAL(lhs.GetValueByPath("a/c/e/x", '/'), NULL); UNIT_ASSERT_EQUAL(lhs.GetValueByPath("nokey", '/'), NULL); UNIT_ASSERT_EQUAL(*lhs.GetValueByPath("", '/'), lhs); // itself - - TJsonValue array; - TJsonValue third; - array[0] = first; - array[1] = second; - third["t"] = array; - - UNIT_ASSERT(array.GetValueByPath("[0].e", result)); - UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(third.GetValueByPath("t.[0].e", result)); - UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(third.GetValueByPath("t.[1].c.e", result)); - UNIT_ASSERT(result.GetStringRobust() == "f"); - UNIT_ASSERT(!third.GetValueByPath("t.[2]", result)); - - UNIT_ASSERT(third.SetValueByPath("t.[2]", "g")); - UNIT_ASSERT(third.GetValueByPath("t.[2]", result)); - UNIT_ASSERT(result.GetStringRobust() == "g"); - - UNIT_ASSERT(lhs.SetValueByPath("l/a/c/se", "h", '/')); - UNIT_ASSERT(lhs.GetValueByPath("l/a/c/se", result, '/')); - UNIT_ASSERT(result.GetStringRobust() == "h"); + + TJsonValue array; + TJsonValue third; + array[0] = first; + array[1] = second; + third["t"] = array; + + UNIT_ASSERT(array.GetValueByPath("[0].e", result)); + UNIT_ASSERT(result.GetStringRobust() == "f"); + UNIT_ASSERT(third.GetValueByPath("t.[0].e", result)); + UNIT_ASSERT(result.GetStringRobust() == "f"); + UNIT_ASSERT(third.GetValueByPath("t.[1].c.e", result)); + UNIT_ASSERT(result.GetStringRobust() == "f"); + UNIT_ASSERT(!third.GetValueByPath("t.[2]", result)); + + UNIT_ASSERT(third.SetValueByPath("t.[2]", "g")); + UNIT_ASSERT(third.GetValueByPath("t.[2]", result)); + UNIT_ASSERT(result.GetStringRobust() == "g"); + + UNIT_ASSERT(lhs.SetValueByPath("l/a/c/se", "h", '/')); + UNIT_ASSERT(lhs.GetValueByPath("l/a/c/se", result, '/')); + UNIT_ASSERT(result.GetStringRobust() == "h"); } } |