From 2e12375a3e7b371ec186ff9798b8b006affbec83 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 17 Mar 2020 13:53:49 +0000 Subject: Order the bits so it is more suitable as a hash value. --- vespalib/src/vespa/vespalib/datastore/entryref.h | 5 ++--- vespalib/src/vespa/vespalib/datastore/entryref.hpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'vespalib') diff --git a/vespalib/src/vespa/vespalib/datastore/entryref.h b/vespalib/src/vespa/vespalib/datastore/entryref.h index c65e788637f..d49b1ab9071 100644 --- a/vespalib/src/vespa/vespalib/datastore/entryref.h +++ b/vespalib/src/vespa/vespalib/datastore/entryref.h @@ -32,9 +32,8 @@ public: EntryRefT() : EntryRef() {} EntryRefT(size_t offset_, uint32_t bufferId_); EntryRefT(const EntryRef & ref_) : EntryRef(ref_.ref()) {} - uint32_t hash() const { return offset() + (bufferId() << OffsetBits); } - size_t offset() const { return _ref >> BufferBits; } - uint32_t bufferId() const { return _ref & (numBuffers() - 1); } + size_t offset() const { return _ref & (offsetSize() - 1); } + uint32_t bufferId() const { return _ref >> OffsetBits; } static size_t offsetSize() { return 1ul << OffsetBits; } static uint32_t numBuffers() { return 1 << BufferBits; } static size_t align(size_t val) { return val; } diff --git a/vespalib/src/vespa/vespalib/datastore/entryref.hpp b/vespalib/src/vespa/vespalib/datastore/entryref.hpp index 6e8b94f8989..b7aafb30fdd 100644 --- a/vespalib/src/vespa/vespalib/datastore/entryref.hpp +++ b/vespalib/src/vespa/vespalib/datastore/entryref.hpp @@ -9,7 +9,7 @@ namespace search::datastore { template EntryRefT::EntryRefT(size_t offset_, uint32_t bufferId_) : - EntryRef((offset_ << BufferBits) + bufferId_) + EntryRef((bufferId_ << OffsetBits) + offset_) { ASSERT_ONCE_OR_LOG(offset_ < offsetSize(), "EntryRefT.offset_overflow", 10000); ASSERT_ONCE_OR_LOG(bufferId_ < numBuffers(), "EntryRefT.bufferId_overflow", 10000); -- cgit v1.2.3