diff options
author | Tor Egge <Tor.Egge@online.no> | 2021-04-08 11:10:27 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2021-04-08 11:22:13 +0200 |
commit | 4c63dbea476de60b09183b011d3444970be9c665 (patch) | |
tree | 2c6904a8f9f81fe0e90a39e0a04b12655f7c9721 /vespalib | |
parent | f90dfe4b86e18abbd2ef22ffce55074ca573de1b (diff) |
Sort unique values during load if needed.
Diffstat (limited to 'vespalib')
5 files changed, 11 insertions, 9 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 e61713e40d8..d9b3d25a908 100644 --- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp +++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp @@ -133,7 +133,7 @@ struct TestBase : public ::testing::Test { } size_t entrySize() const { return sizeof(ValueType); } auto getBuilder(uint32_t uniqueValuesHint) { return store.getBuilder(uniqueValuesHint); } - auto getEnumerator() { return store.getEnumerator(); } + auto getEnumerator(bool sort_unique_values) { return store.getEnumerator(sort_unique_values); } size_t get_reserved(EntryRef ref) { return store.bufferState(ref).getTypeHandler()->getReservedElements(getBufferId(ref)); } @@ -404,7 +404,7 @@ TYPED_TEST(TestBase, store_can_be_enumerated) this->remove(this->add(this->values()[2])); this->trimHoldLists(); - auto enumerator = this->getEnumerator(); + auto enumerator = this->getEnumerator(true); std::vector<uint32_t> refs; enumerator.foreach_key([&](EntryRef ref) { refs.push_back(ref.ref()); }); std::vector<uint32_t> expRefs; @@ -445,7 +445,7 @@ 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 enumerator = getEnumerator(); + auto enumerator = getEnumerator(true); enumerator.enumerateValues(); std::vector<uint32_t> enumerated; for (auto &ref : refs) { diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.h b/vespalib/src/vespa/vespalib/datastore/unique_store.h index 565c1ceee61..d0a12ddd290 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.h @@ -76,7 +76,7 @@ public: uint32_t getNumUniques() const; Builder getBuilder(uint32_t uniqueValuesHint); - Enumerator getEnumerator() const; + Enumerator getEnumerator(bool sort_unique_values) 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 c5e4eb0d6fd..a883b2351de 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp @@ -229,9 +229,9 @@ UniqueStore<EntryT, RefT, Compare, Allocator>::getBuilder(uint32_t uniqueValuesH template <typename EntryT, typename RefT, typename Compare, typename Allocator> typename UniqueStore<EntryT, RefT, Compare, Allocator>::Enumerator -UniqueStore<EntryT, RefT, Compare, Allocator>::getEnumerator() const +UniqueStore<EntryT, RefT, Compare, Allocator>::getEnumerator(bool sort_unique_values) const { - return Enumerator(*_dict, _store); + return Enumerator(*_dict, _store, sort_unique_values); } template <typename EntryT, typename RefT, typename Compare, typename Allocator> diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h index be591649310..d7ea449754c 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.h @@ -31,7 +31,7 @@ private: void allocate_enum_values(); public: - UniqueStoreEnumerator(const IUniqueStoreDictionary &dict, const DataStoreBase &store); + UniqueStoreEnumerator(const IUniqueStoreDictionary &dict, const DataStoreBase &store, bool sort_unique_values); ~UniqueStoreEnumerator(); void enumerateValue(EntryRef ref); void enumerateValues(); diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp index 7a43b16e66a..378fc54750d 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_enumerator.hpp @@ -9,14 +9,16 @@ namespace vespalib::datastore { template <typename RefT> -UniqueStoreEnumerator<RefT>::UniqueStoreEnumerator(const IUniqueStoreDictionary &dict, const DataStoreBase &store) +UniqueStoreEnumerator<RefT>::UniqueStoreEnumerator(const IUniqueStoreDictionary &dict, const DataStoreBase &store, bool sort_unique_values) : _dict_snapshot(dict.get_read_snapshot()), _store(store), _enumValues(), _next_enum_val(1) { _dict_snapshot->fill(); - _dict_snapshot->sort(); + if (sort_unique_values) { + _dict_snapshot->sort(); + } allocate_enum_values(); } |