summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-12-02 17:26:52 +0100
committerTor Egge <Tor.Egge@online.no>2021-12-02 17:26:52 +0100
commita40ad05bfe98dd80cdae6192b027c38e8eaa21a1 (patch)
tree74bab561b3fe0b1af82ecd1bff2498209b2a7afc /vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
parent6b5c9652df7bc095bede29f2ba415abfdbdbcd05 (diff)
Don't try to move dictionary keys that won't move.
Diffstat (limited to 'vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp')
-rw-r--r--vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
index 3cd3d00645c..6e984f286c1 100644
--- a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
+++ b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/datastore/sharded_hash_map.h>
+#include <vespa/vespalib/datastore/i_compactable.h>
#include <vespa/vespalib/datastore/unique_store_allocator.h>
#include <vespa/vespalib/datastore/unique_store_comparator.h>
@@ -17,6 +18,7 @@
LOG_SETUP("vespalib_datastore_shared_hash_test");
using vespalib::datastore::EntryRef;
+using vespalib::datastore::ICompactable;
using RefT = vespalib::datastore::EntryRefT<22>;
using MyAllocator = vespalib::datastore::UniqueStoreAllocator<uint32_t, RefT>;
using MyDataStore = vespalib::datastore::DataStoreT<RefT>;
@@ -35,6 +37,27 @@ void consider_yield(uint32_t i)
}
}
+class MyCompactable : public ICompactable
+{
+ MyAllocator& _allocator;
+ std::vector<EntryRef>& _new_refs;
+public:
+ MyCompactable(MyAllocator& allocator, std::vector<EntryRef>& new_refs)
+ : ICompactable(),
+ _allocator(allocator),
+ _new_refs(new_refs)
+ {
+ }
+ ~MyCompactable() override = default;
+
+ EntryRef move(EntryRef ref) override {
+ auto new_ref = _allocator.move(ref);
+ _allocator.hold(ref);
+ _new_refs.emplace_back(new_ref);
+ return new_ref;
+ }
+};
+
}
struct DataStoreShardedHashTest : public ::testing::Test
@@ -257,7 +280,8 @@ TEST_F(DataStoreShardedHashTest, move_keys_works)
std::vector<EntryRef> refs;
_hash_map.foreach_key([&refs](EntryRef ref) { refs.emplace_back(ref); });
std::vector<EntryRef> new_refs;
- _hash_map.move_keys([this, &new_refs](EntryRef ref) { auto new_ref = _allocator.move(ref); _allocator.hold(ref); new_refs.emplace_back(new_ref); return new_ref; });
+ MyCompactable my_compactable(_allocator, new_refs);
+ _hash_map.move_keys(my_compactable, std::vector<bool>(RefT::numBuffers(), true), RefT::offset_bits);
std::vector<EntryRef> verify_new_refs;
_hash_map.foreach_key([&verify_new_refs](EntryRef ref) { verify_new_refs.emplace_back(ref); });
EXPECT_EQ(50u, refs.size());