aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorskalsin <skalsin@yandex-team.ru>2022-02-10 16:46:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:39 +0300
commit5036b5f2122001f9aef8a0e4cd85440d73ea6b9f (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /util
parent0ec5f3106fcb5e342ec13cdfad678bf4633580d5 (diff)
downloadydb-5036b5f2122001f9aef8a0e4cd85440d73ea6b9f.tar.gz
Restoring authorship annotation for <skalsin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/digest/multi.pxd4
-rw-r--r--util/digest/multi_ut.pyx32
-rw-r--r--util/generic/hash.h108
-rw-r--r--util/generic/hash_ut.cpp40
-rw-r--r--util/memory/tempbuf.cpp6
-rw-r--r--util/memory/tempbuf.h6
-rw-r--r--util/memory/tempbuf_ut.cpp32
-rw-r--r--util/tests/cython/test_digest.py24
-rw-r--r--util/tests/cython/ya.make2
9 files changed, 127 insertions, 127 deletions
diff --git a/util/digest/multi.pxd b/util/digest/multi.pxd
index cc8348cc75..8b4fae5016 100644
--- a/util/digest/multi.pxd
+++ b/util/digest/multi.pxd
@@ -1,2 +1,2 @@
-cdef extern from "<util/digest/multi.h>" nogil:
- size_t MultiHash(...);
+cdef extern from "<util/digest/multi.h>" nogil:
+ size_t MultiHash(...);
diff --git a/util/digest/multi_ut.pyx b/util/digest/multi_ut.pyx
index 7716e61712..26faa0069b 100644
--- a/util/digest/multi_ut.pyx
+++ b/util/digest/multi_ut.pyx
@@ -1,19 +1,19 @@
-from util.digest.multi cimport MultiHash
+from util.digest.multi cimport MultiHash
from util.generic.string cimport TString
-
-import pytest
-import unittest
-
-
-class TestMultiHash(unittest.TestCase):
-
- def test_str_int(self):
+
+import pytest
+import unittest
+
+
+class TestMultiHash(unittest.TestCase):
+
+ def test_str_int(self):
value = MultiHash(TString(b"1234567"), 123)
- self.assertEquals(value, 17038203285960021630)
-
- def test_int_str(self):
+ self.assertEquals(value, 17038203285960021630)
+
+ def test_int_str(self):
value = MultiHash(123, TString(b"1234567"))
- self.assertEquals(value, 9973288649881090712)
-
- def test_collision(self):
- self.assertNotEquals(MultiHash(1, 1, 0), MultiHash(2, 2, 0))
+ self.assertEquals(value, 9973288649881090712)
+
+ def test_collision(self):
+ self.assertNotEquals(MultiHash(1, 1, 0), MultiHash(2, 2, 0))
diff --git a/util/generic/hash.h b/util/generic/hash.h
index 8852e69488..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -676,24 +676,24 @@ public:
template <class OtherValue>
iterator insert_equal(const OtherValue& obj) {
reserve(num_elements + 1);
- return emplace_equal_noresize(obj);
+ return emplace_equal_noresize(obj);
}
- template <typename... Args>
+ template <typename... Args>
iterator emplace_equal(Args&&... args) {
reserve(num_elements + 1);
- return emplace_equal_noresize(std::forward<Args>(args)...);
- }
-
+ return emplace_equal_noresize(std::forward<Args>(args)...);
+ }
+
template <class OtherValue>
iterator insert_direct(const OtherValue& obj, insert_ctx ins) {
- return emplace_direct(ins, obj);
- }
-
- template <typename... Args>
+ return emplace_direct(ins, obj);
+ }
+
+ template <typename... Args>
iterator emplace_direct(insert_ctx ins, Args&&... args) {
bool resized = reserve(num_elements + 1);
- node* tmp = new_node(std::forward<Args>(args)...);
+ node* tmp = new_node(std::forward<Args>(args)...);
if (resized) {
find_i(get_key(tmp->val), ins);
}
@@ -703,19 +703,19 @@ public:
return iterator(tmp);
}
- template <typename... Args>
+ template <typename... Args>
std::pair<iterator, bool> emplace_unique(Args&&... args) {
reserve(num_elements + 1);
- return emplace_unique_noresize(std::forward<Args>(args)...);
- }
-
- template <typename... Args>
+ return emplace_unique_noresize(std::forward<Args>(args)...);
+ }
+
+ template <typename... Args>
std::pair<iterator, bool> emplace_unique_noresize(Args&&... args);
-
+
template <class OtherValue>
std::pair<iterator, bool> insert_unique_noresize(const OtherValue& obj);
- template <typename... Args>
+ template <typename... Args>
iterator emplace_equal_noresize(Args&&... args);
template <class InputIterator>
@@ -755,7 +755,7 @@ public:
reserve(num_elements + n);
for (; n > 0; --n, ++f)
- emplace_equal_noresize(*f);
+ emplace_equal_noresize(*f);
}
template <class OtherValue>
@@ -929,12 +929,12 @@ private:
return bkt_num_key(get_key(obj), n);
}
- template <typename... Args>
+ template <typename... Args>
node* new_node(Args&&... val) {
node* n = get_node();
n->next = (node*)1; /*y*/ // just for a case
try {
- new (static_cast<void*>(&n->val)) Value(std::forward<Args>(val)...);
+ new (static_cast<void*>(&n->val)) Value(std::forward<Args>(val)...);
} catch (...) {
put_node(n);
throw;
@@ -997,28 +997,28 @@ inline __yhashtable_const_iterator<V> __yhashtable_const_iterator<V>::operator++
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-template <typename... Args>
+template <typename... Args>
std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V, K, HF, Ex, Eq, A>::emplace_unique_noresize(Args&&... args) {
auto deleter = [&](node* tmp) { delete_node(tmp); };
- node* tmp = new_node(std::forward<Args>(args)...);
- std::unique_ptr<node, decltype(deleter)> guard(tmp, deleter);
-
- const size_type n = bkt_num(tmp->val);
- node* first = buckets[n];
-
- if (first) /*y*/
- for (node* cur = first; !((uintptr_t)cur & 1); cur = cur->next) /*y*/
- if (equals(get_key(cur->val), get_key(tmp->val)))
- return std::pair<iterator, bool>(iterator(cur), false); /*y*/
-
- guard.release();
- tmp->next = first ? first : (node*)((uintptr_t)&buckets[n + 1] | 1); /*y*/
- buckets[n] = tmp;
- ++num_elements;
- return std::pair<iterator, bool>(iterator(tmp), true); /*y*/
-}
-
-template <class V, class K, class HF, class Ex, class Eq, class A>
+ node* tmp = new_node(std::forward<Args>(args)...);
+ std::unique_ptr<node, decltype(deleter)> guard(tmp, deleter);
+
+ const size_type n = bkt_num(tmp->val);
+ node* first = buckets[n];
+
+ if (first) /*y*/
+ for (node* cur = first; !((uintptr_t)cur & 1); cur = cur->next) /*y*/
+ if (equals(get_key(cur->val), get_key(tmp->val)))
+ return std::pair<iterator, bool>(iterator(cur), false); /*y*/
+
+ guard.release();
+ tmp->next = first ? first : (node*)((uintptr_t)&buckets[n + 1] | 1); /*y*/
+ buckets[n] = tmp;
+ ++num_elements;
+ return std::pair<iterator, bool>(iterator(tmp), true); /*y*/
+}
+
+template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherValue>
std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V, K, HF, Ex, Eq, A>::insert_unique_noresize(const OtherValue& obj) {
const size_type n = bkt_num(obj);
@@ -1037,25 +1037,25 @@ std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-template <typename... Args>
+template <typename... Args>
__yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::emplace_equal_noresize(Args&&... args) {
auto deleter = [&](node* tmp) { delete_node(tmp); };
- node* tmp = new_node(std::forward<Args>(args)...);
- std::unique_ptr<node, decltype(deleter)> guard(tmp, deleter);
- const size_type n = bkt_num(tmp->val);
+ node* tmp = new_node(std::forward<Args>(args)...);
+ std::unique_ptr<node, decltype(deleter)> guard(tmp, deleter);
+ const size_type n = bkt_num(tmp->val);
node* first = buckets[n];
if (first) /*y*/
for (node* cur = first; !((uintptr_t)cur & 1); cur = cur->next) /*y*/
- if (equals(get_key(cur->val), get_key(tmp->val))) {
- guard.release();
+ if (equals(get_key(cur->val), get_key(tmp->val))) {
+ guard.release();
tmp->next = cur->next;
cur->next = tmp;
++num_elements;
return iterator(tmp); /*y*/
}
- guard.release();
+ guard.release();
tmp->next = first ? first : (node*)((uintptr_t)&buckets[n + 1] | 1); /*y*/
buckets[n] = tmp;
++num_elements;
@@ -1570,10 +1570,10 @@ public:
return rep.insert_unique(obj);
}
- template <typename... Args>
+ template <typename... Args>
std::pair<iterator, bool> emplace(Args&&... args) {
- return rep.emplace_unique(std::forward<Args>(args)...);
- }
+ return rep.emplace_unique(std::forward<Args>(args)...);
+ }
std::pair<iterator, bool> insert_noresize(const value_type& obj) {
return rep.insert_unique_noresize(obj);
@@ -1644,7 +1644,7 @@ public:
return it->second;
}
- return rep.emplace_direct(ctx, std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple())->second;
+ return rep.emplace_direct(ctx, std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple())->second;
}
template <class TheKey>
@@ -1897,11 +1897,11 @@ public:
template <typename... Args>
iterator emplace(Args&&... args) {
- return rep.emplace_equal(std::forward<Args>(args)...);
- }
+ return rep.emplace_equal(std::forward<Args>(args)...);
+ }
iterator insert_noresize(const value_type& obj) {
- return rep.emplace_equal_noresize(obj);
+ return rep.emplace_equal_noresize(obj);
}
template <typename... Args>
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index 7028da5963..0551d58770 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -37,7 +37,7 @@ class THashTest: public TTestBase {
UNIT_TEST(TestInvariants);
UNIT_TEST(TestAllocation);
UNIT_TEST(TestInsertCopy);
- UNIT_TEST(TestEmplace);
+ UNIT_TEST(TestEmplace);
UNIT_TEST(TestEmplaceNoresize);
UNIT_TEST(TestEmplaceDirect);
UNIT_TEST(TestTryEmplace);
@@ -48,7 +48,7 @@ class THashTest: public TTestBase {
UNIT_TEST(TestHSetEmplace);
UNIT_TEST(TestHSetEmplaceNoresize);
UNIT_TEST(TestHSetEmplaceDirect);
- UNIT_TEST(TestNonCopyable);
+ UNIT_TEST(TestNonCopyable);
UNIT_TEST(TestValueInitialization);
UNIT_TEST(TestAssignmentClear);
UNIT_TEST(TestReleaseNodes);
@@ -88,7 +88,7 @@ protected:
void TestInvariants();
void TestAllocation();
void TestInsertCopy();
- void TestEmplace();
+ void TestEmplace();
void TestEmplaceNoresize();
void TestEmplaceDirect();
void TestTryEmplace();
@@ -99,7 +99,7 @@ protected:
void TestHMMapEmplace();
void TestHMMapEmplaceNoresize();
void TestHMMapEmplaceDirect();
- void TestNonCopyable();
+ void TestNonCopyable();
void TestValueInitialization();
void TestAssignmentClear();
void TestReleaseNodes();
@@ -887,14 +887,14 @@ void THashTest::TestInsertCopy() {
hash[TNonCopyableInt<0>(0)] = 0;
}
-void THashTest::TestEmplace() {
+void THashTest::TestEmplace() {
using hash_t = THashMap<int, TNonCopyableInt<0>>;
hash_t hash;
- hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
- auto it = hash.find(1);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
-}
-
+ hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
+ auto it = hash.find(1);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
+}
+
void THashTest::TestEmplaceNoresize() {
using hash_t = THashMap<int, TNonCopyableInt<0>>;
hash_t hash;
@@ -1037,9 +1037,9 @@ void THashTest::TestHSetEmplaceDirect() {
UNIT_ASSERT(!hash.contains(1));
}
-void THashTest::TestNonCopyable() {
- struct TValue: public TNonCopyable {
- int value;
+void THashTest::TestNonCopyable() {
+ struct TValue: public TNonCopyable {
+ int value;
TValue(int _value = 0)
: value(_value)
{
@@ -1047,16 +1047,16 @@ void THashTest::TestNonCopyable() {
operator int() {
return value;
}
- };
-
+ };
+
THashMap<int, TValue> hash;
- hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(5));
+ hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(5));
auto&& value = hash[1];
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(value), 5);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(value), 5);
auto&& not_inserted = hash[2];
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(not_inserted), 0);
-}
-
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(not_inserted), 0);
+}
+
void THashTest::TestValueInitialization() {
THashMap<int, int> hash;
diff --git a/util/memory/tempbuf.cpp b/util/memory/tempbuf.cpp
index 23114ec82c..09a2d0f140 100644
--- a/util/memory/tempbuf.cpp
+++ b/util/memory/tempbuf.cpp
@@ -255,10 +255,10 @@ void TTempBuf::SetPos(size_t off) {
Impl_->SetPos(off);
}
-char* TTempBuf::Proceed(size_t off) {
- char* ptr = Current();
+char* TTempBuf::Proceed(size_t off) {
+ char* ptr = Current();
Impl_->Proceed(off);
- return ptr;
+ return ptr;
}
void TTempBuf::Append(const void* data, size_t len) {
diff --git a/util/memory/tempbuf.h b/util/memory/tempbuf.h
index ea8ce55ea6..334670eb1e 100644
--- a/util/memory/tempbuf.h
+++ b/util/memory/tempbuf.h
@@ -41,7 +41,7 @@ public:
void Reset() noexcept;
void SetPos(size_t off);
- char* Proceed(size_t off);
+ char* Proceed(size_t off);
void Append(const void* data, size_t len);
Y_PURE_FUNCTION bool IsNull() const noexcept;
@@ -97,7 +97,7 @@ public:
return TypedSize(TTempBuf::Filled());
}
- T* Proceed(size_t off) {
- return (T*)TTempBuf::Proceed(RawSize(off));
+ T* Proceed(size_t off) {
+ return (T*)TTempBuf::Proceed(RawSize(off));
}
};
diff --git a/util/memory/tempbuf_ut.cpp b/util/memory/tempbuf_ut.cpp
index e695a43111..d6bcf9d546 100644
--- a/util/memory/tempbuf_ut.cpp
+++ b/util/memory/tempbuf_ut.cpp
@@ -10,14 +10,14 @@ class TTempBufTest: public TTestBase {
UNIT_TEST(TestOps);
UNIT_TEST(TestMoveCtor);
UNIT_TEST(TestAppend);
- UNIT_TEST(TestProceed);
+ UNIT_TEST(TestProceed);
UNIT_TEST_SUITE_END();
public:
void TestCreate();
void TestOps();
void TestMoveCtor();
- void TestProceed();
+ void TestProceed();
void TestAppend() {
TTempBuf tmp;
@@ -77,17 +77,17 @@ void TTempBufTest::TestMoveCtor() {
UNIT_ASSERT(!dst.IsNull());
UNIT_ASSERT_EQUAL(dst.Filled(), 10);
}
-
-void TTempBufTest::TestProceed() {
- TTempBuf src;
-
- char* data = src.Proceed(100);
- UNIT_ASSERT_EQUAL(data, src.Data());
- UNIT_ASSERT_EQUAL(data + 100, src.Current());
- UNIT_ASSERT_EQUAL(100, src.Filled());
-
- char* second = src.Proceed(100);
- UNIT_ASSERT_EQUAL(data + 100, second);
- UNIT_ASSERT_EQUAL(data + 200, src.Current());
- UNIT_ASSERT_EQUAL(200, src.Filled());
-}
+
+void TTempBufTest::TestProceed() {
+ TTempBuf src;
+
+ char* data = src.Proceed(100);
+ UNIT_ASSERT_EQUAL(data, src.Data());
+ UNIT_ASSERT_EQUAL(data + 100, src.Current());
+ UNIT_ASSERT_EQUAL(100, src.Filled());
+
+ char* second = src.Proceed(100);
+ UNIT_ASSERT_EQUAL(data + 100, second);
+ UNIT_ASSERT_EQUAL(data + 200, src.Current());
+ UNIT_ASSERT_EQUAL(200, src.Filled());
+}
diff --git a/util/tests/cython/test_digest.py b/util/tests/cython/test_digest.py
index 092cb09c00..89c95df720 100644
--- a/util/tests/cython/test_digest.py
+++ b/util/tests/cython/test_digest.py
@@ -1,12 +1,12 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import print_function, absolute_import, division
-
-from util.digest.multi_ut import TestMultiHash
-
-# Test discovery does not work in cython modules.
-# Reexporting test classes here to satisfy pylint and pytest.
-
-__all__ = [
- 'TestMultiHash',
-]
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function, absolute_import, division
+
+from util.digest.multi_ut import TestMultiHash
+
+# Test discovery does not work in cython modules.
+# Reexporting test classes here to satisfy pylint and pytest.
+
+__all__ = [
+ 'TestMultiHash',
+]
diff --git a/util/tests/cython/ya.make b/util/tests/cython/ya.make
index 59f324e23a..b928c19026 100644
--- a/util/tests/cython/ya.make
+++ b/util/tests/cython/ya.make
@@ -24,7 +24,7 @@ PY_SRCS(
stream/str_ut.pyx
string/cast_ut.pyx
system/types_ut.pyx
- digest/multi_ut.pyx
+ digest/multi_ut.pyx
)
TEST_SRCS(