diff options
author | Geir Storli <geirst@oath.com> | 2018-02-02 12:54:29 +0000 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2018-02-02 12:54:29 +0000 |
commit | 4d2fc52cfa76096c81253565874ed33b6b2fe565 (patch) | |
tree | c707f24a3619e914620d075b7c7ac85713b65bf2 | |
parent | 0c29fb32d7263487ce5d722e95e2fb89166b00c8 (diff) |
Define and use fixed bucket spaces names.
7 files changed, 31 insertions, 14 deletions
diff --git a/document/src/tests/fixed_bucket_spaces_test.cpp b/document/src/tests/fixed_bucket_spaces_test.cpp index fab38c638a7..12c248adf37 100644 --- a/document/src/tests/fixed_bucket_spaces_test.cpp +++ b/document/src/tests/fixed_bucket_spaces_test.cpp @@ -44,11 +44,13 @@ void FixedBucketSpacesTest::bucket_space_from_name_throws_exception_for_unknown_ void FixedBucketSpacesTest::name_from_bucket_space_is_defined_for_default_space() { CPPUNIT_ASSERT_EQUAL(vespalib::stringref("default"), FixedBucketSpaces::to_string(FixedBucketSpaces::default_space())); + CPPUNIT_ASSERT_EQUAL(vespalib::stringref("default"), FixedBucketSpaces::default_space_name()); } void FixedBucketSpacesTest::name_from_bucket_space_is_defined_for_global_space() { CPPUNIT_ASSERT_EQUAL(vespalib::stringref("global"), FixedBucketSpaces::to_string(FixedBucketSpaces::global_space())); + CPPUNIT_ASSERT_EQUAL(vespalib::stringref("global"), FixedBucketSpaces::global_space_name()); } void FixedBucketSpacesTest::name_from_bucket_space_throws_exception_for_unknown_space() { diff --git a/document/src/vespa/document/bucket/fixed_bucket_spaces.h b/document/src/vespa/document/bucket/fixed_bucket_spaces.h index 87722c7a21c..c9786306897 100644 --- a/document/src/vespa/document/bucket/fixed_bucket_spaces.h +++ b/document/src/vespa/document/bucket/fixed_bucket_spaces.h @@ -16,6 +16,8 @@ VESPA_DEFINE_EXCEPTION(UnknownBucketSpaceException, vespalib::IllegalArgumentExc struct FixedBucketSpaces { static constexpr BucketSpace default_space() { return BucketSpace(1); }; static constexpr BucketSpace global_space() { return BucketSpace(2); } + static vespalib::stringref default_space_name() { return to_string(default_space()); } + static vespalib::stringref global_space_name() { return to_string(global_space()); } // Post-condition: returned space has valid() == true iff name // is either "default" or "global". diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp index 418d152d6bc..02b94bc8426 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.cpp @@ -2,14 +2,17 @@ #include "getbucketlistmessage.h" #include "getbucketlistreply.h" +#include <vespa/document/bucket/fixed_bucket_spaces.h> #include <vespa/documentapi/messagebus/documentprotocol.h> +using document::FixedBucketSpaces; + namespace documentapi { GetBucketListMessage::GetBucketListMessage(const document::BucketId &bucketId) : DocumentMessage(), _bucketId(bucketId), - _bucketSpace("default") // TODO repo + _bucketSpace(FixedBucketSpaces::default_space_name()) { } diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/statbucketmessage.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/statbucketmessage.cpp index 8c968ce46e6..0bd037b6386 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/statbucketmessage.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/messages/statbucketmessage.cpp @@ -1,22 +1,25 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "statbucketmessage.h" #include "statbucketreply.h" +#include <vespa/document/bucket/fixed_bucket_spaces.h> #include <vespa/documentapi/messagebus/documentprotocol.h> +using document::FixedBucketSpaces; + namespace documentapi { StatBucketMessage::StatBucketMessage() : DocumentMessage(), _bucketId(document::BucketId()), _documentSelection(), - _bucketSpace("default") // TODO repo + _bucketSpace(FixedBucketSpaces::default_space_name()) {} StatBucketMessage::StatBucketMessage(document::BucketId bucketId, const string& documentSelection) : DocumentMessage(), _bucketId(bucketId), _documentSelection(documentSelection), - _bucketSpace("default") // TODO repo + _bucketSpace(FixedBucketSpaces::default_space_name()) {} StatBucketMessage::~StatBucketMessage() { diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp index 44ec234b75e..3cea95dbd39 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp @@ -2,6 +2,9 @@ #include "visitor.h" #include <climits> +#include <vespa/document/bucket/fixed_bucket_spaces.h> + +using document::FixedBucketSpaces; namespace documentapi { @@ -11,7 +14,7 @@ CreateVisitorMessage::CreateVisitorMessage() : _instanceId(), _controlDestination(), _dataDestination(), - _bucketSpace("default"), // TODO repo + _bucketSpace(FixedBucketSpaces::default_space_name()), _docSelection(), _maxPendingReplyCount(8), _buckets(), @@ -35,7 +38,7 @@ CreateVisitorMessage::CreateVisitorMessage(const string& libraryName, _instanceId(instanceId), _controlDestination(controlDestination), _dataDestination(dataDestination), - _bucketSpace("default"), // TODO repo + _bucketSpace(FixedBucketSpaces::default_space_name()), _docSelection(), _maxPendingReplyCount(8), _buckets(), diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp index 2530e9a5770..7eb227cd382 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp @@ -1,12 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "routablefactories50.h" +#include <vespa/document/bucket/bucketidfactory.h> +#include <vespa/document/bucket/fixed_bucket_spaces.h> +#include <vespa/document/select/parser.h> #include <vespa/documentapi/documentapi.h> #include <vespa/documentapi/loadtypes/loadtypeset.h> #include <vespa/vespalib/objects/nbostream.h> -#include <vespa/document/bucket/bucketidfactory.h> -#include <vespa/document/select/parser.h> +using document::FixedBucketSpaces; using vespalib::nbostream; using std::make_unique; using std::make_shared; @@ -408,11 +410,11 @@ bool RoutableFactories50::GetBucketListMessageFactory::encodeBucketSpace( vespalib::stringref bucketSpace, vespalib::GrowableByteBuffer& buf) const { (void) buf; - return (bucketSpace == "default"); // TODO used fixed repo here + return (bucketSpace == FixedBucketSpaces::default_space_name()); } string RoutableFactories50::GetBucketListMessageFactory::decodeBucketSpace(document::ByteBuffer&) const { - return "default"; // TODO fixed bucket repo + return FixedBucketSpaces::default_space_name(); } DocumentMessage::UP @@ -846,11 +848,11 @@ bool RoutableFactories50::StatBucketMessageFactory::encodeBucketSpace( vespalib::stringref bucketSpace, vespalib::GrowableByteBuffer& buf) const { (void) buf; - return (bucketSpace == "default"); // TODO used fixed repo here + return (bucketSpace == FixedBucketSpaces::default_space_name()); } string RoutableFactories50::StatBucketMessageFactory::decodeBucketSpace(document::ByteBuffer&) const { - return "default"; // TODO fixed bucket repo + return FixedBucketSpaces::default_space_name(); } DocumentMessage::UP diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories51.cpp b/documentapi/src/vespa/documentapi/messagebus/routablefactories51.cpp index 15d485e6181..ee51bd306a6 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routablefactories51.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories51.cpp @@ -1,11 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "routablefactories51.h" +#include <vespa/document/bucket/fixed_bucket_spaces.h> +#include <vespa/document/document.h> #include <vespa/documentapi/documentapi.h> #include <vespa/documentapi/loadtypes/loadtypeset.h> -#include <vespa/document/document.h> #include <vespa/vespalib/objects/nbostream.h> +using document::FixedBucketSpaces; using vespalib::nbostream; namespace documentapi { @@ -132,11 +134,11 @@ bool RoutableFactories51::CreateVisitorMessageFactory::encodeBucketSpace( vespalib::stringref bucketSpace, vespalib::GrowableByteBuffer& buf) const { (void) buf; - return (bucketSpace == "default"); // TODO used fixed repo here + return (bucketSpace == FixedBucketSpaces::default_space_name()); } string RoutableFactories51::CreateVisitorMessageFactory::decodeBucketSpace(document::ByteBuffer&) const { - return "default"; // TODO fixed bucket repo + return FixedBucketSpaces::default_space_name(); } DocumentMessage::UP |