summaryrefslogtreecommitdiffstats
path: root/searchlib/src
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-03-19 08:50:34 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-03-19 08:50:34 +0000
commit7b2d6ca35843c531672a34cd508ba9df016a1926 (patch)
treede66519bbc315d02bc88e6bb6b3809ee3221a726 /searchlib/src
parentde69949611cb36b688c280333347f39aaec7304b (diff)
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.
Diffstat (limited to 'searchlib/src')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.hpp17
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstorebase.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postingstore.h6
-rw-r--r--searchlib/src/vespa/searchlib/btree/btreenodestore.h12
-rw-r--r--searchlib/src/vespa/searchlib/btree/btreestore.h8
-rw-r--r--searchlib/src/vespa/searchlib/datastore/allocator.hpp19
-rw-r--r--searchlib/src/vespa/searchlib/datastore/array_store.h5
-rw-r--r--searchlib/src/vespa/searchlib/datastore/array_store.hpp5
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastore.h2
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastore.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastorebase.h22
-rw-r--r--searchlib/src/vespa/searchlib/datastore/free_list_allocator.hpp6
-rw-r--r--searchlib/src/vespa/searchlib/datastore/free_list_raw_allocator.hpp5
-rw-r--r--searchlib/src/vespa/searchlib/datastore/raw_allocator.hpp12
-rw-r--r--searchlib/src/vespa/searchlib/datastore/unique_store.h4
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/featurestore.h4
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/wordstore.h3
-rw-r--r--searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h4
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp6
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<StringEntryType>::writeValues(BufferWriter &writer,
{
for (uint32_t i = 0; i < count; ++i) {
Index idx = idxs[i];
- const char *src(_store.getBufferEntry<char>(idx.bufferId(),
- idx.offset()) +
+ const char *src(_store.getEntry<char>(idx) +
EntryBase::size());
size_t sz = strlen(src) + 1;
writer.write(src, sz);
@@ -135,7 +134,8 @@ EnumStoreT<StringEntryType>::deserialize(const void *src,
LOG_ABORT("Out of enumstore bufferspace");
}
uint64_t offset = buffer.size();
- char *dst(_store.getBufferEntry<char>(activeBufferId, offset));
+ Index newIdx(offset, activeBufferId);
+ char *dst(_store.getEntry<char>(newIdx));
memcpy(dst, &_nextEnum, sizeof(uint32_t));
uint32_t pos = sizeof(uint32_t);
uint32_t refCount(0);
@@ -149,7 +149,7 @@ EnumStoreT<StringEntryType>::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 @@ protected:
using EnumStoreBase::TYPE_ID;
Entry getEntry(Index idx) const {
- return Entry(const_cast<DataStoreType &>(_store).getBufferEntry<char>(idx.bufferId(), idx.offset()));
+ return Entry(const_cast<DataStoreType &>(_store).getEntry<char>(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<EntryType>::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<char>(idx.bufferId(), idx.offset()) + EntryBase::size());
+ const char *src(_store.getEntry<char>(idx) + EntryBase::size());
writer.write(src, sz);
}
}
@@ -148,7 +148,8 @@ EnumStoreT<EntryType>::deserialize(const void *src, size_t available, Index &idx
HDR_ABORT("not enough space");
}
uint64_t offset = buffer.size();
- char *dst(_store.getBufferEntry<char>(activeBufferId, offset));
+ Index newIdx(offset, activeBufferId);
+ char *dst(_store.getEntry<char>(newIdx));
memcpy(dst, &_nextEnum, sizeof(uint32_t));
uint32_t pos = sizeof(uint32_t);
uint32_t refCount(0);
@@ -161,7 +162,7 @@ EnumStoreT<EntryType>::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<EntryType>::addEnum(Type value, Index &newIdx, Dictionary &dict)
}
uint64_t offset = buffer.size();
- char * dst = _store.template getBufferEntry<char>(activeBufferId, offset);
+ newIdx = Index(offset, activeBufferId);
+ char * dst = _store.template getEntry<char>(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<EntryType>::reset(Builder &builder, Dictionary &dict)
{
uint64_t offset = state.size();
Index idx(offset, activeBufferId);
- char * dst = _store.template getBufferEntry<char>(activeBufferId, offset);
+ char * dst = _store.template getEntry<char>(idx);
this->insertEntry(dst, this->_nextEnum++, iter->_refCount, iter->_value);
state.pushed_back(iter->_sz);
@@ -413,7 +414,8 @@ EnumStoreT<EntryType>::performCompaction(Dictionary &dict, EnumIndexMap & old2Ne
}
uint64_t offset = freeBuf.size();
- char * dst = _store.template getBufferEntry<char>(freeBufferIdx, offset);
+ Index newIdx = Index(offset, freeBufferIdx);
+ char * dst = _store.template getEntry<char>(newIdx);
// insert entry into free buffer
this->insertEntry(dst, newEnum, refCount, value);
#ifdef LOG_ENUM_STORE
@@ -424,7 +426,6 @@ EnumStoreT<EntryType>::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 @@ protected:
virtual ~EnumStoreBase();
EntryBase getEntryBase(Index idx) const {
- return EntryBase(const_cast<DataStoreType &>(_store).getBufferEntry<char>(idx.bufferId(), idx.offset()));
+ return EntryBase(const_cast<DataStoreType &>(_store).getEntry<char>(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 @@ public:
AggregatedType getAggregated(const EntryRef ref) const;
const BitVectorEntry *getBitVectorEntry(RefType ref) const {
- return _store.template getBufferEntry<BitVectorEntry>(ref.bufferId(),
- ref.offset());
+ return _store.template getEntry<BitVectorEntry>(ref);
}
BitVectorEntry *getWBitVectorEntry(RefType ref) {
- return _store.template getBufferEntry<BitVectorEntry>(ref.bufferId(),
- ref.offset());
+ return _store.template getEntry<BitVectorEntry>(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 @@ public:
const InternalNodeType *mapInternalRef(EntryRef ref) const {
RefType iRef(ref);
- return _store.getBufferEntry<InternalNodeType>(iRef.bufferId(), iRef.offset());
+ return _store.getEntry<InternalNodeType>(iRef);
}
InternalNodeType *mapInternalRef(EntryRef ref) {
RefType iRef(ref);
- return _store.getBufferEntry<InternalNodeType>(iRef.bufferId(), iRef.offset());
+ return _store.getEntry<InternalNodeType>(iRef);
}
const LeafNodeType *mapLeafRef(EntryRef ref) const {
RefType iRef(ref);
- return _store.getBufferEntry<LeafNodeType>(iRef.bufferId(), iRef.offset());
+ return _store.getEntry<LeafNodeType>(iRef);
}
LeafNodeType *mapLeafRef(EntryRef ref) {
RefType iRef(ref);
- return _store.getBufferEntry<LeafNodeType>(iRef.bufferId(), iRef.offset());
+ return _store.getEntry<LeafNodeType>(iRef);
}
template <typename NodeType>
const NodeType *mapRef(EntryRef ref) const {
RefType iRef(ref);
- return _store.getBufferEntry<NodeType>(iRef.bufferId(), iRef.offset());
+ return _store.getEntry<NodeType>(iRef);
}
template <typename NodeType>
NodeType *mapRef(EntryRef ref) {
RefType iRef(ref);
- return _store.getBufferEntry<NodeType>(iRef.bufferId(), iRef.offset());
+ return _store.getEntry<NodeType>(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 @@ protected:
Builder _builder;
BTreeType * getWTreeEntry(RefType ref) {
- return _store.getBufferEntry<BTreeType>(ref.bufferId(), ref.offset());
+ return _store.getEntry<BTreeType>(ref);
}
public:
@@ -322,11 +322,11 @@ public:
}
const BTreeType * getTreeEntry(RefType ref) const {
- return _store.getBufferEntry<BTreeType>(ref.bufferId(), ref.offset());
+ return _store.getEntry<BTreeType>(ref);
}
- const KeyDataType * getKeyDataEntry(RefType ref, uint32_t clusterSize) const {
- return _store.getBufferEntry<KeyDataType>(ref.bufferId(), ref.offset() * clusterSize);
+ const KeyDataType * getKeyDataEntry(RefType ref, uint32_t arraySize) const {
+ return _store.getEntryArray<KeyDataType>(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<EntryT, RefT>::alloc(Args && ... args)
BufferState &state = _store.getBufferState(activeBufferId);
assert(state.isActive());
size_t oldBufferSize = state.size();
- EntryT *entry = _store.getBufferEntry<EntryT>(activeBufferId, oldBufferSize);
+ RefT ref(oldBufferSize, activeBufferId);
+ EntryT *entry = _store.getEntry<EntryT>(ref);
new (static_cast<void *>(entry)) EntryT(std::forward<Args>(args)...);
state.pushed_back(1);
- return HandleType(RefT(oldBufferSize, activeBufferId), entry);
+ return HandleType(ref, entry);
}
template <typename EntryT, typename RefT>
@@ -40,13 +41,14 @@ Allocator<EntryT, RefT>::allocArray(ConstArrayRef array)
assert(state.isActive());
assert(state.getArraySize() == array.size());
size_t oldBufferSize = state.size();
- EntryT *buf = _store.template getBufferEntry<EntryT>(activeBufferId, oldBufferSize);
+ assert((oldBufferSize % array.size()) == 0);
+ RefT ref((oldBufferSize / array.size()), activeBufferId);
+ EntryT *buf = _store.template getEntryArray<EntryT>(ref, array.size());
for (size_t i = 0; i < array.size(); ++i) {
new (static_cast<void *>(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 <typename EntryT, typename RefT>
@@ -59,13 +61,14 @@ Allocator<EntryT, RefT>::allocArray(size_t size)
assert(state.isActive());
assert(state.getArraySize() == size);
size_t oldBufferSize = state.size();
- EntryT *buf = _store.template getBufferEntry<EntryT>(activeBufferId, oldBufferSize);
+ assert((oldBufferSize % size) == 0);
+ RefT ref((oldBufferSize / size), activeBufferId);
+ EntryT *buf = _store.template getEntryArray<EntryT>(ref, size);
for (size_t i = 0; i < size; ++i) {
new (static_cast<void *>(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 @@ private:
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<EntryT>(ref.bufferId(), bufferOffset);
+ const EntryT *buf = _store.template getEntryArray<EntryT>(ref, arraySize);
return ConstArrayRef(buf, arraySize);
}
ConstArrayRef getLargeArray(RefT ref) const {
- const LargeArray *buf = _store.template getBufferEntry<LargeArray>(ref.bufferId(), ref.offset());
+ const LargeArray *buf = _store.template getEntry<LargeArray>(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<EntryT, RefT>::addLargeArray(const ConstArrayRef &array)
BufferState &state = _store.getBufferState(activeBufferId);
assert(state.isActive());
size_t oldBufferSize = state.size();
- LargeArray *buf = _store.template getBufferEntry<LargeArray>(activeBufferId, oldBufferSize);
+ RefT ref(oldBufferSize, activeBufferId);
+ LargeArray *buf = _store.template getEntry<LargeArray>(ref);
new (static_cast<void *>(buf)) LargeArray(array.cbegin(), array.cend());
state.pushed_back(1, sizeof(EntryT) * array.size());
- return RefT(oldBufferSize, activeBufferId);
+ return ref;
}
template <typename EntryT, typename RefT>
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 @@ protected:
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<EntryType, RefT>::getEntry(EntryRef ref) const
{
RefType intRef(ref);
- const EntryType *be =
- this->template
- getBufferEntry<EntryType>(intRef.bufferId(), intRef.offset());
+ const EntryType *be = this->template getEntry<EntryType>(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 @@ public:
void clearHoldLists();
- template <typename EntryType>
- EntryType *getBufferEntry(uint32_t bufferId, size_t offset) {
- return static_cast<EntryType *>(_buffers[bufferId].getBuffer()) + offset;
+ template <typename EntryType, typename RefType>
+ EntryType *getEntry(RefType ref) {
+ return static_cast<EntryType *>(_buffers[ref.bufferId()].getBuffer()) + ref.offset();
}
- template <typename EntryType>
- const EntryType *getBufferEntry(uint32_t bufferId, size_t offset) const {
- return static_cast<const EntryType *>(_buffers[bufferId].getBuffer()) + offset;
+ template <typename EntryType, typename RefType>
+ const EntryType *getEntry(RefType ref) const {
+ return static_cast<const EntryType *>(_buffers[ref.bufferId()].getBuffer()) + ref.offset();
+ }
+
+ template <typename EntryType, typename RefType>
+ EntryType *getEntryArray(RefType ref, size_t arraySize) {
+ return static_cast<EntryType *>(_buffers[ref.bufferId()].getBuffer()) + (ref.offset() * arraySize);
+ }
+
+ template <typename EntryType, typename RefType>
+ const EntryType *getEntryArray(RefType ref, size_t arraySize) const {
+ return static_cast<const EntryType *>(_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<EntryT, RefT, ReclaimerT>::alloc(Args && ... args)
BufferState &state = *freeListList._head;
assert(state.isActive());
RefT ref = state.popFreeList();
- EntryT *entry = _store.template getBufferEntry<EntryT>(ref.bufferId(), ref.offset());
+ EntryT *entry = _store.template getEntry<EntryT>(ref);
ReclaimerT::reclaim(entry);
allocator::Assigner<EntryT, Args...>::assign(*entry, std::forward<Args>(args)...);
return HandleType(ref, entry);
@@ -77,7 +77,7 @@ FreeListAllocator<EntryT, RefT, ReclaimerT>::allocArray(ConstArrayRef array)
assert(state.isActive());
assert(state.getArraySize() == array.size());
RefT ref(state.popFreeList());
- EntryT *buf = _store.template getBufferEntry<EntryT>(ref.bufferId(), ref.offset() * array.size());
+ EntryT *buf = _store.template getEntryArray<EntryT>(ref, array.size());
for (size_t i = 0; i < array.size(); ++i) {
*(buf + i) = array[i];
}
@@ -96,7 +96,7 @@ FreeListAllocator<EntryT, RefT, ReclaimerT>::allocArray(size_t size)
assert(state.isActive());
assert(state.getArraySize() == size);
RefT ref(state.popFreeList());
- EntryT *buf = _store.template getBufferEntry<EntryT>(ref.bufferId(), ref.offset() * size);
+ EntryT *buf = _store.template getEntryArray<EntryT>(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<EntryT, RefT>::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<EntryT>(ref.bufferId(), offset);
+ EntryT *entry = !RefT::isAlignedType ?
+ _store.template getEntryArray<EntryT>(ref, state.getArraySize()) :
+ _store.template getEntry<EntryT>(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<EntryT, RefT>::alloc(size_t numElems, size_t extraElems)
BufferState &state = _store.getBufferState(activeBufferId);
assert(state.isActive());
size_t oldBufferSize = state.size();
- EntryT *buffer = _store.getBufferEntry<EntryT>(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<EntryT>(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<EntryT>(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 @@ public:
inline const EntryType &get(EntryRef ref) const {
if (ref.valid()) {
RefType iRef(ref);
- return *_store.template getBufferEntry<EntryType>(iRef.bufferId(), iRef.offset());
+ return *_store.template getEntry<EntryType>(iRef);
} else {
return _value;
}
@@ -94,7 +94,7 @@ public:
const EntryType &get(EntryRef ref) const
{
RefType iRef(ref);
- return *_store.template getBufferEntry<EntryType>(iRef.bufferId(), iRef.offset());
+ return *_store.template getEntry<EntryType>(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<uint32_t>(internalRef.bufferId(),
- internalRef.offset());
+ const uint32_t *buf = _store.getEntry<uint32_t>(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 @@ public:
uint32_t bufferId = RefType(ref).bufferId();
const datastore::BufferState &state = _store.getBufferState(bufferId);
decoder.setEnd(
- ((_store.getBufferEntry<uint8_t>(bufferId, state.size()) -
+ ((_store.getEntry<uint8_t>(RefType(state.size(), bufferId)) -
bits) + 7) / 8,
false);
}
@@ -181,7 +181,7 @@ public:
*/
const uint8_t *getBits(datastore::EntryRef ref) const {
RefType iRef(ref);
- return _store.getBufferEntry<uint8_t>(iRef.bufferId(), iRef.offset());
+ return _store.getEntry<uint8_t>(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 @@ public:
const char * getWord(datastore::EntryRef ref) const
{
RefType internalRef(ref);
- return _store.getBufferEntry<char>(internalRef.bufferId(),
- internalRef.offset());
+ return _store.getEntry<char>(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<uint32_t>(entry_ref.bufferId(), entry_ref.offset());
+ return _store.getEntry<uint32_t>(entry_ref);
}
};
DataStoreAdapter _store_adapter;
@@ -101,7 +101,7 @@ public:
size_out = 1;
return single_buf;
}
- const uint32_t *buf = _store.getBufferEntry<uint32_t>(data_ref.bufferId(), data_ref.offset());
+ const uint32_t *buf = _store.getEntry<uint32_t>(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<char>(ref.bufferId(),
- ref.offset() * _bufferType.getArraySize());
+ return _store.getEntryArray<char>(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<char>(ref.bufferId(),
- ref.offset());
+ const char *buf = _store.getEntry<char>(ref);
uint32_t len = *reinterpret_cast<const uint32_t *>(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<char>(iRef.bufferId(),
- iRef.offset());
+ const char *buf = _store.getEntry<char>(iRef);
uint32_t len = *reinterpret_cast<const uint32_t *>(buf);
_concreteStore.holdElem(ref, len + sizeof(uint32_t));
}