From 35f99197a7dde6516c56fb4030d838046358eed1 Mon Sep 17 00:00:00 2001 From: Geir Storli Date: Wed, 28 Aug 2019 13:28:23 +0000 Subject: Collapse EnumStoreBase into EnumStoreT in preparation for replacing underlying data store with unique store. --- .../src/vespa/searchlib/attribute/CMakeLists.txt | 1 - .../searchlib/attribute/address_space_usage.cpp | 4 +- .../searchlib/attribute/enum_store_dictionary.cpp | 1 - .../searchlib/attribute/enumattributesaver.cpp | 1 + .../vespa/searchlib/attribute/enumattributesaver.h | 2 +- .../searchlib/attribute/enumhintsearchcontext.cpp | 6 +- .../searchlib/attribute/enumhintsearchcontext.h | 17 +- .../src/vespa/searchlib/attribute/enumstore.cpp | 16 ++ .../src/vespa/searchlib/attribute/enumstore.h | 162 +++++++++++++-- .../src/vespa/searchlib/attribute/enumstore.hpp | 206 ++++++++++++++++++- .../vespa/searchlib/attribute/enumstorebase.cpp | 225 --------------------- .../src/vespa/searchlib/attribute/enumstorebase.h | 186 ----------------- .../src/vespa/searchlib/attribute/load_utils.cpp | 4 +- .../vespa/searchlib/attribute/loadedenumvalue.h | 3 +- .../src/vespa/searchlib/attribute/loadedvalue.h | 2 +- .../searchlib/attribute/multi_value_mapping.cpp | 4 +- .../vespa/searchlib/attribute/multienumattribute.h | 4 +- .../attribute/multistringpostattribute.cpp | 2 +- .../attribute/multistringpostattribute.hpp | 2 +- .../src/vespa/searchlib/attribute/numericbase.h | 2 +- .../vespa/searchlib/attribute/postingchange.cpp | 14 +- .../src/vespa/searchlib/attribute/postingchange.h | 8 +- .../searchlib/attribute/postinglistattribute.cpp | 4 +- .../searchlib/attribute/postinglistattribute.h | 4 +- .../attribute/postinglistsearchcontext.cpp | 6 +- .../searchlib/attribute/postinglistsearchcontext.h | 4 +- .../src/vespa/searchlib/attribute/postingstore.h | 2 +- .../attribute/singlenumericpostattribute.h | 2 +- .../attribute/singlenumericpostattribute.hpp | 2 +- .../attribute/singlestringpostattribute.h | 2 +- .../attribute/singlestringpostattribute.hpp | 2 +- .../src/vespa/searchlib/attribute/stringbase.h | 10 +- .../searchlib/queryeval/sourceblendersearch.cpp | 1 + 33 files changed, 418 insertions(+), 493 deletions(-) delete mode 100644 searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp delete mode 100644 searchlib/src/vespa/searchlib/attribute/enumstorebase.h (limited to 'searchlib') diff --git a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt index c190f8af023..286d10ef1c7 100644 --- a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt @@ -41,7 +41,6 @@ vespa_add_library(searchlib_attribute OBJECT enumhintsearchcontext.cpp enum_store_dictionary.cpp enumstore.cpp - enumstorebase.cpp extendableattributes.cpp fixedsourceselector.cpp flagattribute.cpp diff --git a/searchlib/src/vespa/searchlib/attribute/address_space_usage.cpp b/searchlib/src/vespa/searchlib/attribute/address_space_usage.cpp index 4ad06fae54c..e03eec2764a 100644 --- a/searchlib/src/vespa/searchlib/attribute/address_space_usage.cpp +++ b/searchlib/src/vespa/searchlib/attribute/address_space_usage.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "address_space_usage.h" -#include "enumstorebase.h" +#include "i_enum_store.h" namespace search { @@ -21,7 +21,7 @@ AddressSpaceUsage::AddressSpaceUsage(const AddressSpace &enumStoreUsage_, AddressSpace AddressSpaceUsage::defaultEnumStoreUsage() { - return AddressSpace(0, 0, EnumStoreBase::DataStoreType::RefType::offsetSize()); + return AddressSpace(0, 0, IEnumStore::Index::offsetSize()); } AddressSpace diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp index 689aa102d3a..24c0eeabd2c 100644 --- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp @@ -2,7 +2,6 @@ #include "enum_store_dictionary.h" #include "enumstore.h" -#include "enumstorebase.h" #include #include #include diff --git a/searchlib/src/vespa/searchlib/attribute/enumattributesaver.cpp b/searchlib/src/vespa/searchlib/attribute/enumattributesaver.cpp index 1c42eaa5835..db235f91798 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumattributesaver.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumattributesaver.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "enumattributesaver.h" +#include "i_enum_store_dictionary.h" #include "iattributesavetarget.h" #include #include diff --git a/searchlib/src/vespa/searchlib/attribute/enumattributesaver.h b/searchlib/src/vespa/searchlib/attribute/enumattributesaver.h index 8d0e69afddc..c399a0a88b1 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumattributesaver.h +++ b/searchlib/src/vespa/searchlib/attribute/enumattributesaver.h @@ -2,7 +2,7 @@ #pragma once -#include "enumstorebase.h" +#include "i_enum_store.h" #include namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp index f221ac858bd..28a270555d3 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp @@ -25,15 +25,15 @@ EnumHintSearchContext::~EnumHintSearchContext() = default; void -EnumHintSearchContext::lookupTerm(const EnumStoreComparator &comp) +EnumHintSearchContext::lookupTerm(const datastore::EntryComparator &comp) { _uniqueValues = _dict_snapshot->count(comp); } void -EnumHintSearchContext::lookupRange(const EnumStoreComparator &low, - const EnumStoreComparator &high) +EnumHintSearchContext::lookupRange(const datastore::EntryComparator &low, + const datastore::EntryComparator &high) { _uniqueValues = _dict_snapshot->count_in_range(low, high); } diff --git a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h index 6f766bec386..5a20318ae7b 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.h @@ -2,11 +2,15 @@ #pragma once -#include "enumstore.h" +#include "i_enum_store_dictionary.h" #include "ipostinglistsearchcontext.h" #include -namespace search::attribute { +namespace search { + +namespace datastore { class EntryComparator; } + +namespace attribute { /** * Search context helper for enumerated attributes, used to eliminate @@ -19,16 +23,16 @@ class EnumHintSearchContext : public IPostingListSearchContext uint32_t _uniqueValues; uint32_t _docIdLimit; uint64_t _numValues; // attr.getStatus().getNumValues(); - + protected: EnumHintSearchContext(const IEnumStoreDictionary &dictionary, uint32_t docIdLimit, uint64_t numValues); ~EnumHintSearchContext(); - void lookupTerm(const EnumStoreComparator &comp); - void lookupRange(const EnumStoreComparator &low, const EnumStoreComparator &high); - + void lookupTerm(const datastore::EntryComparator &comp); + void lookupRange(const datastore::EntryComparator &low, const datastore::EntryComparator &high); + queryeval::SearchIterator::UP createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) override; @@ -37,3 +41,4 @@ protected: }; } +} diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp index c45486f9513..4cf5ea9c766 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "enumstore.hpp" +#include +#include #include #include @@ -82,6 +84,12 @@ EnumStoreT::deserialize(const void *src, return sz; } +vespalib::asciistream & operator << (vespalib::asciistream & os, const IEnumStore::Index & idx) { + return os << "offset(" << idx.offset() << "), bufferId(" << idx.bufferId() << "), idx(" << idx.ref() << ")"; +} + +template class datastore::DataStoreT; + template class btree::BTreeBuilder; @@ -99,3 +107,11 @@ template class EnumStoreT >; template class EnumStoreT >; } // namespace search + +namespace vespalib { + template class RcuVectorBase; +} + +VESPALIB_HASH_MAP_INSTANTIATE_H_E_M(search::IEnumStore::Index, search::IEnumStore::Index, + vespalib::hash, std::equal_to, + vespalib::hashtable_base::and_modulator); diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h index be2a8eafd9e..fa5e9611c55 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.h +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h @@ -3,7 +3,7 @@ #pragma once #include "enum_store_dictionary.h" -#include "enumstorebase.h" +#include "i_enum_store.h" #include #include #include @@ -74,7 +74,7 @@ struct FloatingPointCompareHelper // EnumStoreT //----------------------------------------------------------------------------- template -class EnumStoreT : public EnumStoreBase +class EnumStoreT : public IEnumStore { friend class EnumStoreTest; public: @@ -82,9 +82,31 @@ public: using ComparatorType = EnumStoreComparatorT; using FoldedComparatorType = EnumStoreFoldedComparatorT; using EnumStoreType = EnumStoreT; - using EnumStoreBase::deserialize; - using EnumStoreBase::fixupRefCounts; - using EnumStoreBase::reset; + using DataStoreType = datastore::DataStoreT; + using generation_t = vespalib::GenerationHandler::generation_t; + + class EntryBase { + protected: + char * _data; + public: + EntryBase(void * data) : _data(static_cast(data)) {} + uint32_t getRefCount() const { + return *(reinterpret_cast(_data) + 1); + } + void incRefCount() { + uint32_t *dst = reinterpret_cast(_data) + 1; + ++(*dst); + } + void decRefCount() { + uint32_t *dst = reinterpret_cast(_data) + 1; + --(*dst); + } + void setRefCount(uint32_t refCount) { + uint32_t *dst = reinterpret_cast(_data) + 1; + *dst = refCount; + } + static uint32_t size() { return 2*sizeof(uint32_t); } + }; class Entry : public EntryBase { public: @@ -92,9 +114,40 @@ public: Type getValue() const; static uint32_t fixedSize() { return EntryBase::size() + EntryType::fixedSize(); } }; + + class EnumBufferType : public datastore::BufferType { + private: + size_t _minSizeNeeded; // lower cap for sizeNeeded + size_t _deadElems; // dead elements in active buffer + bool _pendingCompact; + bool _wantCompact; + public: + EnumBufferType(); + size_t calcArraysToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const override; + void setSizeNeededAndDead(size_t sizeNeeded, size_t deadElems) { + _minSizeNeeded = sizeNeeded; + _deadElems = deadElems; + } + void onFree(size_t usedElems) override { + datastore::BufferType::onFree(usedElems); + _pendingCompact = _wantCompact; + _wantCompact = false; + } + void setWantCompact() { _wantCompact = true; } + bool getPendingCompact() const { return _pendingCompact; } + void clearPendingCompact() { _pendingCompact = false; } + }; + static void insertEntry(char * dst, uint32_t refCount, Type value); private: + IEnumStoreDictionary *_enumDict; + DataStoreType _store; + EnumBufferType _type; + std::vector _toHoldBuffers; // used during compaction + + static const uint32_t TYPE_ID = 0; + EnumStoreT(const EnumStoreT & rhs) = delete; EnumStoreT & operator=(const EnumStoreT & rhs) = delete; @@ -102,10 +155,21 @@ private: memcpy(dst, &value, sizeof(Type)); } -protected: - typedef IEnumStore::IndexSet IndexSet; - using EnumStoreBase::_store; - using EnumStoreBase::TYPE_ID; + EntryBase getEntryBase(Index idx) const { + return EntryBase(const_cast(_store).getEntry(idx)); + } + datastore::BufferState & getBuffer(uint32_t bufferIdx) { + return _store.getBufferState(bufferIdx); + } + const datastore::BufferState & getBuffer(uint32_t bufferIdx) const { + return _store.getBufferState(bufferIdx); + } + bool validIndex(Index idx) const { + return (idx.valid() && idx.offset() < _store.getBufferState(idx.bufferId()).size()); + } + uint32_t getBufferIndex(datastore::BufferState::State status); + void postCompact(); + bool preCompact(uint64_t bytesNeeded); Entry getEntry(Index idx) const { return Entry(const_cast(_store).getEntry(idx)); @@ -114,18 +178,70 @@ protected: void freeUnusedEnum(Index idx, IndexSet & unused) override; public: - EnumStoreT(uint64_t initBufferSize, bool hasPostings) - : EnumStoreBase(initBufferSize, hasPostings) - { + EnumStoreT(uint64_t initBufferSize, bool hasPostings); + virtual ~EnumStoreT(); + + void reset(uint64_t initBufferSize); + + uint32_t getRefCount(Index idx) const { return getEntryBase(idx).getRefCount(); } + void incRefCount(Index idx) { getEntryBase(idx).incRefCount(); } + void decRefCount(Index idx) { getEntryBase(idx).decRefCount(); } + + // Only use when reading from enumerated attribute save files + void fixupRefCount(Index idx, uint32_t refCount) override { + getEntryBase(idx).setRefCount(refCount); + } + + uint32_t getNumUniques() const override { return _enumDict->getNumUniques(); } + + uint32_t getRemaining() const { + return _store.getBufferState(_store.getActiveBufferId(TYPE_ID)).remaining(); + } + uint32_t getCapacity() const { + return _store.getBufferState(_store.getActiveBufferId(TYPE_ID)).capacity(); + } + vespalib::MemoryUsage getMemoryUsage() const override { return _store.getMemoryUsage(); } + vespalib::MemoryUsage getTreeMemoryUsage() const override { return _enumDict->get_memory_usage(); } + + vespalib::AddressSpace getAddressSpaceUsage() const; + + void transferHoldLists(generation_t generation); + void trimHoldLists(generation_t firstUsed); + + static void failNewSize(uint64_t minNewSize, uint64_t maxSize); + + // Align buffers and entries to 4 bytes boundary. + static uint64_t alignBufferSize(uint64_t val) { return Index::align(val); } + static uint32_t alignEntrySize(uint32_t val) { return Index::align(val); } + + void fallbackResize(uint64_t bytesNeeded); + bool getPendingCompact() const { return _type.getPendingCompact(); } + void clearPendingCompact() { _type.clearPendingCompact(); } + + ssize_t deserialize0(const void *src, size_t available, IndexVector &idx) override; + + ssize_t deserialize(const void *src, size_t available, IndexVector &idx) { + return _enumDict->deserialize(src, available, idx); + } + + void fixupRefCounts(const EnumVector &hist) { _enumDict->fixupRefCounts(hist); } + void freezeTree() { _enumDict->freeze(); } + + IEnumStoreDictionary &getEnumStoreDict() override { return *_enumDict; } + const IEnumStoreDictionary &getEnumStoreDict() const override { return *_enumDict; } + EnumPostingTree &getPostingDictionary() { return _enumDict->getPostingDictionary(); } + + const EnumPostingTree &getPostingDictionary() const { + return _enumDict->getPostingDictionary(); } + const datastore::DataStoreBase &get_data_store_base() const override { return _store; } + bool getValue(Index idx, Type & value) const; Type getValue(uint32_t idx) const { return getValue(Index(datastore::EntryRef(idx))); } Type getValue(Index idx) const { return getEntry(idx).getValue(); } - static uint32_t - getEntrySize(Type value) - { + static uint32_t getEntrySize(Type value) { return alignEntrySize(EntryBase::size() + EntryType::size(value)); } @@ -192,17 +308,17 @@ public: } void writeValues(BufferWriter &writer, const Index *idxs, size_t count) const override; - ssize_t deserialize(const void *src, size_t available, size_t &initSpace) override; - ssize_t deserialize(const void *src, size_t available, Index &idx) override; + ssize_t deserialize(const void *src, size_t available, size_t &initSpace); + ssize_t deserialize(const void *src, size_t available, Index &idx); bool foldedChange(const Index &idx1, const Index &idx2) override; virtual bool findEnum(Type value, IEnumStore::EnumHandle &e) const; virtual std::vector findFoldedEnums(Type value) const; void addEnum(Type value, Index &newIdx); virtual bool findIndex(Type value, Index &idx) const; void freeUnusedEnums(bool movePostingidx) override; - void freeUnusedEnums(const IndexSet& toRemove) override; + void freeUnusedEnums(const IndexSet& toRemove); void reset(Builder &builder); - bool performCompaction(uint64_t bytesNeeded, EnumIndexMap & old2New) override; + bool performCompaction(uint64_t bytesNeeded, EnumIndexMap & old2New); private: template @@ -215,12 +331,18 @@ private: void performCompaction(Dictionary &dict, EnumIndexMap & old2New); }; +vespalib::asciistream & operator << (vespalib::asciistream & os, const IEnumStore::Index & idx); + +extern template +class datastore::DataStoreT; + + template inline typename EntryType::Type EnumStoreT::Entry::getValue() const // implementation for numeric { Type dst; - const char * src = _data + EntryBase::size(); + const char * src = this->_data + EntryBase::size(); memcpy(&dst, src, sizeof(Type)); return dst; } diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp index 297a5e3f807..428875e00db 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp @@ -5,6 +5,7 @@ #include "enumstore.h" #include "enumcomparator.h" +#include #include #include #include @@ -25,15 +26,49 @@ const uint32_t dummy_enum_value = 0; } template -void EnumStoreT::freeUnusedEnum(Index idx, IndexSet & unused) +EnumStoreT::EnumBufferType::EnumBufferType() + : datastore::BufferType(Index::align(1), + Index::offsetSize() / Index::align(1), + Index::offsetSize() / Index::align(1)), + _minSizeNeeded(0), + _deadElems(0), + _pendingCompact(false), + _wantCompact(false) { - Entry e = getEntry(idx); - if (e.getRefCount() == 0) { - Type value = e.getValue(); - if (unused.insert(idx).second) { - _store.incDead(idx, getEntrySize(value)); - } +} + +template +size_t +EnumStoreT::EnumBufferType::calcArraysToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const +{ + (void) resizing; + size_t reservedElements = getReservedElements(bufferId); + sizeNeeded = std::max(sizeNeeded, _minSizeNeeded); + size_t usedElems = _activeUsedElems; + if (_lastUsedElems != nullptr) { + usedElems += *_lastUsedElems; + } + assert((usedElems % _arraySize) == 0); + double growRatio = 1.5f; + uint64_t maxSize = static_cast(_maxArrays) * _arraySize; + uint64_t newSize = usedElems - _deadElems + sizeNeeded; + if (usedElems != 0) { + newSize *= growRatio; } + newSize += reservedElements; + newSize = alignBufferSize(newSize); + assert((newSize % _arraySize) == 0); + if (newSize <= maxSize) { + return newSize / _arraySize; + } + newSize = usedElems - _deadElems + sizeNeeded + reservedElements + 1000000; + newSize = alignBufferSize(newSize); + assert((newSize % _arraySize) == 0); + if (newSize <= maxSize) { + return _maxArrays; + } + failNewSize(newSize, maxSize); + return 0; } template @@ -53,6 +88,161 @@ void EnumStoreT:: insertEntryValue(char * dst, Type value); +template +uint32_t +EnumStoreT::getBufferIndex(datastore::BufferState::State status) +{ + for (uint32_t i = 0; i < _store.getNumBuffers(); ++i) { + if (_store.getBufferState(i).getState() == status) { + return i; + } + } + return Index::numBuffers(); +} + +template +void +EnumStoreT::postCompact() +{ + _store.finishCompact(_toHoldBuffers); +} + +template +bool +EnumStoreT::preCompact(uint64_t bytesNeeded) +{ + if (getBufferIndex(datastore::BufferState::FREE) == Index::numBuffers()) { + return false; + } + uint32_t activeBufId = _store.getActiveBufferId(TYPE_ID); + datastore::BufferState & activeBuf = _store.getBufferState(activeBufId); + _type.setSizeNeededAndDead(bytesNeeded, activeBuf.getDeadElems()); + _toHoldBuffers = _store.startCompact(TYPE_ID); + return true; +} + +template +void EnumStoreT::freeUnusedEnum(Index idx, IndexSet & unused) +{ + Entry e = getEntry(idx); + if (e.getRefCount() == 0) { + Type value = e.getValue(); + if (unused.insert(idx).second) { + _store.incDead(idx, getEntrySize(value)); + } + } +} + +template +EnumStoreT::EnumStoreT(uint64_t initBufferSize, bool hasPostings) + : _enumDict(nullptr), + _store(), + _type(), + _toHoldBuffers() +{ + if (hasPostings) { + _enumDict = new EnumStoreDictionary(*this); + } else { + _enumDict = new EnumStoreDictionary(*this); + } + _store.addType(&_type); + _type.setSizeNeededAndDead(initBufferSize, 0); + _store.initActiveBuffers(); +} + +template +EnumStoreT::~EnumStoreT() +{ + _store.clearHoldLists(); + _store.dropBuffers(); + delete _enumDict; +} + +template +void +EnumStoreT::reset(uint64_t initBufferSize) +{ + _store.clearHoldLists(); + _store.dropBuffers(); + _type.setSizeNeededAndDead(initBufferSize, 0); + _store.initActiveBuffers(); + _enumDict->onReset(); +} + +template +vespalib::AddressSpace +EnumStoreT::getAddressSpaceUsage() const +{ + const datastore::BufferState &activeState = _store.getBufferState(_store.getActiveBufferId(TYPE_ID)); + return vespalib::AddressSpace(activeState.size(), activeState.getDeadElems(), DataStoreType::RefType::offsetSize()); +} + +template +void +EnumStoreT::transferHoldLists(generation_t generation) +{ + _enumDict->transfer_hold_lists(generation); + _store.transferHoldLists(generation); +} + +template +void +EnumStoreT::trimHoldLists(generation_t firstUsed) +{ + // remove generations in the range [0, firstUsed> + _enumDict->trim_hold_lists(firstUsed); + _store.trimHoldLists(firstUsed); +} + +template +void +EnumStoreT::failNewSize(uint64_t minNewSize, uint64_t maxSize) +{ + throw vespalib::IllegalStateException(vespalib::make_string("EnumStoreT::failNewSize: Minimum new size (%" PRIu64 ") exceeds max size (%" PRIu64 ")", minNewSize, maxSize)); +} + +template +void +EnumStoreT::fallbackResize(uint64_t bytesNeeded) +{ + uint32_t activeBufId = _store.getActiveBufferId(TYPE_ID); + size_t reservedElements = _type.getReservedElements(activeBufId); + _type.setSizeNeededAndDead(bytesNeeded, reservedElements); + _type.setWantCompact(); + _store.fallbackResize(activeBufId, bytesNeeded); +} + +template +ssize_t +EnumStoreT::deserialize0(const void *src, + size_t available, + IndexVector &idx) +{ + size_t left = available; + size_t initSpace = Index::align(1); + const char * p = static_cast(src); + while (left > 0) { + ssize_t sz = deserialize(p, left, initSpace); + if (sz < 0) + return sz; + p += sz; + left -= sz; + } + reset(initSpace); + left = available; + p = static_cast(src); + Index idx1; + while (left > 0) { + ssize_t sz = deserialize(p, left, idx1); + if (sz < 0) + return sz; + p += sz; + left -= sz; + idx.push_back(idx1); + } + return available - left; +} + template bool EnumStoreT::getValue(Index idx, Type & value) const @@ -308,7 +498,7 @@ void EnumStoreT::reset(Builder &builder, Dictionary &dict) { typedef typename Dictionary::Builder DictionaryBuilder; - EnumStoreBase::reset(builder.getBufferSize()); + reset(builder.getBufferSize()); DictionaryBuilder treeBuilder(dict.getAllocator()); uint32_t activeBufferId = _store.getActiveBufferId(TYPE_ID); diff --git a/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp b/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp deleted file mode 100644 index 7aba3547339..00000000000 --- a/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "enumstorebase.h" -#include "enumstore.h" -#include "enum_store_dictionary.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -LOG_SETUP(".searchlib.attribute.enumstorebase"); - -namespace search { - -using btree::BTreeNode; - -EnumStoreBase::EnumBufferType::EnumBufferType() - : datastore::BufferType(Index::align(1), - Index::offsetSize() / Index::align(1), - Index::offsetSize() / Index::align(1)), - _minSizeNeeded(0), - _deadElems(0), - _pendingCompact(false), - _wantCompact(false) -{ -} - -size_t -EnumStoreBase::EnumBufferType::calcArraysToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const -{ - (void) resizing; - size_t reservedElements = getReservedElements(bufferId); - sizeNeeded = std::max(sizeNeeded, _minSizeNeeded); - size_t usedElems = _activeUsedElems; - if (_lastUsedElems != nullptr) { - usedElems += *_lastUsedElems; - } - assert((usedElems % _arraySize) == 0); - double growRatio = 1.5f; - uint64_t maxSize = static_cast(_maxArrays) * _arraySize; - uint64_t newSize = usedElems - _deadElems + sizeNeeded; - if (usedElems != 0) { - newSize *= growRatio; - } - newSize += reservedElements; - newSize = alignBufferSize(newSize); - assert((newSize % _arraySize) == 0); - if (newSize <= maxSize) { - return newSize / _arraySize; - } - newSize = usedElems - _deadElems + sizeNeeded + reservedElements + 1000000; - newSize = alignBufferSize(newSize); - assert((newSize % _arraySize) == 0); - if (newSize <= maxSize) { - return _maxArrays; - } - failNewSize(newSize, maxSize); - return 0; -} - -EnumStoreBase::EnumStoreBase(uint64_t initBufferSize, bool hasPostings) - : _enumDict(nullptr), - _store(), - _type(), - _toHoldBuffers() -{ - if (hasPostings) - _enumDict = new EnumStoreDictionary(*this); - else - _enumDict = new EnumStoreDictionary(*this); - _store.addType(&_type); - _type.setSizeNeededAndDead(initBufferSize, 0); - _store.initActiveBuffers(); -} - -EnumStoreBase::~EnumStoreBase() -{ - _store.clearHoldLists(); - _store.dropBuffers(); - delete _enumDict; -} - -void -EnumStoreBase::reset(uint64_t initBufferSize) -{ - _store.clearHoldLists(); - _store.dropBuffers(); - _type.setSizeNeededAndDead(initBufferSize, 0); - _store.initActiveBuffers(); - _enumDict->onReset(); -} - -uint32_t -EnumStoreBase::getBufferIndex(datastore::BufferState::State status) -{ - for (uint32_t i = 0; i < _store.getNumBuffers(); ++i) { - if (_store.getBufferState(i).getState() == status) { - return i; - } - } - return Index::numBuffers(); -} - -vespalib::MemoryUsage -EnumStoreBase::getMemoryUsage() const -{ - return _store.getMemoryUsage(); -} - -vespalib::AddressSpace -EnumStoreBase::getAddressSpaceUsage() const -{ - const datastore::BufferState &activeState = _store.getBufferState(_store.getActiveBufferId(TYPE_ID)); - return vespalib::AddressSpace(activeState.size(), activeState.getDeadElems(), DataStoreType::RefType::offsetSize()); -} - -void -EnumStoreBase::transferHoldLists(generation_t generation) -{ - _enumDict->transfer_hold_lists(generation); - _store.transferHoldLists(generation); -} - -void -EnumStoreBase::trimHoldLists(generation_t firstUsed) -{ - // remove generations in the range [0, firstUsed> - _enumDict->trim_hold_lists(firstUsed); - _store.trimHoldLists(firstUsed); -} - -bool -EnumStoreBase::preCompact(uint64_t bytesNeeded) -{ - if (getBufferIndex(datastore::BufferState::FREE) == Index::numBuffers()) { - return false; - } - uint32_t activeBufId = _store.getActiveBufferId(TYPE_ID); - datastore::BufferState & activeBuf = _store.getBufferState(activeBufId); - _type.setSizeNeededAndDead(bytesNeeded, activeBuf.getDeadElems()); - _toHoldBuffers = _store.startCompact(TYPE_ID); - return true; -} - - -void -EnumStoreBase::fallbackResize(uint64_t bytesNeeded) -{ - uint32_t activeBufId = _store.getActiveBufferId(TYPE_ID); - size_t reservedElements = _type.getReservedElements(activeBufId); - _type.setSizeNeededAndDead(bytesNeeded, reservedElements); - _type.setWantCompact(); - _store.fallbackResize(activeBufId, bytesNeeded); -} - - -void -EnumStoreBase::postCompact() -{ - _store.finishCompact(_toHoldBuffers); -} - -void -EnumStoreBase::failNewSize(uint64_t minNewSize, uint64_t maxSize) -{ - throw vespalib::IllegalStateException(vespalib::make_string("EnumStoreBase::failNewSize: Minimum new size (%" PRIu64 ") exceeds max size (%" PRIu64 ")", minNewSize, maxSize)); -} - -ssize_t -EnumStoreBase::deserialize0(const void *src, - size_t available, - IndexVector &idx) -{ - size_t left = available; - size_t initSpace = Index::align(1); - const char * p = static_cast(src); - while (left > 0) { - ssize_t sz = deserialize(p, left, initSpace); - if (sz < 0) - return sz; - p += sz; - left -= sz; - } - reset(initSpace); - left = available; - p = static_cast(src); - Index idx1; - while (left > 0) { - ssize_t sz = deserialize(p, left, idx1); - if (sz < 0) - return sz; - p += sz; - left -= sz; - idx.push_back(idx1); - } - return available - left; -} - - -vespalib::asciistream & operator << (vespalib::asciistream & os, const IEnumStore::Index & idx) { - return os << "offset(" << idx.offset() << "), bufferId(" << idx.bufferId() << "), idx(" << idx.ref() << ")"; -} - - -template class datastore::DataStoreT; - -} - -namespace vespalib { -template class RcuVectorBase; -} - -VESPALIB_HASH_MAP_INSTANTIATE_H_E_M(search::IEnumStore::Index, search::IEnumStore::Index, - vespalib::hash, std::equal_to, - vespalib::hashtable_base::and_modulator); diff --git a/searchlib/src/vespa/searchlib/attribute/enumstorebase.h b/searchlib/src/vespa/searchlib/attribute/enumstorebase.h deleted file mode 100644 index cec6c5e5ac8..00000000000 --- a/searchlib/src/vespa/searchlib/attribute/enumstorebase.h +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include "enum_store_dictionary.h" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace vespalib { class asciistream; } -namespace search { - -class BufferWriter; - -namespace attribute { class Status; } - -using EnumStoreComparator = datastore::EntryComparator; - - -class EnumStoreBase : public IEnumStore { -public: - using DataStoreType = datastore::DataStoreT; - using generation_t = vespalib::GenerationHandler::generation_t; - - - class EntryBase { - protected: - char * _data; - public: - EntryBase(void * data) : _data(static_cast(data)) {} - - uint32_t getRefCount() const { - return *(reinterpret_cast(_data) + 1); - } - - void incRefCount() { - uint32_t *dst = reinterpret_cast(_data) + 1; - ++(*dst); - } - - void decRefCount() { - uint32_t *dst = reinterpret_cast(_data) + 1; - --(*dst); - } - - void setRefCount(uint32_t refCount) { - uint32_t *dst = reinterpret_cast(_data) + 1; - *dst = refCount; - } - - static uint32_t size() { return 2*sizeof(uint32_t); } - }; - -protected: - - class EnumBufferType : public datastore::BufferType { - private: - size_t _minSizeNeeded; // lower cap for sizeNeeded - size_t _deadElems; // dead elements in active buffer - bool _pendingCompact; - bool _wantCompact; - public: - EnumBufferType(); - - size_t calcArraysToAlloc(uint32_t bufferId, size_t sizeNeeded, bool resizing) const override; - - void setSizeNeededAndDead(size_t sizeNeeded, size_t deadElems) { - _minSizeNeeded = sizeNeeded; - _deadElems = deadElems; - } - - void onFree(size_t usedElems) override { - datastore::BufferType::onFree(usedElems); - _pendingCompact = _wantCompact; - _wantCompact = false; - } - - void setWantCompact() { _wantCompact = true; } - bool getPendingCompact() const { return _pendingCompact; } - void clearPendingCompact() { _pendingCompact = false; } - }; - - IEnumStoreDictionary *_enumDict; - DataStoreType _store; - EnumBufferType _type; - std::vector _toHoldBuffers; // used during compaction - - static const uint32_t TYPE_ID = 0; - - EnumStoreBase(uint64_t initBufferSize, bool hasPostings); - - virtual ~EnumStoreBase(); - - EntryBase getEntryBase(Index idx) const { - return EntryBase(const_cast(_store).getEntry(idx)); - } - datastore::BufferState & getBuffer(uint32_t bufferIdx) { - return _store.getBufferState(bufferIdx); - } - const datastore::BufferState & getBuffer(uint32_t bufferIdx) const { - return _store.getBufferState(bufferIdx); - } - bool validIndex(Index idx) const { - return (idx.valid() && idx.offset() < _store.getBufferState(idx.bufferId()).size()); - } - - uint32_t getBufferIndex(datastore::BufferState::State status); - void postCompact(); - bool preCompact(uint64_t bytesNeeded); - -public: - void reset(uint64_t initBufferSize); - - uint32_t getRefCount(Index idx) const { return getEntryBase(idx).getRefCount(); } - void incRefCount(Index idx) { getEntryBase(idx).incRefCount(); } - void decRefCount(Index idx) { getEntryBase(idx).decRefCount(); } - - // Only use when reading from enumerated attribute save files - void fixupRefCount(Index idx, uint32_t refCount) override { - getEntryBase(idx).setRefCount(refCount); - } - - uint32_t getNumUniques() const override { return _enumDict->getNumUniques(); } - - uint32_t getRemaining() const { - return _store.getBufferState(_store.getActiveBufferId(TYPE_ID)).remaining(); - } - uint32_t getCapacity() const { - return _store.getBufferState(_store.getActiveBufferId(TYPE_ID)).capacity(); - } - vespalib::MemoryUsage getMemoryUsage() const override; - vespalib::MemoryUsage getTreeMemoryUsage() const override { return _enumDict->get_memory_usage(); } - - vespalib::AddressSpace getAddressSpaceUsage() const; - - void transferHoldLists(generation_t generation); - void trimHoldLists(generation_t firstUsed); - - static void failNewSize(uint64_t minNewSize, uint64_t maxSize); - - // Align buffers and entries to 4 bytes boundary. - static uint64_t alignBufferSize(uint64_t val) { return Index::align(val); } - static uint32_t alignEntrySize(uint32_t val) { return Index::align(val); } - - void fallbackResize(uint64_t bytesNeeded); - bool getPendingCompact() const { return _type.getPendingCompact(); } - void clearPendingCompact() { _type.clearPendingCompact(); } - - virtual ssize_t deserialize(const void *src, size_t available, size_t &initSpace) = 0; - virtual ssize_t deserialize(const void *src, size_t available, Index &idx) = 0; - - ssize_t deserialize0(const void *src, size_t available, IndexVector &idx) override; - - ssize_t deserialize(const void *src, size_t available, IndexVector &idx) { - return _enumDict->deserialize(src, available, idx); - } - - virtual void freeUnusedEnums(const IndexSet& toRemove) = 0; - - void fixupRefCounts(const EnumVector &hist) { _enumDict->fixupRefCounts(hist); } - void freezeTree() { _enumDict->freeze(); } - - virtual bool performCompaction(uint64_t bytesNeeded, EnumIndexMap & old2New) = 0; - - IEnumStoreDictionary &getEnumStoreDict() override { return *_enumDict; } - const IEnumStoreDictionary &getEnumStoreDict() const override { return *_enumDict; } - EnumPostingTree &getPostingDictionary() { return _enumDict->getPostingDictionary(); } - - const EnumPostingTree &getPostingDictionary() const { - return _enumDict->getPostingDictionary(); - } - const datastore::DataStoreBase &get_data_store_base() const override { return _store; } -}; - -vespalib::asciistream & operator << (vespalib::asciistream & os, const IEnumStore::Index & idx); - -extern template -class datastore::DataStoreT; - - -} diff --git a/searchlib/src/vespa/searchlib/attribute/load_utils.cpp b/searchlib/src/vespa/searchlib/attribute/load_utils.cpp index b33d604c4a8..041daa08cd5 100644 --- a/searchlib/src/vespa/searchlib/attribute/load_utils.cpp +++ b/searchlib/src/vespa/searchlib/attribute/load_utils.cpp @@ -1,10 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include "i_enum_store.h" #include "load_utils.hpp" -#include "multivalue.h" -#include "enumstorebase.h" #include "loadedenumvalue.h" #include "multi_value_mapping.h" +#include "multivalue.h" #include using search::multivalue::Value; diff --git a/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.h b/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.h index a58fa479249..4fa3510fbec 100644 --- a/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.h +++ b/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.h @@ -3,7 +3,8 @@ #pragma once #include -#include +#include +#include namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/loadedvalue.h b/searchlib/src/vespa/searchlib/attribute/loadedvalue.h index f8af21e6fa7..b1d1c178e5f 100644 --- a/searchlib/src/vespa/searchlib/attribute/loadedvalue.h +++ b/searchlib/src/vespa/searchlib/attribute/loadedvalue.h @@ -3,7 +3,7 @@ #pragma once #include -#include +#include #include namespace search diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp index 8cc6d6d6ac6..6a1a5194890 100644 --- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp +++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp @@ -1,10 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include "attributevector.h" +#include "i_enum_store.h" #include "multi_value_mapping.h" #include "multi_value_mapping.hpp" #include "multivalue.h" -#include "enumstorebase.h" -#include "attributevector.h" #include using search::multivalue::Value; diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.h b/searchlib/src/vespa/searchlib/attribute/multienumattribute.h index 48c3649a9b2..ac271247e70 100644 --- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.h @@ -2,10 +2,10 @@ #pragma once -#include "multivalueattribute.h" -#include "enumstorebase.h" +#include "i_enum_store.h" #include "loadedenumvalue.h" #include "multivalue.h" +#include "multivalueattribute.h" #include "no_loaded_vector.h" namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.cpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.cpp index 6f0ea37896f..4409bdd5857 100644 --- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.cpp @@ -9,7 +9,7 @@ LOG_SETUP(".searchlib.attribute.multi_string_post_attribute"); namespace search { IEnumStore::Index -StringEnumIndexMapper::map(IEnumStore::Index original, const EnumStoreComparator & compare) const +StringEnumIndexMapper::map(IEnumStore::Index original, const datastore::EntryComparator& compare) const { return _dictionary.find(original, compare).getKey(); } diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp index 8d956b55733..154bbb91809 100644 --- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp @@ -30,7 +30,7 @@ class StringEnumIndexMapper : public EnumIndexMapper { public: StringEnumIndexMapper(const EnumPostingTree & dictionary) : _dictionary(dictionary) { } - IEnumStore::Index map(IEnumStore::Index original, const EnumStoreComparator & compare) const override; + IEnumStore::Index map(IEnumStore::Index original, const datastore::EntryComparator& compare) const override; virtual bool hasFold() const override { return true; } private: const EnumPostingTree & _dictionary; diff --git a/searchlib/src/vespa/searchlib/attribute/numericbase.h b/searchlib/src/vespa/searchlib/attribute/numericbase.h index f05f99a622a..687dd0face6 100644 --- a/searchlib/src/vespa/searchlib/attribute/numericbase.h +++ b/searchlib/src/vespa/searchlib/attribute/numericbase.h @@ -3,7 +3,7 @@ #pragma once #include "attributevector.h" -#include "enumstorebase.h" +#include "i_enum_store.h" #include "loadedenumvalue.h" #include diff --git a/searchlib/src/vespa/searchlib/attribute/postingchange.cpp b/searchlib/src/vespa/searchlib/attribute/postingchange.cpp index 45bcfb0beac..a98c030bcee 100644 --- a/searchlib/src/vespa/searchlib/attribute/postingchange.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postingchange.cpp @@ -102,7 +102,7 @@ removeDupRemovals(std::vector &removals) } IEnumStore::Index -EnumIndexMapper::map(IEnumStore::Index original, const EnumStoreComparator & compare) const +EnumIndexMapper::map(IEnumStore::Index original, const datastore::EntryComparator& compare) const { (void) compare; return original; @@ -170,14 +170,14 @@ public: const WeightedIndex * entriesOld, size_t szOld, AlwaysWeightedIndexVector & added, AlwaysWeightedIndexVector & changed, AlwaysWeightedIndexVector & removed); - ActualChangeComputer(const EnumStoreComparator &compare, const EnumIndexMapper &mapper); + ActualChangeComputer(const datastore::EntryComparator& compare, const EnumIndexMapper& mapper); ~ActualChangeComputer(); private: WeightedIndexVector _oldEntries; WeightedIndexVector _newEntries; vespalib::hash_map _cachedMapping; - const EnumStoreComparator &_compare; + const datastore::EntryComparator &_compare; const EnumIndexMapper &_mapper; const bool _hasFold; @@ -262,7 +262,7 @@ public: }; template -ActualChangeComputer::ActualChangeComputer(const EnumStoreComparator &compare, +ActualChangeComputer::ActualChangeComputer(const datastore::EntryComparator &compare, const EnumIndexMapper &mapper) : _oldEntries(), _newEntries(), @@ -318,7 +318,7 @@ template PostingMap PostingChangeComputerT:: compute(const MultivalueMapping & mvm, const DocIndices & docIndices, - const EnumStoreComparator & compare, const EnumIndexMapper & mapper) + const datastore::EntryComparator & compare, const EnumIndexMapper & mapper) { typedef ActualChangeComputer AC; AC actualChange(compare, mapper); @@ -362,13 +362,13 @@ typedef std::vector>> DocIndicesValu template WeightedPostingChangeMap PostingChangeComputerT ::compute(const WeightedMultiValueMapping &, const DocIndicesWeighted &, - const EnumStoreComparator &, + const datastore::EntryComparator &, const EnumIndexMapper &); template WeightedPostingChangeMap PostingChangeComputerT ::compute(const ValueMultiValueMapping &, const DocIndicesValue &, - const EnumStoreComparator &, + const datastore::EntryComparator &, const EnumIndexMapper &); } diff --git a/searchlib/src/vespa/searchlib/attribute/postingchange.h b/searchlib/src/vespa/searchlib/attribute/postingchange.h index 3d5cafe098a..569fbfd6517 100644 --- a/searchlib/src/vespa/searchlib/attribute/postingchange.h +++ b/searchlib/src/vespa/searchlib/attribute/postingchange.h @@ -2,12 +2,14 @@ #pragma once +#include "i_enum_store.h" #include "postingdata.h" -#include "enumstorebase.h" #include namespace search { +namespace datastore { class EntryComparator; } + class GrowableBitVector; /** @@ -48,7 +50,7 @@ class EnumIndexMapper { public: virtual ~EnumIndexMapper() { } - virtual IEnumStore::Index map(IEnumStore::Index original, const EnumStoreComparator & compare) const; + virtual IEnumStore::Index map(IEnumStore::Index original, const datastore::EntryComparator& compare) const; virtual bool hasFold() const { return false; } }; @@ -60,7 +62,7 @@ private: public: template static PostingMap compute(const MultivalueMapping & mvm, const DocIndices & docIndices, - const EnumStoreComparator & compare, const EnumIndexMapper & mapper); + const datastore::EntryComparator & compare, const EnumIndexMapper & mapper); }; template <> diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp index 800e621045a..c8ee6ab50b2 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp @@ -114,7 +114,7 @@ PostingListAttributeBase

::fillPostingsFixupEnumBase(const LoadedEnumAttribute template void PostingListAttributeBase

::updatePostings(PostingMap &changePost, - EnumStoreComparator &cmp) + datastore::EntryComparator &cmp) { for (auto& elem : changePost) { auto& change = elem.second; @@ -159,7 +159,7 @@ PostingListAttributeBase

:: clearPostings(attribute::IAttributeVector::EnumHandle eidx, uint32_t fromLid, uint32_t toLid, - EnumStoreComparator &cmp) + datastore::EntryComparator &cmp) { PostingChange

postings; diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h index 50e97e703c3..69b6cf73fa8 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h @@ -57,7 +57,7 @@ protected: virtual void updatePostings(PostingMap & changePost) = 0; - void updatePostings(PostingMap &changePost, EnumStoreComparator &cmp); + void updatePostings(PostingMap &changePost, datastore::EntryComparator &cmp); void clearAllPostings(); void disableFreeLists() { _postingList.disableFreeLists(); } void disableElemHoldList() { _postingList.disableElemHoldList(); } @@ -65,7 +65,7 @@ protected: bool forwardedOnAddDoc(DocId doc, size_t wantSize, size_t wantCapacity); void clearPostings(attribute::IAttributeVector::EnumHandle eidx, uint32_t fromLid, - uint32_t toLid, EnumStoreComparator &cmp); + uint32_t toLid, datastore::EntryComparator &cmp); void forwardedShrinkLidSpace(uint32_t newSize) override; virtual vespalib::MemoryUsage getMemoryUsage() const override; diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp index 97d54022cc2..70cf5f00edb 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp @@ -44,7 +44,7 @@ PostingListSearchContext::~PostingListSearchContext() = default; void -PostingListSearchContext::lookupTerm(const EnumStoreComparator &comp) +PostingListSearchContext::lookupTerm(const datastore::EntryComparator &comp) { _lowerDictItr.lower_bound(_frozenDictionary.getRoot(), EnumIndex(), comp); _upperDictItr = _lowerDictItr; @@ -56,8 +56,8 @@ PostingListSearchContext::lookupTerm(const EnumStoreComparator &comp) void -PostingListSearchContext::lookupRange(const EnumStoreComparator &low, - const EnumStoreComparator &high) +PostingListSearchContext::lookupRange(const datastore::EntryComparator &low, + const datastore::EntryComparator &high) { _lowerDictItr.lower_bound(_frozenDictionary.getRoot(), EnumIndex(), low); _upperDictItr = _lowerDictItr; diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h index f31fbd8423d..a274528c92b 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h @@ -52,8 +52,8 @@ protected: ~PostingListSearchContext(); - void lookupTerm(const EnumStoreComparator &comp); - void lookupRange(const EnumStoreComparator &low, const EnumStoreComparator &high); + void lookupTerm(const datastore::EntryComparator &comp); + void lookupRange(const datastore::EntryComparator &low, const datastore::EntryComparator &high); void lookupSingle(); virtual bool useThis(const DictionaryConstIterator & it) const { (void) it; diff --git a/searchlib/src/vespa/searchlib/attribute/postingstore.h b/searchlib/src/vespa/searchlib/attribute/postingstore.h index 7ca1fa5e641..278b587deda 100644 --- a/searchlib/src/vespa/searchlib/attribute/postingstore.h +++ b/searchlib/src/vespa/searchlib/attribute/postingstore.h @@ -2,8 +2,8 @@ #pragma once +#include "enum_store_dictionary.h" #include "postinglisttraits.h" -#include "enumstorebase.h" #include namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h index 4895eb2256a..23ec0016abf 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h @@ -63,7 +63,7 @@ private: void mergeMemoryStats(vespalib::MemoryUsage & total) override; void applyUpdateValueChange(const Change & c, EnumStore & enumStore, std::map & currEnumIndices); - void makePostingChange(const EnumStoreComparator *cmp, + void makePostingChange(const datastore::EntryComparator *cmp, const std::map &currEnumIndices, PostingMap &changePost); diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp index 0b80c7cbf4a..8afb0418b68 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp @@ -53,7 +53,7 @@ SingleValueNumericPostingAttribute::applyUpdateValueChange(const Change & c, template void SingleValueNumericPostingAttribute:: -makePostingChange(const EnumStoreComparator *cmpa, +makePostingChange(const datastore::EntryComparator *cmpa, const std::map &currEnumIndices, PostingMap &changePost) { diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h index 5afbc5aee1b..49d1be93580 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h @@ -72,7 +72,7 @@ private: std::map &currEnumIndices); void - makePostingChange(const EnumStoreComparator *cmp, + makePostingChange(const datastore::EntryComparator *cmp, Dictionary &dict, const std::map &currEnumIndices, PostingMap &changePost); diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp index 8374647311e..ed76a8eca14 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp @@ -51,7 +51,7 @@ SingleValueStringPostingAttributeT::applyUpdateValueChange(const Change & c, template void SingleValueStringPostingAttributeT:: -makePostingChange(const EnumStoreComparator *cmpa, +makePostingChange(const datastore::EntryComparator *cmpa, Dictionary &dict, const std::map &currEnumIndices, PostingMap &changePost) diff --git a/searchlib/src/vespa/searchlib/attribute/stringbase.h b/searchlib/src/vespa/searchlib/attribute/stringbase.h index 9e441aa2e0c..39f40e0fffe 100644 --- a/searchlib/src/vespa/searchlib/attribute/stringbase.h +++ b/searchlib/src/vespa/searchlib/attribute/stringbase.h @@ -2,15 +2,15 @@ #pragma once +#include "no_loaded_vector.h" #include +#include +#include +#include #include +#include #include #include -#include -#include -#include -#include "no_loaded_vector.h" -#include namespace search { diff --git a/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.cpp b/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.cpp index b372834f3f8..23a0d2d52a6 100644 --- a/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/sourceblendersearch.cpp @@ -2,6 +2,7 @@ #include "sourceblendersearch.h" #include "isourceselector.h" +#include #include #include -- cgit v1.2.3