summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-09-10 11:24:38 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-09-10 11:24:38 +0000
commitcad5274df5ad5e2cc5f0d5f179c2d2d86d10cf50 (patch)
treea3c0bbe3e161102f268c301e4fed8b657db309aa /searchlib
parent1dffab88191e9fce8c8711350d8e8de36168b927 (diff)
Remove decRefCount() from enum store API.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/enumstore/enumstore_test.cpp19
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h2
2 files changed, 10 insertions, 11 deletions
diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
index d4431b8a990..c6acf465f83 100644
--- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
+++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
@@ -222,7 +222,6 @@ EnumStoreTest::testUniques
void
EnumStoreTest::testHoldListAndGeneration()
{
- // TODO: Rewrite test to use BatchUpdater
StringEnumStore ses(false);
StringVector uniques;
generation_t sesGen = 0u;
@@ -269,13 +268,14 @@ EnumStoreTest::testHoldListAndGeneration()
}
// remove all uniques
+ auto updater = ses.make_batch_updater();
for (uint32_t i = 0; i < 100; ++i) {
EnumIndex idx;
EXPECT_TRUE(ses.findIndex(uniques[i].c_str(), idx));
- ses.decRefCount(idx);
+ updater.dec_ref_count(idx);
EXPECT_EQUAL(0u, ses.getRefCount(idx));
}
- ses.freeUnusedEnums();
+ updater.commit();
// check readers again
checkReaders(ses, sesGen, readers);
@@ -287,10 +287,12 @@ EnumStoreTest::testHoldListAndGeneration()
namespace {
void
-decRefCount(NumericEnumStore& store, NumericEnumStore::Index idx)
+dec_ref_count(NumericEnumStore& store, NumericEnumStore::Index idx)
{
- store.decRefCount(idx);
- store.freeUnusedEnums();
+ auto updater = store.make_batch_updater();
+ updater.dec_ref_count(idx);
+ updater.commit();
+
generation_t gen = 5;
store.transferHoldLists(gen);
store.trimHoldLists(gen + 1);
@@ -301,7 +303,6 @@ decRefCount(NumericEnumStore& store, NumericEnumStore::Index idx)
void
EnumStoreTest::requireThatAddressSpaceUsageIsReported()
{
- // TODO: Rewrite test to use BatchUpdater
const size_t ADDRESS_LIMIT = 4290772994; // Max allocated elements in un-allocated buffers + allocated elements in allocated buffers.
NumericEnumStore store(false);
@@ -312,9 +313,9 @@ EnumStoreTest::requireThatAddressSpaceUsageIsReported()
EnumIndex idx2 = store.insert(20);
// Address limit increases because buffer is re-sized.
EXPECT_EQUAL(AddressSpace(3, 1, ADDRESS_LIMIT + 2), store.getAddressSpaceUsage());
- decRefCount(store, idx1);
+ dec_ref_count(store, idx1);
EXPECT_EQUAL(AddressSpace(3, 2, ADDRESS_LIMIT + 2), store.getAddressSpaceUsage());
- decRefCount(store, idx2);
+ dec_ref_count(store, idx2);
EXPECT_EQUAL(AddressSpace(3, 3, ADDRESS_LIMIT + 2), store.getAddressSpaceUsage());
}
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h
index 8155f1ba537..e8be6652403 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h
@@ -77,9 +77,7 @@ public:
virtual ~EnumStoreT();
uint32_t getRefCount(Index idx) const { return get_entry_base(idx).get_ref_count(); }
- // TODO: Remove from public API
void incRefCount(Index idx) { return get_entry_base(idx).inc_ref_count(); }
- void decRefCount(Index idx) { return get_entry_base(idx).dec_ref_count(); }
// Only use when reading from enumerated attribute save files
// TODO: Instead create an API that is used for loading/initializing.