diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-03-17 13:53:49 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-03-17 14:27:22 +0000 |
commit | 2e12375a3e7b371ec186ff9798b8b006affbec83 (patch) | |
tree | 1f8758c6e624703594e820931dec14c55c0cb7e3 /vespalib | |
parent | b2d5ec8958eaed2d5ab0bd6b52fd8450abc0d24a (diff) |
Order the bits so it is more suitable as a hash value.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/entryref.h | 5 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/entryref.hpp | 2 |
2 files changed, 3 insertions, 4 deletions
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 <uint32_t OffsetBits, uint32_t BufferBits> EntryRefT<OffsetBits, BufferBits>::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); |