Browse Source

Restoring authorship annotation for <emazhukin@yandex-team.ru>. Commit 1 of 2.

emazhukin 3 years ago
parent
commit
39c9b25634

+ 1 - 1
contrib/python/ya.make

@@ -1030,7 +1030,7 @@ RECURSE(
     srptools
     srsly
     sshpubkeys
-    sshtunnel
+    sshtunnel 
     stack-data
     starlette
     statsd

+ 1 - 1
library/cpp/cache/cache.cpp

@@ -1 +1 @@
-#include "cache.h"
+#include "cache.h" 

+ 1 - 1
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>
 

+ 1 - 1
library/cpp/cache/thread_safe_cache.cpp

@@ -1 +1 @@
-#include "thread_safe_cache.h"
+#include "thread_safe_cache.h" 

+ 21 - 21
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...);

+ 28 - 28
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) {

+ 5 - 5
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(

+ 8 - 8
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 
+) 

+ 8 - 8
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) {

+ 6 - 6
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
     {

Some files were not shown because too many files changed in this diff