aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnaury <snaury@ydb.tech>2022-09-14 11:51:07 +0300
committersnaury <snaury@ydb.tech>2022-09-14 11:51:07 +0300
commitdc37dfe86ca1c20394aad4d3d76dfd9405c0b8fa (patch)
treee3a72708266c851570bdd4be9e4dcbea40e07f0e
parent124ca2ab2dc0a5e43cb21c73617d5592156db1f0 (diff)
downloadydb-dc37dfe86ca1c20394aad4d3d76dfd9405c0b8fa.tar.gz
Switch commit hash maps to absl::flat_hash
-rw-r--r--library/cpp/containers/CMakeLists.txt1
-rw-r--r--library/cpp/containers/absl_flat_hash/CMakeLists.txt22
-rw-r--r--ydb/core/tablet_flat/CMakeLists.txt1
-rw-r--r--ydb/core/tablet_flat/flat_executor.cpp2
-rw-r--r--ydb/core/tablet_flat/flat_mem_warm.h12
-rw-r--r--ydb/core/tablet_flat/flat_table.h5
-rw-r--r--ydb/core/tablet_flat/flat_table_committed.h7
7 files changed, 39 insertions, 11 deletions
diff --git a/library/cpp/containers/CMakeLists.txt b/library/cpp/containers/CMakeLists.txt
index cf1ec79fb8..47256015a0 100644
--- a/library/cpp/containers/CMakeLists.txt
+++ b/library/cpp/containers/CMakeLists.txt
@@ -7,6 +7,7 @@
add_subdirectory(2d_array)
+add_subdirectory(absl_flat_hash)
add_subdirectory(atomizer)
add_subdirectory(bitseq)
add_subdirectory(compact_vector)
diff --git a/library/cpp/containers/absl_flat_hash/CMakeLists.txt b/library/cpp/containers/absl_flat_hash/CMakeLists.txt
new file mode 100644
index 0000000000..aeed1a3f3d
--- /dev/null
+++ b/library/cpp/containers/absl_flat_hash/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+# This file was gererated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-containers-absl_flat_hash)
+target_include_directories(cpp-containers-absl_flat_hash PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/restricted/abseil-cpp
+)
+target_link_libraries(cpp-containers-absl_flat_hash PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ abseil-cpp-absl-container
+)
+target_sources(cpp-containers-absl_flat_hash PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/containers/absl_flat_hash/flat_hash_map.cpp
+ ${CMAKE_SOURCE_DIR}/library/cpp/containers/absl_flat_hash/flat_hash_set.cpp
+)
diff --git a/ydb/core/tablet_flat/CMakeLists.txt b/ydb/core/tablet_flat/CMakeLists.txt
index 7b171bd5d7..05dd798c54 100644
--- a/ydb/core/tablet_flat/CMakeLists.txt
+++ b/ydb/core/tablet_flat/CMakeLists.txt
@@ -20,6 +20,7 @@ target_link_libraries(ydb-core-tablet_flat PUBLIC
yutil
tools-enum_parser-enum_serialization_runtime
contrib-libs-protobuf
+ cpp-containers-absl_flat_hash
cpp-containers-intrusive_rb_tree
cpp-containers-stack_vector
cpp-digest-crc32c
diff --git a/ydb/core/tablet_flat/flat_executor.cpp b/ydb/core/tablet_flat/flat_executor.cpp
index 38641a8c41..4e9719940a 100644
--- a/ydb/core/tablet_flat/flat_executor.cpp
+++ b/ydb/core/tablet_flat/flat_executor.cpp
@@ -4234,7 +4234,7 @@ ui64 TExecutor::BeginCompaction(THolder<NTable::TCompactionParams> params)
bool compactTxStatus = false;
for (const auto& memTableSnapshot : snapshot->Subset->Frozen) {
- if (memTableSnapshot->GetCommittedTransactions() || memTableSnapshot->GetRemovedTransactions()) {
+ if (!memTableSnapshot->GetCommittedTransactions().empty() || !memTableSnapshot->GetRemovedTransactions().empty()) {
// We must compact tx status when mem table has changes
compactTxStatus = true;
}
diff --git a/ydb/core/tablet_flat/flat_mem_warm.h b/ydb/core/tablet_flat/flat_mem_warm.h
index 9ce331624f..4682a7ffca 100644
--- a/ydb/core/tablet_flat/flat_mem_warm.h
+++ b/ydb/core/tablet_flat/flat_mem_warm.h
@@ -15,6 +15,8 @@
#include <ydb/core/util/btree_cow.h>
#include <ydb/core/util/yverify_stream.h>
+#include <library/cpp/containers/absl_flat_hash/flat_hash_map.h>
+#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
#include <library/cpp/containers/stack_vector/stack_vec.h>
#include <util/generic/vector.h>
@@ -183,7 +185,7 @@ namespace NMem {
ui64 OpsCount = 0;
};
- using TTxIdStats = THashMap<ui64, TTxIdStat>;
+ using TTxIdStats = absl::flat_hash_map<ui64, TTxIdStat>;
public:
using TTree = NMem::TTree;
@@ -494,11 +496,11 @@ namespace NMem {
}
}
- const THashMap<ui64, TRowVersion>& GetCommittedTransactions() const {
+ const absl::flat_hash_map<ui64, TRowVersion>& GetCommittedTransactions() const {
return Committed;
}
- const THashSet<ui64>& GetRemovedTransactions() const {
+ const absl::flat_hash_set<ui64>& GetRemovedTransactions() const {
return Removed;
}
@@ -549,8 +551,8 @@ namespace NMem {
TRowVersion MinRowVersion = TRowVersion::Max();
TRowVersion MaxRowVersion = TRowVersion::Min();
TTxIdStats TxIdStats;
- THashMap<ui64, TRowVersion> Committed;
- THashSet<ui64> Removed;
+ absl::flat_hash_map<ui64, TRowVersion> Committed;
+ absl::flat_hash_set<ui64> Removed;
private:
struct TRollbackState {
diff --git a/ydb/core/tablet_flat/flat_table.h b/ydb/core/tablet_flat/flat_table.h
index ffd5d450d1..1b9992de11 100644
--- a/ydb/core/tablet_flat/flat_table.h
+++ b/ydb/core/tablet_flat/flat_table.h
@@ -17,6 +17,7 @@
#include "util_basics.h"
#include <ydb/core/scheme/scheme_tablecell.h>
+#include <library/cpp/containers/absl_flat_hash/flat_hash_map.h>
#include <library/cpp/containers/stack_vector/stack_vec.h>
#include <util/generic/deque.h>
@@ -341,8 +342,8 @@ private:
TRowVersionRanges RemovedRowVersions;
- THashMap<ui64, size_t> TxRefs;
- THashSet<ui64> CheckTransactions;
+ absl::flat_hash_map<ui64, size_t> TxRefs;
+ absl::flat_hash_set<ui64> CheckTransactions;
TTransactionMap CommittedTransactions;
TTransactionSet RemovedTransactions;
diff --git a/ydb/core/tablet_flat/flat_table_committed.h b/ydb/core/tablet_flat/flat_table_committed.h
index 38faf7dce8..b2f73153c2 100644
--- a/ydb/core/tablet_flat/flat_table_committed.h
+++ b/ydb/core/tablet_flat/flat_table_committed.h
@@ -2,7 +2,8 @@
#include "defs.h"
#include <ydb/core/base/row_version.h>
-#include <util/generic/hash.h>
+#include <library/cpp/containers/absl_flat_hash/flat_hash_map.h>
+#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
#include <util/generic/ptr.h>
#include <unordered_map>
@@ -143,7 +144,7 @@ namespace NTable {
*/
class TTransactionMap {
private:
- using TTxMap = std::unordered_map<ui64, TRowVersion>;
+ using TTxMap = absl::flat_hash_map<ui64, TRowVersion>;
struct TState final : public ITransactionMap, public TTxMap {
const TRowVersion* Find(ui64 txId) const override {
@@ -249,7 +250,7 @@ namespace NTable {
*/
class TTransactionSet {
private:
- using TTxSet = std::unordered_set<ui64>;
+ using TTxSet = absl::flat_hash_set<ui64>;
struct TState : public TThrRefBase, TTxSet {
};