diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2019-08-23 16:04:02 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2019-08-23 16:06:06 +0200 |
commit | 94a4d7aabd81639ba132c158cf828a9d289a8272 (patch) | |
tree | f22272eaffb293cc1de0a3fff5678a509fe1bd13 /vespalib | |
parent | b8ae6bfff7c69d454e04b51b4aee4e6c4607cee1 (diff) |
Rename UniqueStoreSaver => UniqueStoreEnumerator.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/tests/datastore/unique_store/unique_store_test.cpp | 22 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/unique_store.h | 8 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/unique_store.hpp | 8 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h (renamed from vespalib/src/vespa/vespalib/datastore/unique_store_saver.h) | 9 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp (renamed from vespalib/src/vespa/vespalib/datastore/unique_store_saver.hpp) | 18 |
5 files changed, 32 insertions, 33 deletions
diff --git a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp index c6db5783eba..bde7e3b9f0a 100644 --- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp +++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp @@ -123,7 +123,7 @@ struct TestBase : public ::testing::Test { } size_t entrySize() const { return sizeof(ValueType); } auto getBuilder(uint32_t uniqueValuesHint) { return store.getBuilder(uniqueValuesHint); } - auto getSaver() { return store.getSaver(); } + auto getEnumerator() { return store.getEnumerator(); } size_t get_reserved(EntryRef ref) { return store.bufferState(ref).getTypeHandler()->getReservedElements(getBufferId(ref)); } @@ -270,24 +270,24 @@ TYPED_TEST(TestBase, store_can_be_instantiated_with_builder) EXPECT_EQ(val1Ref.ref(), this->add(this->values[1]).ref()); } -TYPED_TEST(TestBase, store_can_be_saved) +TYPED_TEST(TestBase, store_can_be_enumerated) { EntryRef val0Ref = this->add(this->values[0]); EntryRef val1Ref = this->add(this->values[1]); this->remove(this->add(this->values[2])); this->trimHoldLists(); - auto saver = this->getSaver(); + auto enumerator = this->getEnumerator(); std::vector<uint32_t> refs; - saver.foreach_key([&](EntryRef ref) { refs.push_back(ref.ref()); }); + enumerator.foreach_key([&](EntryRef ref) { refs.push_back(ref.ref()); }); std::vector<uint32_t> expRefs; expRefs.push_back(val0Ref.ref()); expRefs.push_back(val1Ref.ref()); EXPECT_EQ(expRefs, refs); - saver.enumerateValues(); - uint32_t invalidEnum = saver.mapEntryRefToEnumValue(EntryRef()); - uint32_t enumValue1 = saver.mapEntryRefToEnumValue(val0Ref); - uint32_t enumValue2 = saver.mapEntryRefToEnumValue(val1Ref); + enumerator.enumerateValues(); + uint32_t invalidEnum = enumerator.mapEntryRefToEnumValue(EntryRef()); + uint32_t enumValue1 = enumerator.mapEntryRefToEnumValue(val0Ref); + uint32_t enumValue2 = enumerator.mapEntryRefToEnumValue(val1Ref); EXPECT_EQ(0u, invalidEnum); EXPECT_EQ(1u, enumValue1); EXPECT_EQ(2u, enumValue2); @@ -318,11 +318,11 @@ TEST_F(DoubleTest, nan_is_handled) EXPECT_FALSE(std::signbit(store.get(refs[2]))); EXPECT_TRUE(std::isinf(store.get(refs[3]))); EXPECT_TRUE(std::signbit(store.get(refs[3]))); - auto saver = getSaver(); - saver.enumerateValues(); + auto enumerator = getEnumerator(); + enumerator.enumerateValues(); std::vector<uint32_t> enumerated; for (auto &ref : refs) { - enumerated.push_back(saver.mapEntryRefToEnumValue(ref)); + enumerated.push_back(enumerator.mapEntryRefToEnumValue(ref)); } std::vector<uint32_t> exp_enumerated = { 0, 1, 4, 2, 3, 1, 4, 2 }; EXPECT_EQ(exp_enumerated, enumerated); diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.h b/vespalib/src/vespa/vespalib/datastore/unique_store.h index a045da6ca1f..bbf5f9c90a4 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.h @@ -19,8 +19,8 @@ namespace search::datastore { template <typename Allocator> class UniqueStoreBuilder; -template <typename EntryT, typename RefT> -class UniqueStoreSaver; +template <typename RefT> +class UniqueStoreEnumerator; /** * Datastore for unique values of type EntryT that is accessed via a @@ -33,7 +33,7 @@ public: using DataStoreType = DataStoreT<RefT>; using EntryType = EntryT; using RefType = RefT; - using Saver = UniqueStoreSaver<EntryT, RefT>; + using Enumerator = UniqueStoreEnumerator<RefT>; using Builder = UniqueStoreBuilder<Allocator>; using EntryConstRefType = typename Allocator::EntryConstRefType; private: @@ -61,7 +61,7 @@ public: uint32_t getNumUniques() const; Builder getBuilder(uint32_t uniqueValuesHint); - Saver getSaver() const; + Enumerator getEnumerator() const; // Should only be used for unit testing const BufferState &bufferState(EntryRef ref) const; diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp index ae7f82a6e52..1ebdd65d87a 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp @@ -8,7 +8,7 @@ #include "unique_store_allocator.hpp" #include "unique_store_builder.hpp" #include "unique_store_dictionary.hpp" -#include "unique_store_saver.hpp" +#include "unique_store_enumerator.hpp" #include <vespa/vespalib/util/bufferwriter.h> #include <atomic> #include <algorithm> @@ -217,10 +217,10 @@ UniqueStore<EntryT, RefT, Compare, Allocator>::getBuilder(uint32_t uniqueValuesH } template <typename EntryT, typename RefT, typename Compare, typename Allocator> -typename UniqueStore<EntryT, RefT, Compare, Allocator>::Saver -UniqueStore<EntryT, RefT, Compare, Allocator>::getSaver() const +typename UniqueStore<EntryT, RefT, Compare, Allocator>::Enumerator +UniqueStore<EntryT, RefT, Compare, Allocator>::getEnumerator() const { - return Saver(*_dict, _store); + return Enumerator(*_dict, _store); } template <typename EntryT, typename RefT, typename Compare, typename Allocator> diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_saver.h b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h index 2486441911d..9de36125fa5 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_saver.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h @@ -12,9 +12,8 @@ namespace search::datastore { * Contains utility methods for traversing all unique values (as * EntryRef value) and mapping from EntryRef value to enum value. */ -template <typename EntryT, typename RefT> -class UniqueStoreSaver { - using EntryType = EntryT; +template <typename RefT> +class UniqueStoreEnumerator { using RefType = RefT; const UniqueStoreDictionaryBase &_dict; @@ -23,8 +22,8 @@ class UniqueStoreSaver { std::vector<std::vector<uint32_t>> _enumValues; uint32_t _next_enum_val; public: - UniqueStoreSaver(const UniqueStoreDictionaryBase &dict, const DataStoreBase &store); - ~UniqueStoreSaver(); + UniqueStoreEnumerator(const UniqueStoreDictionaryBase &dict, const DataStoreBase &store); + ~UniqueStoreEnumerator(); void enumerateValue(EntryRef ref); void enumerateValues(); diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_saver.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp index f6f258f57da..b364c2a2ba3 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_saver.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp @@ -2,12 +2,12 @@ #pragma once -#include "unique_store_saver.h" +#include "unique_store_enumerator.h" namespace search::datastore { -template <typename EntryT, typename RefT> -UniqueStoreSaver<EntryT, RefT>::UniqueStoreSaver(const UniqueStoreDictionaryBase &dict, const DataStoreBase &store) +template <typename RefT> +UniqueStoreEnumerator<RefT>::UniqueStoreEnumerator(const UniqueStoreDictionaryBase &dict, const DataStoreBase &store) : _dict(dict), _root(_dict.get_frozen_root()), _store(store), @@ -15,14 +15,14 @@ UniqueStoreSaver<EntryT, RefT>::UniqueStoreSaver(const UniqueStoreDictionaryBase { } -template <typename EntryT, typename RefT> -UniqueStoreSaver<EntryT, RefT>::~UniqueStoreSaver() +template <typename RefT> +UniqueStoreEnumerator<RefT>::~UniqueStoreEnumerator() { } -template <typename EntryT, typename RefT> +template <typename RefT> void -UniqueStoreSaver<EntryT, RefT>::enumerateValue(EntryRef ref) +UniqueStoreEnumerator<RefT>::enumerateValue(EntryRef ref) { RefType iRef(ref); assert(iRef.valid()); @@ -33,9 +33,9 @@ UniqueStoreSaver<EntryT, RefT>::enumerateValue(EntryRef ref) ++_next_enum_val; } -template <typename EntryT, typename RefT> +template <typename RefT> void -UniqueStoreSaver<EntryT, RefT>::enumerateValues() +UniqueStoreEnumerator<RefT>::enumerateValues() { _enumValues.resize(RefType::numBuffers()); for (uint32_t bufferId = 0; bufferId < RefType::numBuffers(); ++bufferId) { |