summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-08-18 11:31:31 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-08-18 12:03:53 +0000
commitf3829b251cc830b31b9f1f021a7b594edc3ebfe4 (patch)
tree0ba5feb449199f4f133136206ee6232d280df5c8 /document
parentc6d747e7f832bd24b21216af6437bb76f62c51ef (diff)
Use XXH3 to get a good hash distribution sine it will be very bad when using group/user doc distribution.
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/bucket/bucketid.cpp8
-rw-r--r--document/src/vespa/document/bucket/bucketid.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/document/src/vespa/document/bucket/bucketid.cpp b/document/src/vespa/document/bucket/bucketid.cpp
index f01bfb67674..3752eab4810 100644
--- a/document/src/vespa/document/bucket/bucketid.cpp
+++ b/document/src/vespa/document/bucket/bucketid.cpp
@@ -8,6 +8,7 @@
#include <vespa/vespalib/stllike/hash_set.hpp>
#include <vespa/vespalib/util/stringfmt.h>
#include <limits>
+#include <xxh3.h>
using vespalib::nbostream;
using vespalib::asciistream;
@@ -76,6 +77,12 @@ void BucketId::initialize() noexcept {
fillStripMasks(BucketId::_stripMasks, BucketId::maxNumBits);
}
+uint64_t
+BucketId::xxhash::operator () (const BucketId& bucketId) const noexcept {
+ const uint64_t raw_id = bucketId.getId();
+ return XXH3_64bits(&raw_id, sizeof(uint64_t));
+}
+
vespalib::string
BucketId::toString() const
{
@@ -152,3 +159,4 @@ operator>>(nbostream &is, BucketId &bucketId)
} // document
VESPALIB_HASH_SET_INSTANTIATE_H(document::BucketId, document::BucketId::hash);
+VESPALIB_HASH_SET_INSTANTIATE_H(document::BucketId, document::BucketId::xxhash);
diff --git a/document/src/vespa/document/bucket/bucketid.h b/document/src/vespa/document/bucket/bucketid.h
index d54f86e4ae7..a0f9ca4e94f 100644
--- a/document/src/vespa/document/bucket/bucketid.h
+++ b/document/src/vespa/document/bucket/bucketid.h
@@ -41,6 +41,9 @@ public:
return g.getId();
}
};
+ struct xxhash {
+ uint64_t operator () (const BucketId& g) const noexcept;
+ };
/**
* The primitive type used to store bucket identifiers. If you use the