summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@oath.com>2017-12-18 10:32:16 +0100
committerGitHub <noreply@github.com>2017-12-18 10:32:16 +0100
commit012722079ebdf505ae141be8e2b41bb6370c0bea (patch)
treedcd5e019e9b7ea2aa8aa51060aa3461bb522ebf7 /document
parent232c8b0e86df3c126f59d744bb8523a9d3678f5e (diff)
parenta248ff694ca95218c4127f9156735ceb3fbba4d7 (diff)
Merge pull request #4455 from vespa-engine/vekterli/add-configurable-bucket-space-resolver
Add configurable bucket resolver and fixed space repo/factory
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/bucket/bucketspace.h18
-rw-r--r--document/src/vespa/document/test/make_bucket_space.cpp6
2 files changed, 13 insertions, 11 deletions
diff --git a/document/src/vespa/document/bucket/bucketspace.h b/document/src/vespa/document/bucket/bucketspace.h
index 1198b173a4b..99b510f7aff 100644
--- a/document/src/vespa/document/bucket/bucketspace.h
+++ b/document/src/vespa/document/bucket/bucketspace.h
@@ -16,15 +16,16 @@ class BucketSpace {
public:
using Type = uint64_t;
- BucketSpace(const BucketSpace&) noexcept = default;
- BucketSpace& operator=(const BucketSpace&) noexcept = default;
- explicit BucketSpace(Type id) noexcept : _id(id) {}
+ constexpr BucketSpace(const BucketSpace&) noexcept = default;
+ constexpr BucketSpace& operator=(const BucketSpace&) noexcept = default;
+ constexpr explicit BucketSpace(Type id) noexcept : _id(id) {}
- bool operator <(const BucketSpace& bucket) const noexcept { return _id < bucket._id; }
- bool operator==(const BucketSpace& bucket) const noexcept { return _id == bucket._id; }
- bool operator!=(const BucketSpace& bucket) const noexcept { return _id != bucket._id; }
+ constexpr bool operator <(const BucketSpace& bucket) const noexcept { return _id < bucket._id; }
+ constexpr bool operator==(const BucketSpace& bucket) const noexcept { return _id == bucket._id; }
+ constexpr bool operator!=(const BucketSpace& bucket) const noexcept { return _id != bucket._id; }
- Type getId() const noexcept { return _id; }
+ constexpr Type getId() const noexcept { return _id; }
+ constexpr bool valid() const noexcept { return (_id != 0); }
vespalib::string toString() const;
struct hash {
@@ -36,7 +37,8 @@ public:
/*
* Temporary placeholder value while wiring in use of BucketSpace in APIs.
*/
- static BucketSpace placeHolder() { return BucketSpace(0); }
+ static constexpr BucketSpace placeHolder() noexcept { return BucketSpace(1); }
+ static constexpr BucketSpace invalid() noexcept { return BucketSpace(0); }
private:
Type _id;
};
diff --git a/document/src/vespa/document/test/make_bucket_space.cpp b/document/src/vespa/document/test/make_bucket_space.cpp
index be8292fcf71..dae0399e75d 100644
--- a/document/src/vespa/document/test/make_bucket_space.cpp
+++ b/document/src/vespa/document/test/make_bucket_space.cpp
@@ -11,12 +11,12 @@ BucketSpace makeBucketSpace()
BucketSpace makeBucketSpace(const vespalib::string &docTypeName)
{
- // Used by persistence conformance test to map fron document type name
+ // Used by persistence conformance test to map from document type name
// to bucket space. See document::TestDocRepo for known document types.
if (docTypeName == "no") {
- return BucketSpace(2);
+ return BucketSpace(3);
} else if (docTypeName == "testdoctype2") {
- return BucketSpace(1);
+ return BucketSpace(2);
} else {
return makeBucketSpace();
}