diff options
Diffstat (limited to 'persistence/src')
7 files changed, 106 insertions, 71 deletions
diff --git a/persistence/src/tests/spi/clusterstatetest.cpp b/persistence/src/tests/spi/clusterstatetest.cpp index a829035b61d..2fdaf25abf6 100644 --- a/persistence/src/tests/spi/clusterstatetest.cpp +++ b/persistence/src/tests/spi/clusterstatetest.cpp @@ -169,7 +169,7 @@ ClusterStateTest::testReady() { lib::ClusterState s("version:1 storage:3 distributor:3"); - Bucket b(document::BucketId(16, 1), PartitionId(0)); + Bucket b(document::Bucket(document::BucketSpace::placeHolder(), document::BucketId(16, 1)), PartitionId(0)); // With 3 copies, this bucket has ideal state 0, 2, 1 diff --git a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp index a0176fe88f2..1ef8956d3d8 100644 --- a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp +++ b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp @@ -2,6 +2,7 @@ #include <vespa/document/base/testdocman.h> #include <vespa/persistence/conformancetest/conformancetest.h> +#include <vespa/persistence/spi/test.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/document/fieldset/fieldsets.h> #include <vespa/document/update/documentupdate.h> @@ -16,6 +17,7 @@ #include <limits> using document::BucketId; +using storage::spi::test::makeBucket; namespace storage::spi { @@ -309,7 +311,7 @@ void ConformanceTest::testBasics() { PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2); spi->createBucket(bucket, context); @@ -395,9 +397,9 @@ void ConformanceTest::testListBuckets() { BucketId bucketId1(8, 0x01); BucketId bucketId2(8, 0x02); BucketId bucketId3(8, 0x03); - Bucket bucket1(bucketId1, partId); - Bucket bucket2(bucketId2, partId); - Bucket bucket3(bucketId3, partId); + Bucket bucket1(makeBucket(bucketId1, partId)); + Bucket bucket2(makeBucket(bucketId2, partId)); + Bucket bucket3(makeBucket(bucketId3, partId)); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x02, 2); @@ -435,7 +437,7 @@ void ConformanceTest::testBucketInfo() { _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2); @@ -493,7 +495,7 @@ ConformanceTest::testOrderIndependentBucketInfo() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2); @@ -538,7 +540,7 @@ void ConformanceTest::testPut() { PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2); spi->createBucket(bucket, context); @@ -563,7 +565,7 @@ void ConformanceTest::testPutNewDocumentVersion() { PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2(doc1->clone()); doc2->setValue("content", document::StringFieldValue("hiho silver")); @@ -614,7 +616,7 @@ void ConformanceTest::testPutOlderDocumentVersion() { PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2(doc1->clone()); doc2->setValue("content", document::StringFieldValue("hiho silver")); @@ -658,7 +660,7 @@ void ConformanceTest::testPutDuplicate() { PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); spi->createBucket(bucket, context); CPPUNIT_ASSERT_EQUAL(Result(), @@ -691,7 +693,7 @@ void ConformanceTest::testRemove() { PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2); spi->createBucket(bucket, context); @@ -787,7 +789,7 @@ void ConformanceTest::testRemoveMerge() { PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); DocumentId removeId("id:fraggle:testdoctype1:n=1:rock"); spi->createBucket(bucket, context); @@ -884,7 +886,7 @@ void ConformanceTest::testUpdate() { Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); spi->createBucket(bucket, context); const document::DocumentType *docType( @@ -960,7 +962,7 @@ void ConformanceTest::testGet() { Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); spi->createBucket(bucket, context); { @@ -1000,7 +1002,7 @@ ConformanceTest::testIterateCreateIterator() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); spi::CreateIteratorResult result( @@ -1020,7 +1022,7 @@ ConformanceTest::testIterateWithUnknownId() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); IteratorId unknownId(123); @@ -1035,7 +1037,7 @@ ConformanceTest::testIterateDestroyIterator() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); CreateIteratorResult iter(createIterator(*spi, b, createSelection(""))); @@ -1068,7 +1070,7 @@ ConformanceTest::testIterateAllDocs() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docs(feedDocs(*spi, testDocMan, b, 100)); @@ -1087,7 +1089,7 @@ ConformanceTest::testIterateAllDocsNewestVersionOnly() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docs(feedDocs(*spi, testDocMan, b, 100)); @@ -1117,7 +1119,7 @@ ConformanceTest::testIterateChunked() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docs(feedDocs(*spi, testDocMan, b, 100)); @@ -1138,7 +1140,7 @@ ConformanceTest::testMaxByteSize() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docs( @@ -1167,7 +1169,7 @@ ConformanceTest::testIterateMatchTimestampRange() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docsToVisit; @@ -1207,7 +1209,7 @@ ConformanceTest::testIterateExplicitTimestampSubset() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docsToVisit; @@ -1258,7 +1260,7 @@ ConformanceTest::testIterateRemoves() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); int docCount = 10; @@ -1311,7 +1313,7 @@ ConformanceTest::testIterateMatchSelection() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docsToVisit; @@ -1347,7 +1349,7 @@ ConformanceTest::testIterationRequiringDocumentIdOnlyMatching() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); feedDocs(*spi, testDocMan, b, 100); @@ -1381,7 +1383,7 @@ ConformanceTest::testIterateBadDocumentSelection() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); { CreateIteratorResult iter( @@ -1423,7 +1425,7 @@ ConformanceTest::testIterateAlreadyCompleted() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); std::vector<DocAndTimestamp> docs = feedDocs(*spi, testDocMan, b, 10); @@ -1448,7 +1450,7 @@ ConformanceTest::testIterateEmptyBucket() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket b(document::BucketId(8, 0x1), PartitionId(0)); + Bucket b(makeBucket(BucketId(8, 0x1))); spi->createBucket(b, context); Selection sel(createSelection("")); @@ -1471,7 +1473,7 @@ ConformanceTest::testDeleteBucket() Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); spi->createBucket(bucket, context); spi->put(bucket, Timestamp(3), doc1, context); @@ -1515,10 +1517,10 @@ ConformanceTest::testSplitNormalCase() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0)); - Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0)); + Bucket bucketA(makeBucket(BucketId(3, 0x02))); + Bucket bucketB(makeBucket(BucketId(3, 0x06))); - Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0)); + Bucket bucketC(makeBucket(BucketId(2, 0x02))); spi->createBucket(bucketC, context); TimestampList tsList; @@ -1591,11 +1593,11 @@ ConformanceTest::testSplitTargetExists() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0)); - Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0)); + Bucket bucketA(makeBucket(BucketId(3, 0x02))); + Bucket bucketB(makeBucket(BucketId(3, 0x06))); spi->createBucket(bucketB, context); - Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0)); + Bucket bucketC(makeBucket(BucketId(2, 0x02))); spi->createBucket(bucketC, context); TimestampList tsList; @@ -1683,10 +1685,10 @@ ConformanceTest::testSplitSingleDocumentInSource() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket target1(document::BucketId(3, 0x02), PartitionId(0)); - Bucket target2(document::BucketId(3, 0x06), PartitionId(0)); + Bucket target1(makeBucket(BucketId(3, 0x02))); + Bucket target2(makeBucket(BucketId(3, 0x06))); - Bucket source(document::BucketId(2, 0x02), PartitionId(0)); + Bucket source(makeBucket(BucketId(2, 0x02))); spi->createBucket(source, context); // Create doc belonging in target2 after split. @@ -1791,18 +1793,18 @@ ConformanceTest::doTestJoinNormalCase(const Bucket& source1, void ConformanceTest::testJoinNormalCase() { - Bucket source1(document::BucketId(3, 0x02), PartitionId(0)); - Bucket source2(document::BucketId(3, 0x06), PartitionId(0)); - Bucket target(document::BucketId(2, 0x02), PartitionId(0)); + Bucket source1(makeBucket(BucketId(3, 0x02))); + Bucket source2(makeBucket(BucketId(3, 0x06))); + Bucket target(makeBucket(BucketId(2, 0x02))); doTestJoinNormalCase(source1, source2, target); } void ConformanceTest::testJoinNormalCaseWithMultipleBitsDecreased() { - Bucket source1(document::BucketId(3, 0x02), PartitionId(0)); - Bucket source2(document::BucketId(3, 0x06), PartitionId(0)); - Bucket target(document::BucketId(1, 0x00), PartitionId(0)); + Bucket source1(makeBucket(BucketId(3, 0x02))); + Bucket source2(makeBucket(BucketId(3, 0x06))); + Bucket target(makeBucket(BucketId(1, 0x00))); doTestJoinNormalCase(source1, source2, target); } @@ -1849,13 +1851,13 @@ ConformanceTest::testJoinTargetExists() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0)); + Bucket bucketA(makeBucket(BucketId(3, 0x02))); spi->createBucket(bucketA, context); - Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0)); + Bucket bucketB(makeBucket(BucketId(3, 0x06))); spi->createBucket(bucketB, context); - Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0)); + Bucket bucketC(makeBucket(BucketId(2, 0x02))); spi->createBucket(bucketC, context); for (uint32_t i = 0; i < 10; ++i) { @@ -1953,11 +1955,11 @@ ConformanceTest::testJoinOneBucket() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0)); + Bucket bucketA(makeBucket(BucketId(3, 0x02))); spi->createBucket(bucketA, context); - Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0)); - Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0)); + Bucket bucketB(makeBucket(BucketId(3, 0x06))); + Bucket bucketC(makeBucket(BucketId(2, 0x02))); populateBucket(bucketA, *spi, context, 0, 10, testDocMan); @@ -2030,16 +2032,16 @@ ConformanceTest::doTestJoinSameSourceBuckets(const Bucket& source, void ConformanceTest::testJoinSameSourceBuckets() { - Bucket source(document::BucketId(3, 0x02), PartitionId(0)); - Bucket target(document::BucketId(2, 0x02), PartitionId(0)); + Bucket source(makeBucket(BucketId(3, 0x02))); + Bucket target(makeBucket(BucketId(2, 0x02))); doTestJoinSameSourceBuckets(source, target); } void ConformanceTest::testJoinSameSourceBucketsWithMultipleBitsDecreased() { - Bucket source(document::BucketId(3, 0x02), PartitionId(0)); - Bucket target(document::BucketId(1, 0x00), PartitionId(0)); + Bucket source(makeBucket(BucketId(3, 0x02))); + Bucket target(makeBucket(BucketId(1, 0x00))); doTestJoinSameSourceBuckets(source, target); } @@ -2072,10 +2074,10 @@ ConformanceTest::testJoinSameSourceBucketsTargetExists() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket source(document::BucketId(3, 0x02), PartitionId(0)); + Bucket source(makeBucket(BucketId(3, 0x02))); spi->createBucket(source, context); - Bucket target(document::BucketId(2, 0x02), PartitionId(0)); + Bucket target(makeBucket(BucketId(2, 0x02))); spi->createBucket(target, context); populateBucket(source, *spi, context, 0, 10, testDocMan); @@ -2101,7 +2103,7 @@ void ConformanceTest::testMaintain() Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); spi->createBucket(bucket, context); spi->put(bucket, Timestamp(3), doc1, context); @@ -2130,7 +2132,7 @@ void ConformanceTest::testBucketActivation() _factory->clear(); PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); spi->setClusterState(createClusterState()); spi->createBucket(bucket, context); @@ -2174,9 +2176,9 @@ void ConformanceTest::testBucketActivationSplitAndJoin() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucketA(document::BucketId(3, 0x02), PartitionId(0)); - Bucket bucketB(document::BucketId(3, 0x06), PartitionId(0)); - Bucket bucketC(document::BucketId(2, 0x02), PartitionId(0)); + Bucket bucketA(makeBucket(BucketId(3, 0x02))); + Bucket bucketB(makeBucket(BucketId(3, 0x06))); + Bucket bucketC(makeBucket(BucketId(2, 0x02))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x02, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x06, 2); @@ -2253,7 +2255,7 @@ void ConformanceTest::testRemoveEntry() PersistenceProvider::UP spi(getSpi(*_factory, testDocMan)); Context context(defaultLoadType, Priority(0), Trace::TraceLevel(0)); - Bucket bucket(document::BucketId(8, 0x01), PartitionId(0)); + Bucket bucket(makeBucket(BucketId(8, 0x01))); Document::SP doc1 = testDocMan.createRandomDocumentAtLocation(0x01, 1); Document::SP doc2 = testDocMan.createRandomDocumentAtLocation(0x01, 2); spi->createBucket(bucket, context); diff --git a/persistence/src/vespa/persistence/spi/CMakeLists.txt b/persistence/src/vespa/persistence/spi/CMakeLists.txt index 598ed757efb..a8b1faadcd3 100644 --- a/persistence/src/vespa/persistence/spi/CMakeLists.txt +++ b/persistence/src/vespa/persistence/spi/CMakeLists.txt @@ -13,6 +13,7 @@ vespa_add_library(persistence_spi OBJECT read_consistency.cpp result selection.cpp + test.cpp docentry DEPENDS ) diff --git a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp index 3782d17ea50..9e687f52363 100644 --- a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp +++ b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.cpp @@ -52,7 +52,7 @@ AbstractPersistenceProvider::getModifiedBuckets() const Result AbstractPersistenceProvider::move(const Bucket& source, PartitionId target, Context& context) { - spi::Bucket to(source.getBucketId(), spi::PartitionId(target)); + spi::Bucket to(source.getBucket(), spi::PartitionId(target)); return join(source, source, to, context); } diff --git a/persistence/src/vespa/persistence/spi/bucket.h b/persistence/src/vespa/persistence/spi/bucket.h index e4cbbeae075..4e234e4dc49 100644 --- a/persistence/src/vespa/persistence/spi/bucket.h +++ b/persistence/src/vespa/persistence/spi/bucket.h @@ -15,25 +15,26 @@ #pragma once #include <persistence/spi/types.h> -#include <vespa/document/bucket/bucketid.h> +#include <vespa/document/bucket/bucket.h> namespace storage { namespace spi { class Bucket { - document::BucketId _bucket; + document::Bucket _bucket; PartitionId _partition; public: - Bucket() : _bucket(0), _partition(0) {} - Bucket(const document::BucketId& b, PartitionId p) + Bucket() : _bucket(document::BucketSpace::placeHolder(), document::BucketId(0)), _partition(0) {} + Bucket(const document::Bucket& b, PartitionId p) : _bucket(b), _partition(p) {} - const document::BucketId& getBucketId() const { return _bucket; } + const document::Bucket &getBucket() const { return _bucket; } + document::BucketId getBucketId() const { return _bucket.getBucketId(); } PartitionId getPartition() const { return _partition; } /** Convert easily to a document bucket id to make class easy to use. */ - operator const document::BucketId&() const { return _bucket; } + operator document::BucketId() const { return _bucket.getBucketId(); } bool operator==(const Bucket& o) const { return (_bucket == o._bucket && _partition == o._partition); diff --git a/persistence/src/vespa/persistence/spi/test.cpp b/persistence/src/vespa/persistence/spi/test.cpp new file mode 100644 index 00000000000..73dd33f06bf --- /dev/null +++ b/persistence/src/vespa/persistence/spi/test.cpp @@ -0,0 +1,17 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "test.h" + +namespace storage::spi::test { + +Bucket makeBucket(document::BucketId bucketId, PartitionId partitionId) +{ + return Bucket(document::Bucket(document::BucketSpace::placeHolder(), bucketId), partitionId); +} + +Bucket makeBucket(document::BucketId bucketId) +{ + return makeBucket(bucketId, PartitionId(0)); +} + +} diff --git a/persistence/src/vespa/persistence/spi/test.h b/persistence/src/vespa/persistence/spi/test.h new file mode 100644 index 00000000000..f3fc7b7f379 --- /dev/null +++ b/persistence/src/vespa/persistence/spi/test.h @@ -0,0 +1,14 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "bucket.h" + +namespace storage::spi::test { + +// Helper functions used by unit tests + +Bucket makeBucket(document::BucketId bucketId, PartitionId partitionId); +Bucket makeBucket(document::BucketId bucketId); + +} |