From a248ff694ca95218c4127f9156735ceb3fbba4d7 Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Tue, 12 Dec 2017 11:58:40 +0000 Subject: Add configurable bucket resolver and fixed space repo Make default (aka. placeholder) bucket space index 1, not 0. Bucket space index 0 is now considered an invalid space. --- document/src/vespa/document/bucket/bucketspace.h | 18 ++++++++++-------- document/src/vespa/document/test/make_bucket_space.cpp | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'document') 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(); } -- cgit v1.2.3