diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-22 17:17:16 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-22 17:17:16 +0000 |
commit | 7008026d0058282fc67000e8f66e0eedcc337372 (patch) | |
tree | da8b073cc20879f6e172aeb11f0899ca39649ae6 /searchcore | |
parent | 51defae5f1a7e974488f3299e0a564cb37f403e4 (diff) |
- Update copyright.
- Move code to .cpp file.
Diffstat (limited to 'searchcore')
6 files changed, 90 insertions, 123 deletions
diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp index 06f29cbf694..e8d5b22acfc 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "lid_space_common.h" @@ -14,6 +14,7 @@ bool MyScanIterator::valid() const { return _validItr; } + search::DocumentMetaData MyScanIterator::next(uint32_t compactLidLimit, bool retry) { if (!retry && _itr != _lids.begin()) { ++_itr; @@ -29,6 +30,7 @@ search::DocumentMetaData MyScanIterator::next(uint32_t compactLidLimit, bool ret } return search::DocumentMetaData(); } + search::DocumentMetaData MyScanIterator::getMetaData(uint32_t lid) const { return search::DocumentMetaData(lid, TIMESTAMP_1, createBucketId(lid), GID_1); } @@ -42,6 +44,7 @@ void MyHandler::clearMoveDoneContexts() { _moveDoneContexts.clear(); } + void MyHandler::run_remove_ops(bool remove_batch) { // This ensures to max out the threshold time in the operation rate tracker. @@ -55,6 +58,7 @@ MyHandler::run_remove_ops(bool remove_batch) { _op_listener->notify_remove(); } } + void MyHandler::stop_remove_ops(bool remove_batch) const { if (remove_batch) { @@ -63,10 +67,12 @@ MyHandler::stop_remove_ops(bool remove_batch) const { _rm_listener->get_remove_tracker().reset(vespalib::steady_clock::now()); } } + vespalib::string MyHandler::getName() const { return "myhandler"; } + void MyHandler::set_operation_listener(documentmetastore::OperationListener::SP op_listener) { auto* rm_listener = dynamic_cast<RemoveOperationsRateTracker*>(op_listener.get()); @@ -74,16 +80,19 @@ MyHandler::set_operation_listener(documentmetastore::OperationListener::SP op_li _op_listener = std::move(op_listener); _rm_listener = rm_listener; } + LidUsageStats MyHandler::getLidStatus() const { assert(_handleMoveCnt < _stats.size()); return _stats[_handleMoveCnt]; } + IDocumentScanIterator::UP MyHandler::getIterator() const { assert(_iteratorCnt < _lids.size()); return std::make_unique<MyScanIterator>(_lids[_iteratorCnt++], _bucketIdEqualLid); } + MoveOperation::UP MyHandler::createMoveOperation(const search::DocumentMetaData &document, uint32_t moveToLid) const { assert(document.lid > moveToLid); @@ -91,6 +100,7 @@ MyHandler::createMoveOperation(const search::DocumentMetaData &document, uint32_ _moveToLid = moveToLid; return std::make_unique<MoveOperation>(); } + void MyHandler::handleMove(const MoveOperation &, IDestructorCallback::SP moveDoneCtx) { ++_handleMoveCnt; @@ -98,6 +108,7 @@ MyHandler::handleMove(const MoveOperation &, IDestructorCallback::SP moveDoneCtx _moveDoneContexts.push_back(std::move(moveDoneCtx)); } } + void MyHandler::handleCompactLidSpace(const CompactLidSpaceOperation &op, std::shared_ptr<IDestructorCallback>) { _wantedLidLimit = op.getLidLimit(); @@ -119,77 +130,72 @@ MyHandler::MyHandler(bool storeMoveDoneContexts, bool bucketIdEqualLid) MyHandler::~MyHandler() = default; -#if 0 -struct MyStorer : public IOperationStorer { - uint32_t _moveCnt; - uint32_t _compactCnt; - MyStorer() - : _moveCnt(0), - _compactCnt(0) - {} - void appendOperation(const FeedOperation &op, DoneCallback) override { - if (op.getType() == FeedOperation::MOVE) { - ++ _moveCnt; - } else if (op.getType() == FeedOperation::COMPACT_LID_SPACE) { - ++_compactCnt; - } - } - CommitResult startCommit(DoneCallback) override { - return CommitResult(); - } -}; - -struct MyFrozenBucketHandler : public IFrozenBucketHandler { - BucketId _bucket; - MyFrozenBucketHandler() : _bucket() {} - ExclusiveBucketGuard::UP acquireExclusiveBucket(BucketId bucket) override { - return (_bucket == bucket) - ? ExclusiveBucketGuard::UP() - : std::make_unique<ExclusiveBucketGuard>(bucket); - } - void addListener(IBucketFreezeListener *) override { } - void removeListener(IBucketFreezeListener *) override { } -}; - -struct MyFeedView : public test::DummyFeedView { - explicit MyFeedView(std::shared_ptr<const DocumentTypeRepo> repo) - : test::DummyFeedView(std::move(repo)) - { - } -}; - -struct MyDocumentStore : public test::DummyDocumentStore { - Document::SP _readDoc; - mutable uint32_t _readLid; - MyDocumentStore() : _readDoc(), _readLid(0) {} - ~MyDocumentStore() override; - document::Document::UP read(search::DocumentIdT lid, const document::DocumentTypeRepo &) const override { - _readLid = lid; - return Document::UP(_readDoc->clone()); + +void +MyStorer::appendOperation(const FeedOperation &op, DoneCallback) { + if (op.getType() == FeedOperation::MOVE) { + ++ _moveCnt; + } else if (op.getType() == FeedOperation::COMPACT_LID_SPACE) { + ++_compactCnt; } -}; -#endif +} + +IOperationStorer::CommitResult +MyStorer::startCommit(DoneCallback) { + return CommitResult(); +} + +IFrozenBucketHandler::ExclusiveBucketGuard::UP +MyFrozenBucketHandler::acquireExclusiveBucket(BucketId bucket) { + return (_bucket == bucket) + ? ExclusiveBucketGuard::UP() + : std::make_unique<ExclusiveBucketGuard>(bucket); +} + +MyDocumentStore::MyDocumentStore() + : _readDoc(), + _readLid(0) +{} MyDocumentStore::~MyDocumentStore() = default; -#if 0 -struct MyDocumentRetriever : public DocumentRetrieverBaseForTest { - std::shared_ptr<const DocumentTypeRepo> repo; - const MyDocumentStore& store; - MyDocumentRetriever(std::shared_ptr<const DocumentTypeRepo> repo_in, const MyDocumentStore& store_in) noexcept - : repo(std::move(repo_in)), - store(store_in) - {} - const document::DocumentTypeRepo& getDocumentTypeRepo() const override { return *repo; } - void getBucketMetaData(const storage::spi::Bucket&, DocumentMetaData::Vector&) const override { abort(); } - DocumentMetaData getDocumentMetaData(const DocumentId&) const override { abort(); } - Document::UP getFullDocument(DocumentIdT lid) const override { - return store.read(lid, *repo); - } - CachedSelect::SP parseSelect(const vespalib::string&) const override { abort(); } -}; +document::Document::UP +MyDocumentStore::read(search::DocumentIdT lid, const document::DocumentTypeRepo &) const { + _readLid = lid; + return Document::UP(_readDoc->clone()); +} + +MyDocumentRetriever::MyDocumentRetriever(std::shared_ptr<const DocumentTypeRepo> repo_in, const MyDocumentStore& store_in) noexcept + : repo(std::move(repo_in)), + store(store_in) +{} + +MyDocumentRetriever::~MyDocumentRetriever() = default; + +const document::DocumentTypeRepo& +MyDocumentRetriever::getDocumentTypeRepo() const { + return *repo; +} + +void +MyDocumentRetriever::getBucketMetaData(const storage::spi::Bucket&, DocumentMetaData::Vector&) const { + abort(); +} + +DocumentMetaData +MyDocumentRetriever::getDocumentMetaData(const DocumentId&) const { + abort(); +} -#endif +Document::UP +MyDocumentRetriever::getFullDocument(DocumentIdT lid) const { + return store.read(lid, *repo); +} + +CachedSelect::SP +MyDocumentRetriever::parseSelect(const vespalib::string&) const { + abort(); +} MySubDb::MySubDb(std::shared_ptr<BucketDBOwner> bucket_db, const MyDocumentStore& store, const std::shared_ptr<const DocumentTypeRepo> & repo) : sub_db(std::move(bucket_db), SUBDB_ID), @@ -201,23 +207,3 @@ MySubDb::MySubDb(std::shared_ptr<BucketDBOwner> bucket_db, const MyDocumentStore } MySubDb::~MySubDb() = default; - -#if 0 -struct MyDirectJobRunner : public IMaintenanceJobRunner { - IMaintenanceJob &_job; - explicit MyDirectJobRunner(IMaintenanceJob &job) - : _job(job) - { - _job.registerRunner(this); - } - void run() override { _job.run(); } -}; - -struct MyCountJobRunner : public IMaintenanceJobRunner { - uint32_t runCnt; - explicit MyCountJobRunner(IMaintenanceJob &job) : runCnt(0) { - job.registerRunner(this); - } - void run() override { ++runCnt; } -}; -#endif diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h index 9eb8fc3acd2..ae83441737c 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once @@ -96,26 +96,14 @@ struct MyStorer : public IOperationStorer { : _moveCnt(0), _compactCnt(0) {} - void appendOperation(const FeedOperation &op, DoneCallback) override { - if (op.getType() == FeedOperation::MOVE) { - ++ _moveCnt; - } else if (op.getType() == FeedOperation::COMPACT_LID_SPACE) { - ++_compactCnt; - } - } - CommitResult startCommit(DoneCallback) override { - return CommitResult(); - } + void appendOperation(const FeedOperation &op, DoneCallback) override; + CommitResult startCommit(DoneCallback) override; }; struct MyFrozenBucketHandler : public IFrozenBucketHandler { BucketId _bucket; MyFrozenBucketHandler() : _bucket() {} - ExclusiveBucketGuard::UP acquireExclusiveBucket(BucketId bucket) override { - return (_bucket == bucket) - ? ExclusiveBucketGuard::UP() - : std::make_unique<ExclusiveBucketGuard>(bucket); - } + ExclusiveBucketGuard::UP acquireExclusiveBucket(BucketId bucket) override; void addListener(IBucketFreezeListener *) override { } void removeListener(IBucketFreezeListener *) override { } }; @@ -130,28 +118,21 @@ struct MyFeedView : public test::DummyFeedView { struct MyDocumentStore : public test::DummyDocumentStore { Document::SP _readDoc; mutable uint32_t _readLid; - MyDocumentStore() : _readDoc(), _readLid(0) {} + MyDocumentStore(); ~MyDocumentStore() override; - document::Document::UP read(search::DocumentIdT lid, const document::DocumentTypeRepo &) const override { - _readLid = lid; - return Document::UP(_readDoc->clone()); - } + document::Document::UP read(search::DocumentIdT lid, const document::DocumentTypeRepo &) const override; }; struct MyDocumentRetriever : public DocumentRetrieverBaseForTest { std::shared_ptr<const DocumentTypeRepo> repo; const MyDocumentStore& store; - MyDocumentRetriever(std::shared_ptr<const DocumentTypeRepo> repo_in, const MyDocumentStore& store_in) noexcept - : repo(std::move(repo_in)), - store(store_in) - {} - const document::DocumentTypeRepo& getDocumentTypeRepo() const override { return *repo; } - void getBucketMetaData(const storage::spi::Bucket&, DocumentMetaData::Vector&) const override { abort(); } - DocumentMetaData getDocumentMetaData(const DocumentId&) const override { abort(); } - Document::UP getFullDocument(DocumentIdT lid) const override { - return store.read(lid, *repo); - } - CachedSelect::SP parseSelect(const vespalib::string&) const override { abort(); } + MyDocumentRetriever(std::shared_ptr<const DocumentTypeRepo> repo_in, const MyDocumentStore& store_in) noexcept; + ~MyDocumentRetriever(); + const document::DocumentTypeRepo& getDocumentTypeRepo() const override; + void getBucketMetaData(const storage::spi::Bucket&, DocumentMetaData::Vector&) const override; + DocumentMetaData getDocumentMetaData(const DocumentId&) const override; + Document::UP getFullDocument(DocumentIdT lid) const override; + CachedSelect::SP parseSelect(const vespalib::string&) const override; }; struct MySubDb { diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp index 5afa5176e80..688dd963f61 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "lid_space_jobtest.h" diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp index edd7d3f7f0e..2603c041db0 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "lid_space_common.h" #include <vespa/vespalib/gtest/gtest.h> diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp index c3e6ea78691..bac793fc6e5 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "lid_space_jobtest.h" #include <vespa/searchcore/proton/server/lid_space_compaction_job.h> diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h index 5dc6f89f989..2ca50c064bd 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "lid_space_common.h" #include <vespa/searchcore/proton/server/blockable_maintenance_job.h> |