From 7b2d6ca35843c531672a34cd508ba9df016a1926 Mon Sep 17 00:00:00 2001 From: Geir Storli Date: Tue, 19 Mar 2019 08:50:34 +0000 Subject: [PATCH] Rename data store getBufferEntry() -> getEntry() and change it to take entry ref as argument. Also add getEntryArray() that is used when arraySize > 1 and the offset in entry ref is scaled accordingly. --- .../vespa/searchlib/attribute/enumstore.cpp | 8 +++---- .../src/vespa/searchlib/attribute/enumstore.h | 2 +- .../vespa/searchlib/attribute/enumstore.hpp | 17 +++++++------- .../vespa/searchlib/attribute/enumstorebase.h | 2 +- .../vespa/searchlib/attribute/postingstore.h | 6 ++--- .../vespa/searchlib/btree/btreenodestore.h | 12 +++++----- .../src/vespa/searchlib/btree/btreestore.h | 8 +++---- .../vespa/searchlib/datastore/allocator.hpp | 19 +++++++++------- .../vespa/searchlib/datastore/array_store.h | 5 ++--- .../vespa/searchlib/datastore/array_store.hpp | 5 +++-- .../src/vespa/searchlib/datastore/datastore.h | 2 +- .../vespa/searchlib/datastore/datastore.hpp | 4 +--- .../vespa/searchlib/datastore/datastorebase.h | 22 ++++++++++++++----- .../datastore/free_list_allocator.hpp | 6 ++--- .../datastore/free_list_raw_allocator.hpp | 5 +++-- .../searchlib/datastore/raw_allocator.hpp | 12 ++++++---- .../vespa/searchlib/datastore/unique_store.h | 4 ++-- .../compact_document_words_store.cpp | 3 +-- .../searchlib/memoryindex/featurestore.h | 4 ++-- .../vespa/searchlib/memoryindex/wordstore.h | 3 +-- .../predicate/predicate_interval_store.h | 4 ++-- .../searchlib/tensor/dense_tensor_store.cpp | 3 +-- .../searchlib/tensor/generic_tensor_store.cpp | 6 ++--- 23 files changed, 86 insertions(+), 76 deletions(-) diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp index 19076cc8db7..ef50a2c5327 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp @@ -93,8 +93,7 @@ EnumStoreT::writeValues(BufferWriter &writer, { for (uint32_t i = 0; i < count; ++i) { Index idx = idxs[i]; - const char *src(_store.getBufferEntry(idx.bufferId(), - idx.offset()) + + const char *src(_store.getEntry(idx) + EntryBase::size()); size_t sz = strlen(src) + 1; writer.write(src, sz); @@ -135,7 +134,8 @@ EnumStoreT::deserialize(const void *src, LOG_ABORT("Out of enumstore bufferspace"); } uint64_t offset = buffer.size(); - char *dst(_store.getBufferEntry(activeBufferId, offset)); + Index newIdx(offset, activeBufferId); + char *dst(_store.getEntry(newIdx)); memcpy(dst, &_nextEnum, sizeof(uint32_t)); uint32_t pos = sizeof(uint32_t); uint32_t refCount(0); @@ -149,7 +149,7 @@ EnumStoreT::deserialize(const void *src, assert(ComparatorType::compare(getValue(idx), Entry(dst).getValue()) < 0); } - idx = Index(offset, activeBufferId); + idx = newIdx; return sz; } diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h index 2b614898d0e..2539f2472e2 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.h +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h @@ -106,7 +106,7 @@ class EnumStoreT : public EnumStoreBase using EnumStoreBase::TYPE_ID; Entry getEntry(Index idx) const { - return Entry(const_cast(_store).getBufferEntry(idx.bufferId(), idx.offset())); + return Entry(const_cast(_store).getEntry(idx)); } void printEntry(vespalib::asciistream & os, const Entry & e) const; diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp index 5bc12d8a290..2cddd5b0286 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp @@ -115,7 +115,7 @@ EnumStoreT::writeValues(BufferWriter &writer, const Index *idxs, size size_t sz(EntryType::fixedSize()); for (uint32_t i = 0; i < count; ++i) { Index idx = idxs[i]; - const char *src(_store.getBufferEntry(idx.bufferId(), idx.offset()) + EntryBase::size()); + const char *src(_store.getEntry(idx) + EntryBase::size()); writer.write(src, sz); } } @@ -148,7 +148,8 @@ EnumStoreT::deserialize(const void *src, size_t available, Index &idx HDR_ABORT("not enough space"); } uint64_t offset = buffer.size(); - char *dst(_store.getBufferEntry(activeBufferId, offset)); + Index newIdx(offset, activeBufferId); + char *dst(_store.getEntry(newIdx)); memcpy(dst, &_nextEnum, sizeof(uint32_t)); uint32_t pos = sizeof(uint32_t); uint32_t refCount(0); @@ -161,7 +162,7 @@ EnumStoreT::deserialize(const void *src, size_t available, Index &idx if (idx.valid()) { assert(ComparatorType::compare(getValue(idx), Entry(dst).getValue()) < 0); } - idx = Index(offset, activeBufferId); + idx = newIdx; return sz; } @@ -267,11 +268,11 @@ EnumStoreT::addEnum(Type value, Index &newIdx, Dictionary &dict) } uint64_t offset = buffer.size(); - char * dst = _store.template getBufferEntry(activeBufferId, offset); + newIdx = Index(offset, activeBufferId); + char * dst = _store.template getEntry(newIdx); this->insertEntry(dst, this->_nextEnum++, 0, value); buffer.pushed_back(entrySize); assert(Index::pad(offset) == 0); - newIdx = Index(offset, activeBufferId); // update tree with new index dict.insert(it, newIdx, typename Dictionary::DataType()); @@ -357,7 +358,7 @@ EnumStoreT::reset(Builder &builder, Dictionary &dict) { uint64_t offset = state.size(); Index idx(offset, activeBufferId); - char * dst = _store.template getBufferEntry(activeBufferId, offset); + char * dst = _store.template getEntry(idx); this->insertEntry(dst, this->_nextEnum++, iter->_refCount, iter->_value); state.pushed_back(iter->_sz); @@ -413,7 +414,8 @@ EnumStoreT::performCompaction(Dictionary &dict, EnumIndexMap & old2Ne } uint64_t offset = freeBuf.size(); - char * dst = _store.template getBufferEntry(freeBufferIdx, offset); + Index newIdx = Index(offset, freeBufferIdx); + char * dst = _store.template getEntry(newIdx); // insert entry into free buffer this->insertEntry(dst, newEnum, refCount, value); #ifdef LOG_ENUM_STORE @@ -424,7 +426,6 @@ EnumStoreT::performCompaction(Dictionary &dict, EnumIndexMap & old2Ne } freeBuf.pushed_back(entrySize); assert(Index::pad(offset) == 0); - Index newIdx = Index(offset, freeBufferIdx); #ifdef LOG_ENUM_STORE LOG(info, "performCompaction(): new index: offset = %" PRIu64 diff --git a/searchlib/src/vespa/searchlib/attribute/enumstorebase.h b/searchlib/src/vespa/searchlib/attribute/enumstorebase.h index 7615592a798..51503422335 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstorebase.h +++ b/searchlib/src/vespa/searchlib/attribute/enumstorebase.h @@ -252,7 +252,7 @@ class EnumStoreBase virtual ~EnumStoreBase(); EntryBase getEntryBase(Index idx) const { - return EntryBase(const_cast(_store).getBufferEntry(idx.bufferId(), idx.offset())); + return EntryBase(const_cast(_store).getEntry(idx)); } datastore::BufferState & getBuffer(uint32_t bufferIdx) { return _store.getBufferState(bufferIdx); diff --git a/searchlib/src/vespa/searchlib/attribute/postingstore.h b/searchlib/src/vespa/searchlib/attribute/postingstore.h index 43f9139a068..b2b01409995 100644 --- a/searchlib/src/vespa/searchlib/attribute/postingstore.h +++ b/searchlib/src/vespa/searchlib/attribute/postingstore.h @@ -167,13 +167,11 @@ class PostingStore : public PostingListTraits::PostingStoreBase, AggregatedType getAggregated(const EntryRef ref) const; const BitVectorEntry *getBitVectorEntry(RefType ref) const { - return _store.template getBufferEntry(ref.bufferId(), - ref.offset()); + return _store.template getEntry(ref); } BitVectorEntry *getWBitVectorEntry(RefType ref) { - return _store.template getBufferEntry(ref.bufferId(), - ref.offset()); + return _store.template getEntry(ref); } static inline DataT bitVectorWeight(); diff --git a/searchlib/src/vespa/searchlib/btree/btreenodestore.h b/searchlib/src/vespa/searchlib/btree/btreenodestore.h index 28d0297d554..b53248838f8 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenodestore.h +++ b/searchlib/src/vespa/searchlib/btree/btreenodestore.h @@ -84,34 +84,34 @@ class BTreeNodeStore const InternalNodeType *mapInternalRef(EntryRef ref) const { RefType iRef(ref); - return _store.getBufferEntry(iRef.bufferId(), iRef.offset()); + return _store.getEntry(iRef); } InternalNodeType *mapInternalRef(EntryRef ref) { RefType iRef(ref); - return _store.getBufferEntry(iRef.bufferId(), iRef.offset()); + return _store.getEntry(iRef); } const LeafNodeType *mapLeafRef(EntryRef ref) const { RefType iRef(ref); - return _store.getBufferEntry(iRef.bufferId(), iRef.offset()); + return _store.getEntry(iRef); } LeafNodeType *mapLeafRef(EntryRef ref) { RefType iRef(ref); - return _store.getBufferEntry(iRef.bufferId(), iRef.offset()); + return _store.getEntry(iRef); } template const NodeType *mapRef(EntryRef ref) const { RefType iRef(ref); - return _store.getBufferEntry(iRef.bufferId(), iRef.offset()); + return _store.getEntry(iRef); } template NodeType *mapRef(EntryRef ref) { RefType iRef(ref); - return _store.getBufferEntry(iRef.bufferId(), iRef.offset()); + return _store.getEntry(iRef); } LeafNodeTypeRefPair allocNewLeafNode() { diff --git a/searchlib/src/vespa/searchlib/btree/btreestore.h b/searchlib/src/vespa/searchlib/btree/btreestore.h index 5f5a8ff0d88..40eeb4e9386 100644 --- a/searchlib/src/vespa/searchlib/btree/btreestore.h +++ b/searchlib/src/vespa/searchlib/btree/btreestore.h @@ -91,7 +91,7 @@ class BTreeStore Builder _builder; BTreeType * getWTreeEntry(RefType ref) { - return _store.getBufferEntry(ref.bufferId(), ref.offset()); + return _store.getEntry(ref); } public: @@ -322,11 +322,11 @@ class BTreeStore } const BTreeType * getTreeEntry(RefType ref) const { - return _store.getBufferEntry(ref.bufferId(), ref.offset()); + return _store.getEntry(ref); } - const KeyDataType * getKeyDataEntry(RefType ref, uint32_t clusterSize) const { - return _store.getBufferEntry(ref.bufferId(), ref.offset() * clusterSize); + const KeyDataType * getKeyDataEntry(RefType ref, uint32_t arraySize) const { + return _store.getEntryArray(ref, arraySize); } void freeze() { diff --git a/searchlib/src/vespa/searchlib/datastore/allocator.hpp b/searchlib/src/vespa/searchlib/datastore/allocator.hpp index 553a4e0e30d..fa22ba0c3ed 100644 --- a/searchlib/src/vespa/searchlib/datastore/allocator.hpp +++ b/searchlib/src/vespa/searchlib/datastore/allocator.hpp @@ -24,10 +24,11 @@ Allocator::alloc(Args && ... args) BufferState &state = _store.getBufferState(activeBufferId); assert(state.isActive()); size_t oldBufferSize = state.size(); - EntryT *entry = _store.getBufferEntry(activeBufferId, oldBufferSize); + RefT ref(oldBufferSize, activeBufferId); + EntryT *entry = _store.getEntry(ref); new (static_cast(entry)) EntryT(std::forward(args)...); state.pushed_back(1); - return HandleType(RefT(oldBufferSize, activeBufferId), entry); + return HandleType(ref, entry); } template @@ -40,13 +41,14 @@ Allocator::allocArray(ConstArrayRef array) assert(state.isActive()); assert(state.getArraySize() == array.size()); size_t oldBufferSize = state.size(); - EntryT *buf = _store.template getBufferEntry(activeBufferId, oldBufferSize); + assert((oldBufferSize % array.size()) == 0); + RefT ref((oldBufferSize / array.size()), activeBufferId); + EntryT *buf = _store.template getEntryArray(ref, array.size()); for (size_t i = 0; i < array.size(); ++i) { new (static_cast(buf + i)) EntryT(array[i]); } state.pushed_back(array.size()); - assert((oldBufferSize % array.size()) == 0); - return HandleType(RefT((oldBufferSize / array.size()), activeBufferId), buf); + return HandleType(ref, buf); } template @@ -59,13 +61,14 @@ Allocator::allocArray(size_t size) assert(state.isActive()); assert(state.getArraySize() == size); size_t oldBufferSize = state.size(); - EntryT *buf = _store.template getBufferEntry(activeBufferId, oldBufferSize); + assert((oldBufferSize % size) == 0); + RefT ref((oldBufferSize / size), activeBufferId); + EntryT *buf = _store.template getEntryArray(ref, size); for (size_t i = 0; i < size; ++i) { new (static_cast(buf + i)) EntryT(); } state.pushed_back(size); - assert((oldBufferSize % size) == 0); - return HandleType(RefT((oldBufferSize / size), activeBufferId), buf); + return HandleType(ref, buf); } } diff --git a/searchlib/src/vespa/searchlib/datastore/array_store.h b/searchlib/src/vespa/searchlib/datastore/array_store.h index b4cc7d4eb59..80a11a92f9c 100644 --- a/searchlib/src/vespa/searchlib/datastore/array_store.h +++ b/searchlib/src/vespa/searchlib/datastore/array_store.h @@ -57,12 +57,11 @@ class ArrayStore EntryRef addSmallArray(const ConstArrayRef &array); EntryRef addLargeArray(const ConstArrayRef &array); ConstArrayRef getSmallArray(RefT ref, size_t arraySize) const { - size_t bufferOffset = ref.offset() * arraySize; - const EntryT *buf = _store.template getBufferEntry(ref.bufferId(), bufferOffset); + const EntryT *buf = _store.template getEntryArray(ref, arraySize); return ConstArrayRef(buf, arraySize); } ConstArrayRef getLargeArray(RefT ref) const { - const LargeArray *buf = _store.template getBufferEntry(ref.bufferId(), ref.offset()); + const LargeArray *buf = _store.template getEntry(ref); return ConstArrayRef(&(*buf)[0], buf->size()); } diff --git a/searchlib/src/vespa/searchlib/datastore/array_store.hpp b/searchlib/src/vespa/searchlib/datastore/array_store.hpp index 7efaaa541cb..10521a73ced 100644 --- a/searchlib/src/vespa/searchlib/datastore/array_store.hpp +++ b/searchlib/src/vespa/searchlib/datastore/array_store.hpp @@ -93,10 +93,11 @@ ArrayStore::addLargeArray(const ConstArrayRef &array) BufferState &state = _store.getBufferState(activeBufferId); assert(state.isActive()); size_t oldBufferSize = state.size(); - LargeArray *buf = _store.template getBufferEntry(activeBufferId, oldBufferSize); + RefT ref(oldBufferSize, activeBufferId); + LargeArray *buf = _store.template getEntry(ref); new (static_cast(buf)) LargeArray(array.cbegin(), array.cend()); state.pushed_back(1, sizeof(EntryT) * array.size()); - return RefT(oldBufferSize, activeBufferId); + return ref; } template diff --git a/searchlib/src/vespa/searchlib/datastore/datastore.h b/searchlib/src/vespa/searchlib/datastore/datastore.h index 66fbc37d4fc..6d7376f1b0c 100644 --- a/searchlib/src/vespa/searchlib/datastore/datastore.h +++ b/searchlib/src/vespa/searchlib/datastore/datastore.h @@ -95,7 +95,7 @@ class DataStore : public DataStoreT using ParentType::ensureBufferCapacity; using ParentType::_activeBufferIds; using ParentType::_freeListLists; - using ParentType::getBufferEntry; + using ParentType::getEntry; using ParentType::dropBuffers; using ParentType::initActiveBuffers; using ParentType::addType; diff --git a/searchlib/src/vespa/searchlib/datastore/datastore.hpp b/searchlib/src/vespa/searchlib/datastore/datastore.hpp index ff6c249627b..797cd75cb08 100644 --- a/searchlib/src/vespa/searchlib/datastore/datastore.hpp +++ b/searchlib/src/vespa/searchlib/datastore/datastore.hpp @@ -169,9 +169,7 @@ const EntryType & DataStore::getEntry(EntryRef ref) const { RefType intRef(ref); - const EntryType *be = - this->template - getBufferEntry(intRef.bufferId(), intRef.offset()); + const EntryType *be = this->template getEntry(intRef); return *be; } diff --git a/searchlib/src/vespa/searchlib/datastore/datastorebase.h b/searchlib/src/vespa/searchlib/datastore/datastorebase.h index 4f86594dd58..167fc0a7969 100644 --- a/searchlib/src/vespa/searchlib/datastore/datastorebase.h +++ b/searchlib/src/vespa/searchlib/datastore/datastorebase.h @@ -265,14 +265,24 @@ class DataStoreBase void clearHoldLists(); - template - EntryType *getBufferEntry(uint32_t bufferId, size_t offset) { - return static_cast(_buffers[bufferId].getBuffer()) + offset; + template + EntryType *getEntry(RefType ref) { + return static_cast(_buffers[ref.bufferId()].getBuffer()) + ref.offset(); } - template - const EntryType *getBufferEntry(uint32_t bufferId, size_t offset) const { - return static_cast(_buffers[bufferId].getBuffer()) + offset; + template + const EntryType *getEntry(RefType ref) const { + return static_cast(_buffers[ref.bufferId()].getBuffer()) + ref.offset(); + } + + template + EntryType *getEntryArray(RefType ref, size_t arraySize) { + return static_cast(_buffers[ref.bufferId()].getBuffer()) + (ref.offset() * arraySize); + } + + template + const EntryType *getEntryArray(RefType ref, size_t arraySize) const { + return static_cast(_buffers[ref.bufferId()].getBuffer()) + (ref.offset() * arraySize); } void dropBuffers(); diff --git a/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp b/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp index fed720d52d2..402fbe26725 100644 --- a/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp +++ b/searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp @@ -59,7 +59,7 @@ FreeListAllocator::alloc(Args && ... args) BufferState &state = *freeListList._head; assert(state.isActive()); RefT ref = state.popFreeList(); - EntryT *entry = _store.template getBufferEntry(ref.bufferId(), ref.offset()); + EntryT *entry = _store.template getEntry(ref); ReclaimerT::reclaim(entry); allocator::Assigner::assign(*entry, std::forward(args)...); return HandleType(ref, entry); @@ -77,7 +77,7 @@ FreeListAllocator::allocArray(ConstArrayRef array) assert(state.isActive()); assert(state.getArraySize() == array.size()); RefT ref(state.popFreeList()); - EntryT *buf = _store.template getBufferEntry(ref.bufferId(), ref.offset() * array.size()); + EntryT *buf = _store.template getEntryArray(ref, array.size()); for (size_t i = 0; i < array.size(); ++i) { *(buf + i) = array[i]; } @@ -96,7 +96,7 @@ FreeListAllocator::allocArray(size_t size) assert(state.isActive()); assert(state.getArraySize() == size); RefT ref(state.popFreeList()); - EntryT *buf = _store.template getBufferEntry(ref.bufferId(), ref.offset() * size); + EntryT *buf = _store.template getEntryArray(ref, size); return HandleType(ref, buf); } diff --git a/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp b/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp index dbb54247f58..0e97d6a3c33 100644 --- a/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp +++ b/searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp @@ -25,8 +25,9 @@ FreeListRawAllocator::alloc(size_t numElems) assert(state.getArraySize() == numElems); RefT ref = state.popFreeList(); // If entry ref is not aligned we must scale the offset according to array size as it was divided when the entry ref was created. - size_t offset = !RefT::isAlignedType ? ref.offset() * state.getArraySize() : ref.offset(); - EntryT *entry = _store.template getBufferEntry(ref.bufferId(), offset); + EntryT *entry = !RefT::isAlignedType ? + _store.template getEntryArray(ref, state.getArraySize()) : + _store.template getEntry(ref); return HandleType(ref, entry); } diff --git a/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp b/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp index 431a13f2b48..9b86305a634 100644 --- a/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp +++ b/searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp @@ -23,16 +23,20 @@ RawAllocator::alloc(size_t numElems, size_t extraElems) BufferState &state = _store.getBufferState(activeBufferId); assert(state.isActive()); size_t oldBufferSize = state.size(); - EntryT *buffer = _store.getBufferEntry(activeBufferId, oldBufferSize); - state.pushed_back(numElems); if (RefT::isAlignedType) { // AlignedEntryRef constructor scales down offset by alignment - return HandleType(RefT(oldBufferSize, activeBufferId), buffer); + RefT ref(oldBufferSize, activeBufferId); + EntryT *buffer = _store.getEntry(ref); + state.pushed_back(numElems); + return HandleType(ref, buffer); } else { // Must perform scaling ourselves, according to array size size_t arraySize = state.getArraySize(); assert((numElems % arraySize) == 0u); - return HandleType(RefT(oldBufferSize / arraySize, activeBufferId), buffer); + RefT ref((oldBufferSize / arraySize), activeBufferId); + EntryT *buffer = _store.getEntryArray(ref, arraySize); + state.pushed_back(numElems); + return HandleType(ref, buffer); } } diff --git a/searchlib/src/vespa/searchlib/datastore/unique_store.h b/searchlib/src/vespa/searchlib/datastore/unique_store.h index 15dc485b1da..b5278a289e9 100644 --- a/searchlib/src/vespa/searchlib/datastore/unique_store.h +++ b/searchlib/src/vespa/searchlib/datastore/unique_store.h @@ -48,7 +48,7 @@ class UniqueStore inline const EntryType &get(EntryRef ref) const { if (ref.valid()) { RefType iRef(ref); - return *_store.template getBufferEntry(iRef.bufferId(), iRef.offset()); + return *_store.template getEntry(iRef); } else { return _value; } @@ -94,7 +94,7 @@ class UniqueStore const EntryType &get(EntryRef ref) const { RefType iRef(ref); - return *_store.template getBufferEntry(iRef.bufferId(), iRef.offset()); + return *_store.template getEntry(iRef); } void remove(EntryRef ref); ICompactionContext::UP compactWorst(); diff --git a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp index 3f0ffafcf98..ec8fab1991b 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp @@ -123,8 +123,7 @@ CompactDocumentWordsStore::Iterator CompactDocumentWordsStore::Store::get(datastore::EntryRef ref) const { RefType internalRef(ref); - const uint32_t *buf = _store.getBufferEntry(internalRef.bufferId(), - internalRef.offset()); + const uint32_t *buf = _store.getEntry(internalRef); return Iterator(buf); } diff --git a/searchlib/src/vespa/searchlib/memoryindex/featurestore.h b/searchlib/src/vespa/searchlib/memoryindex/featurestore.h index 4ffdf2bc4e7..f3c2ad6cd03 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/featurestore.h +++ b/searchlib/src/vespa/searchlib/memoryindex/featurestore.h @@ -144,7 +144,7 @@ class FeatureStore uint32_t bufferId = RefType(ref).bufferId(); const datastore::BufferState &state = _store.getBufferState(bufferId); decoder.setEnd( - ((_store.getBufferEntry(bufferId, state.size()) - + ((_store.getEntry(RefType(state.size(), bufferId)) - bits) + 7) / 8, false); } @@ -181,7 +181,7 @@ class FeatureStore */ const uint8_t *getBits(datastore::EntryRef ref) const { RefType iRef(ref); - return _store.getBufferEntry(iRef.bufferId(), iRef.offset()); + return _store.getEntry(iRef); } /** diff --git a/searchlib/src/vespa/searchlib/memoryindex/wordstore.h b/searchlib/src/vespa/searchlib/memoryindex/wordstore.h index dcedaf5d510..a9e941e04d1 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/wordstore.h +++ b/searchlib/src/vespa/searchlib/memoryindex/wordstore.h @@ -26,8 +26,7 @@ class WordStore const char * getWord(datastore::EntryRef ref) const { RefType internalRef(ref); - return _store.getBufferEntry(internalRef.bufferId(), - internalRef.offset()); + return _store.getEntry(internalRef); } MemoryUsage getMemoryUsage() const { diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h index e0a4185f91b..52d3a2fc5b8 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h @@ -30,7 +30,7 @@ class PredicateIntervalStore { DataStoreAdapter(const DataStoreType &store) : _store(store) {} const uint32_t *getBuffer(uint32_t ref) const { RefType entry_ref = datastore::EntryRef(ref); - return _store.getBufferEntry(entry_ref.bufferId(), entry_ref.offset()); + return _store.getEntry(entry_ref); } }; DataStoreAdapter _store_adapter; @@ -101,7 +101,7 @@ class PredicateIntervalStore { size_out = 1; return single_buf; } - const uint32_t *buf = _store.getBufferEntry(data_ref.bufferId(), data_ref.offset()); + const uint32_t *buf = _store.getEntry(data_ref); if (size == RefCacheType::MAX_SIZE) { size = *buf++; } diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp index 094df667146..c20c3d85d28 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp @@ -93,8 +93,7 @@ DenseTensorStore::~DenseTensorStore() const void * DenseTensorStore::getRawBuffer(RefType ref) const { - return _store.getBufferEntry(ref.bufferId(), - ref.offset() * _bufferType.getArraySize()); + return _store.getEntryArray(ref, _bufferType.getArraySize()); } diff --git a/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp index c6cfd23f340..49a78f8d9d9 100644 --- a/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp @@ -43,8 +43,7 @@ GenericTensorStore::getRawBuffer(RefType ref) const if (!ref.valid()) { return std::make_pair(nullptr, 0u); } - const char *buf = _store.getBufferEntry(ref.bufferId(), - ref.offset()); + const char *buf = _store.getEntry(ref); uint32_t len = *reinterpret_cast(buf); return std::make_pair(buf + sizeof(uint32_t), len); } @@ -74,8 +73,7 @@ GenericTensorStore::holdTensor(EntryRef ref) return; } RefType iRef(ref); - const char *buf = _store.getBufferEntry(iRef.bufferId(), - iRef.offset()); + const char *buf = _store.getEntry(iRef); uint32_t len = *reinterpret_cast(buf); _concreteStore.holdElem(ref, len + sizeof(uint32_t)); }