diff options
author | emazhukin <emazhukin@yandex-team.ru> | 2022-02-10 16:48:56 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:56 +0300 |
commit | 39c9b256341fc68d2d9f8e561ac985709f65f164 (patch) | |
tree | f449899a12ddc8707a22128e28a370f8d101f69a /library/cpp | |
parent | 5973931d2355b2d66faf8b1b952ba3de1e7a9324 (diff) | |
download | ydb-39c9b256341fc68d2d9f8e561ac985709f65f164.tar.gz |
Restoring authorship annotation for <emazhukin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/cache/cache.cpp | 2 | ||||
-rw-r--r-- | library/cpp/cache/cache.h | 2 | ||||
-rw-r--r-- | library/cpp/cache/thread_safe_cache.cpp | 2 | ||||
-rw-r--r-- | library/cpp/cache/thread_safe_cache.h | 42 | ||||
-rw-r--r-- | library/cpp/cache/ut/cache_ut.cpp | 56 | ||||
-rw-r--r-- | library/cpp/cache/ut/ya.make | 10 | ||||
-rw-r--r-- | library/cpp/cache/ya.make | 16 | ||||
-rw-r--r-- | library/cpp/protobuf/json/json2proto.cpp | 16 | ||||
-rw-r--r-- | library/cpp/protobuf/json/ut/json2proto_ut.cpp | 12 | ||||
-rw-r--r-- | library/cpp/ya.make | 2 |
10 files changed, 80 insertions, 80 deletions
diff --git a/library/cpp/cache/cache.cpp b/library/cpp/cache/cache.cpp index 05b26b0cf8..656aac3a8d 100644 --- a/library/cpp/cache/cache.cpp +++ b/library/cpp/cache/cache.cpp @@ -1 +1 @@ -#include "cache.h" +#include "cache.h" diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h index 6dc997076d..45a7b4a517 100644 --- a/library/cpp/cache/cache.h +++ b/library/cpp/cache/cache.h @@ -4,7 +4,7 @@ #include <util/generic/ptr.h> #include <util/generic/intrlist.h> #include <util/generic/hash_set.h> -#include <util/generic/vector.h> +#include <util/generic/vector.h> #include <util/generic/yexception.h> #include <utility> diff --git a/library/cpp/cache/thread_safe_cache.cpp b/library/cpp/cache/thread_safe_cache.cpp index de47076d6b..e4cbbc8719 100644 --- a/library/cpp/cache/thread_safe_cache.cpp +++ b/library/cpp/cache/thread_safe_cache.cpp @@ -1 +1 @@ -#include "thread_safe_cache.h" +#include "thread_safe_cache.h" diff --git a/library/cpp/cache/thread_safe_cache.h b/library/cpp/cache/thread_safe_cache.h index 71e1442717..8c12fe2dae 100644 --- a/library/cpp/cache/thread_safe_cache.h +++ b/library/cpp/cache/thread_safe_cache.h @@ -36,19 +36,19 @@ namespace NPrivate { { } - bool Insert(const Key& key, const TPtr& value) { - if (!Contains(key)) { - TWriteGuard w(Mutex); - return Cache.Insert(key, value); - } - return false; - } - - void Update(const Key& key, const TPtr& value) { - TWriteGuard w(Mutex); - Cache.Update(key, value); - } - + bool Insert(const Key& key, const TPtr& value) { + if (!Contains(key)) { + TWriteGuard w(Mutex); + return Cache.Insert(key, value); + } + return false; + } + + void Update(const Key& key, const TPtr& value) { + TWriteGuard w(Mutex); + Cache.Update(key, value); + } + const TPtr Get(TArgs... args) const { return GetValue<true>(args...); } @@ -64,8 +64,8 @@ namespace NPrivate { void Erase(TArgs... args) { Key key = Callbacks.GetKey(args...); - if (!Contains(key)) { - return; + if (!Contains(key)) { + return; } TWriteGuard w(Mutex); typename TInternalCache::TIterator i = Cache.Find(key); @@ -75,12 +75,12 @@ namespace NPrivate { Cache.Erase(i); } - bool Contains(const Key& key) const { - TReadGuard r(Mutex); - auto iter = Cache.FindWithoutPromote(key); - return iter != Cache.End(); - } - + bool Contains(const Key& key) const { + TReadGuard r(Mutex); + auto iter = Cache.FindWithoutPromote(key); + return iter != Cache.End(); + } + template <class TCallbacks> static const TPtr Get(TArgs... args) { return TThreadSafeCacheSingleton<TCallbacks>::Get(args...); diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp index 329872cfde..36c7d509d9 100644 --- a/library/cpp/cache/ut/cache_ut.cpp +++ b/library/cpp/cache/ut/cache_ut.cpp @@ -1,5 +1,5 @@ -#include <library/cpp/cache/cache.h> -#include <library/cpp/cache/thread_safe_cache.h> +#include <library/cpp/cache/cache.h> +#include <library/cpp/cache/thread_safe_cache.h> #include <library/cpp/testing/unittest/registar.h> struct TStrokaWeighter { @@ -368,11 +368,11 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { return i; } TValue* CreateObject(ui32 i) const override { - Creations++; + Creations++; return new TString(VALS[i]); } - - mutable i32 Creations = 0; + + mutable i32 Creations = 0; }; Y_UNIT_TEST(SimpleTest) { @@ -381,29 +381,29 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { UNIT_ASSERT(data == VALS[i]); } } - - Y_UNIT_TEST(InsertUpdateTest) { - TCallbacks callbacks; - TCache cache(callbacks, 10); - - cache.Insert(2, MakeAtomicShared<TString>("hj")); - TAtomicSharedPtr<TString> item = cache.Get(2); - - UNIT_ASSERT(callbacks.Creations == 0); - UNIT_ASSERT(*item == "hj"); - - cache.Insert(2, MakeAtomicShared<TString>("hjk")); - item = cache.Get(2); - - UNIT_ASSERT(callbacks.Creations == 0); - UNIT_ASSERT(*item == "hj"); - - cache.Update(2, MakeAtomicShared<TString>("hjk")); - item = cache.Get(2); - - UNIT_ASSERT(callbacks.Creations == 0); - UNIT_ASSERT(*item == "hjk"); - } + + Y_UNIT_TEST(InsertUpdateTest) { + TCallbacks callbacks; + TCache cache(callbacks, 10); + + cache.Insert(2, MakeAtomicShared<TString>("hj")); + TAtomicSharedPtr<TString> item = cache.Get(2); + + UNIT_ASSERT(callbacks.Creations == 0); + UNIT_ASSERT(*item == "hj"); + + cache.Insert(2, MakeAtomicShared<TString>("hjk")); + item = cache.Get(2); + + UNIT_ASSERT(callbacks.Creations == 0); + UNIT_ASSERT(*item == "hj"); + + cache.Update(2, MakeAtomicShared<TString>("hjk")); + item = cache.Get(2); + + UNIT_ASSERT(callbacks.Creations == 0); + UNIT_ASSERT(*item == "hjk"); + } } Y_UNIT_TEST_SUITE(TThreadSafeCacheUnsafeTest) { diff --git a/library/cpp/cache/ut/ya.make b/library/cpp/cache/ut/ya.make index f660872369..bb61612e0c 100644 --- a/library/cpp/cache/ut/ya.make +++ b/library/cpp/cache/ut/ya.make @@ -1,12 +1,12 @@ UNITTEST() -OWNER( - g:util - vskipin -) +OWNER( + g:util + vskipin +) PEERDIR( - library/cpp/cache + library/cpp/cache ) SRCS( diff --git a/library/cpp/cache/ya.make b/library/cpp/cache/ya.make index fd73032bf8..8987af0f5c 100644 --- a/library/cpp/cache/ya.make +++ b/library/cpp/cache/ya.make @@ -1,16 +1,16 @@ LIBRARY() -OWNER( - g:util -) +OWNER( + g:util +) SRCS( cache.cpp - thread_safe_cache.cpp + thread_safe_cache.cpp ) END() - -RECURSE_FOR_TESTS( - ut -) + +RECURSE_FOR_TESTS( + ut +) diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 640c10f5a5..fc602e990f 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -292,11 +292,11 @@ Json2RepeatedFieldValue(const NJson::TJsonValue& jsonValue, Y_ASSERT(!!innerProto); if (key.Defined()) { const FieldDescriptor* keyField = innerProto->GetDescriptor()->FindFieldByName("key"); - Y_ENSURE(keyField, "Map entry key field not found: " << field.name()); + Y_ENSURE(keyField, "Map entry key field not found: " << field.name()); SetKey(*innerProto, *keyField, *key); const FieldDescriptor* valueField = innerProto->GetDescriptor()->FindFieldByName("value"); - Y_ENSURE(valueField, "Map entry value field not found."); + Y_ENSURE(valueField, "Map entry value field not found."); Json2SingleField(jsonValue, *innerProto, *valueField, config, /*isMapValue=*/true); } else { NProtobufJson::MergeJson2Proto(jsonValue, *innerProto, config); @@ -327,12 +327,12 @@ Json2RepeatedField(const NJson::TJsonValue& json, return; bool isMap = fieldJson.GetType() == NJson::JSON_MAP; - if (isMap) { - if (!config.MapAsObject) { - ythrow yexception() << "Map as object representation is not allowed, field: " << field.name(); - } else if (!field.is_map() && !fieldJson.GetMap().empty()) { - ythrow yexception() << "Field " << field.name() << " is not a map."; - } + if (isMap) { + if (!config.MapAsObject) { + ythrow yexception() << "Map as object representation is not allowed, field: " << field.name(); + } else if (!field.is_map() && !fieldJson.GetMap().empty()) { + ythrow yexception() << "Field " << field.name() << " is not a map."; + } } if (fieldJson.GetType() != NJson::JSON_ARRAY && !config.MapAsObject && !config.VectorizeScalars && !config.ValueVectorizer) { diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp index 0dfe57bc7a..5da7b7bf1f 100644 --- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp +++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp @@ -520,13 +520,13 @@ Y_UNIT_TEST(TestInvalidJson) { UNIT_ASSERT_EXCEPTION(Json2Proto(val, proto), yexception); } -Y_UNIT_TEST(TestInvalidRepeatedFieldWithMapAsObject) { - TCompositeRepeated proto; - TJson2ProtoConfig config; - config.MapAsObject = true; +Y_UNIT_TEST(TestInvalidRepeatedFieldWithMapAsObject) { + TCompositeRepeated proto; + TJson2ProtoConfig config; + config.MapAsObject = true; UNIT_ASSERT_EXCEPTION(Json2Proto(TStringBuf(R"({"Part":{"Boo":{}}})"), proto, config), yexception); -} - +} + Y_UNIT_TEST(TestStringTransforms) { // Check that strings and bytes are transformed { diff --git a/library/cpp/ya.make b/library/cpp/ya.make index 8c1193b007..1ee92de56f 100644 --- a/library/cpp/ya.make +++ b/library/cpp/ya.make @@ -164,7 +164,7 @@ RECURSE( infected_masks/ut int128 int128/ut - introspection + introspection ipmath ipreg ipreg/ut |