diff options
-rw-r--r-- | searchlib/src/tests/predicate/predicate_interval_store_test.cpp | 2 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/datastore/entryref.h | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/searchlib/src/tests/predicate/predicate_interval_store_test.cpp b/searchlib/src/tests/predicate/predicate_interval_store_test.cpp index f90ed81cd7a..461bfd9ef30 100644 --- a/searchlib/src/tests/predicate/predicate_interval_store_test.cpp +++ b/searchlib/src/tests/predicate/predicate_interval_store_test.cpp @@ -135,7 +135,7 @@ TEST("require that interval refs are reused for identical data.") { PredicateIntervalStore store; auto ref = store.insert<Interval>({{0x00010001}, {0x0002ffff}}); ASSERT_TRUE(ref.valid()); - ASSERT_EQUAL(0x02000040u, ref.ref()); + ASSERT_EQUAL(0x02000001u, ref.ref()); auto ref2 = store.insert<Interval>({{0x00010001}, {0x0002ffff}}); EXPECT_EQUAL(ref.ref(), ref2.ref()); diff --git a/searchlib/src/vespa/searchlib/datastore/entryref.h b/searchlib/src/vespa/searchlib/datastore/entryref.h index dc23349caad..f7f722264f8 100644 --- a/searchlib/src/vespa/searchlib/datastore/entryref.h +++ b/searchlib/src/vespa/searchlib/datastore/entryref.h @@ -29,10 +29,14 @@ class EntryRefT : public EntryRef { public: EntryRefT() : EntryRef() {} EntryRefT(uint64_t offset_, uint32_t bufferId_) : - EntryRef((offset_ << BufferBits) + bufferId_) {} + EntryRef((bufferId_ << OffsetBits) + offset_) {} EntryRefT(const EntryRef & ref_) : EntryRef(ref_.ref()) {} - uint64_t offset() const { return _ref >> BufferBits; } - uint32_t bufferId() const { return _ref & (numBuffers() - 1); } + uint64_t offset() const { return _ref & (offsetSize()-1); } + uint32_t bufferId() const { + return ((OffsetBits + BufferBits) == 32u) + ? (_ref >> OffsetBits) + : ((_ref >> OffsetBits) & (numBuffers() - 1)); + } static uint64_t offsetSize() { return 1ul << OffsetBits; } static uint32_t numBuffers() { return 1 << BufferBits; } static uint64_t align(uint64_t val) { return val; } @@ -46,7 +50,7 @@ public: template <uint32_t OffsetBits, uint32_t OffsetAlign> class AlignedEntryRefT : public EntryRefT<OffsetBits> { private: - typedef EntryRefT<OffsetBits> ParentType; + using ParentType = EntryRefT<OffsetBits>; static const uint32_t PadConstant = ((1 << OffsetAlign) - 1); public: AlignedEntryRefT() : ParentType() {} |