diff options
53 files changed, 389 insertions, 636 deletions
diff --git a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.h b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.h index 07482873467..27197c2adb8 100644 --- a/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.h +++ b/persistence/src/vespa/persistence/spi/abstractpersistenceprovider.h @@ -3,9 +3,7 @@ #include <vespa/persistence/spi/persistenceprovider.h> -namespace storage { - -namespace spi { +namespace storage::spi { /** * Simplified abstract persistence provider class. Implements @@ -73,6 +71,3 @@ public: }; } - -} - diff --git a/persistence/src/vespa/persistence/spi/persistenceprovider.h b/persistence/src/vespa/persistence/spi/persistenceprovider.h index d7a5fa2b4a4..b5f2fc198c4 100644 --- a/persistence/src/vespa/persistence/spi/persistenceprovider.h +++ b/persistence/src/vespa/persistence/spi/persistenceprovider.h @@ -15,8 +15,7 @@ namespace document { class FieldSet; } -namespace storage { -namespace spi { +namespace storage::spi { /** * This interface is the basis for a persistence provider in Vespa. A @@ -100,8 +99,7 @@ struct PersistenceProvider * other buckets may be deactivated, so the node must be able to serve * the data from its secondary index or get reduced coverage. */ - virtual Result setActiveState(const Bucket&, - BucketInfo::ActiveState) = 0; + virtual Result setActiveState(const Bucket&, BucketInfo::ActiveState) = 0; /** * Retrieve metadata for a bucket, previously returned in listBuckets(), @@ -171,10 +169,7 @@ struct PersistenceProvider * @param timestamp The timestamp for the new bucket entry. * @param id The ID to remove */ - virtual RemoveResult remove(const Bucket&, - Timestamp timestamp, - const DocumentId& id, - Context&) = 0; + virtual RemoveResult remove(const Bucket&, Timestamp timestamp, const DocumentId& id, Context&) = 0; /** * @see remove() * <p/> @@ -189,10 +184,7 @@ struct PersistenceProvider * @param timestamp The timestamp for the new bucket entry. * @param id The ID to remove */ - virtual RemoveResult removeIfFound(const Bucket&, - Timestamp timestamp, - const DocumentId& id, - Context&) = 0; + virtual RemoveResult removeIfFound(const Bucket&, Timestamp timestamp, const DocumentId& id, Context&) = 0; /** * Remove any trace of the entry with the given timestamp. (Be it a document @@ -209,10 +201,7 @@ struct PersistenceProvider * @param timestamp The timestamp to use for the new update entry. * @param update The document update to apply to the stored document. */ - virtual UpdateResult update(const Bucket&, - Timestamp timestamp, - const DocumentUpdateSP& update, - Context&) = 0; + virtual UpdateResult update(const Bucket&, Timestamp timestamp, const DocumentUpdateSP& update, Context&) = 0; /** * The service layer may choose to batch certain commands. This means that @@ -246,10 +235,7 @@ struct PersistenceProvider * @param fieldSet A set of fields that should be retrieved. * @param id The document id to retrieve. */ - virtual GetResult get(const Bucket&, - const document::FieldSet& fieldSet, - const DocumentId& id, - Context&) const = 0; + virtual GetResult get(const Bucket&, const document::FieldSet& fieldSet, const DocumentId& id, Context&) const = 0; /** * Create an iterator for a given bucket and selection criteria, returning @@ -341,9 +327,7 @@ struct PersistenceProvider * @param maxByteSize An indication of the maximum number of bytes that * should be returned. */ - virtual IterateResult iterate(IteratorId id, - uint64_t maxByteSize, - Context&) const = 0; + virtual IterateResult iterate(IteratorId id, uint64_t maxByteSize, Context&) const = 0; /** * Destroys the iterator specified by the given id. @@ -394,8 +378,7 @@ struct PersistenceProvider * scheduled more often than HIGH maintenance, allowing costly operations * to be run less. */ - virtual Result maintain(const Bucket&, - MaintenanceLevel level) = 0; + virtual Result maintain(const Bucket&, MaintenanceLevel level) = 0; /** * Splits the source bucket into the two target buckets. @@ -412,19 +395,13 @@ struct PersistenceProvider * don't want to split far enough to split content in two. In these cases * target2 will specify invalid bucket 0 (with 0 used bits). */ - virtual Result split(const Bucket& source, - const Bucket& target1, - const Bucket& target2, - Context&) = 0; + virtual Result split(const Bucket& source, const Bucket& target1, const Bucket& target2, Context&) = 0; /** * Joins two buckets into one. After the join, all documents from * source1 and source2 should be stored in the target bucket. */ - virtual Result join(const Bucket& source1, - const Bucket& source2, - const Bucket& target, - Context&) = 0; + virtual Result join(const Bucket& source1, const Bucket& source2, const Bucket& target, Context&) = 0; /** * Moves a bucket from one partition to another. @@ -434,6 +411,4 @@ struct PersistenceProvider virtual Result move(const Bucket&, PartitionId target, Context&) = 0; }; -} // spi -} // storage - +} diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index 206e53e6267..c41b6bdcb97 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -5,6 +5,7 @@ #include <vespa/document/predicate/predicate_slime_builder.h> #include <vespa/document/update/arithmeticvalueupdate.h> #include <vespa/document/update/assignvalueupdate.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/eval/tensor/default_tensor.h> #include <vespa/eval/tensor/tensor.h> #include <vespa/eval/tensor/tensor_factory.h> diff --git a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp index cc94441ccf6..f06bb124eb8 100644 --- a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp @@ -7,6 +7,7 @@ LOG_SETUP("combiningfeedview_test"); #include <vespa/searchcore/proton/server/combiningfeedview.h> #include <vespa/searchcore/proton/test/test.h> #include <vespa/searchlib/common/idestructorcallback.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/vespalib/testkit/testapp.h> using document::DocumentTypeRepo; diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 153b1ae2867..0a73e0b2b6e 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -3,6 +3,7 @@ #include <vespa/persistence/spi/result.h> #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/searchcore/proton/test/bucketfactory.h> #include <vespa/searchcore/proton/common/feedtoken.h> diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index 31311482430..a9fa79f513c 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -21,7 +21,7 @@ #include <vespa/searchcore/proton/test/thread_utils.h> #include <vespa/searchcore/proton/test/threading_service_observer.h> #include <vespa/searchlib/attribute/attributefactory.h> - +#include <vespa/document/update/documentupdate.h> #include <vespa/searchlib/index/docbuilder.h> #include <vespa/log/log.h> diff --git a/searchcore/src/tests/proton/persistenceengine/persistence_handler_map/persistence_handler_map_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistence_handler_map/persistence_handler_map_test.cpp index c333b8943e2..ef12b694187 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistence_handler_map/persistence_handler_map_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistence_handler_map/persistence_handler_map_test.cpp @@ -2,6 +2,9 @@ #include <vespa/searchcore/proton/persistenceengine/ipersistencehandler.h> #include <vespa/searchcore/proton/persistenceengine/persistence_handler_map.h> +#include <vespa/document/fieldvalue/document.h> +#include <vespa/document/update/documentupdate.h> + #include <vespa/vespalib/testkit/testapp.h> using namespace document; @@ -11,43 +14,24 @@ using HandlerSnapshot = PersistenceHandlerMap::HandlerSnapshot; struct DummyPersistenceHandler : public IPersistenceHandler { using SP = std::shared_ptr<DummyPersistenceHandler>; - virtual void initialize() override {} - virtual void handlePut(FeedToken, - const storage::spi::Bucket &, - storage::spi::Timestamp, - const document::Document::SP &) override {} - virtual void handleUpdate(FeedToken, - const storage::spi::Bucket &, - storage::spi::Timestamp, - const document::DocumentUpdate::SP &) override {} - virtual void handleRemove(FeedToken, - const storage::spi::Bucket &, - storage::spi::Timestamp, - const document::DocumentId &) override {} - virtual void handleListBuckets(IBucketIdListResultHandler &) override {} - virtual void handleSetClusterState(const storage::spi::ClusterState &, - IGenericResultHandler &) override {} - virtual void handleSetActiveState(const storage::spi::Bucket &, - storage::spi::BucketInfo::ActiveState, - IGenericResultHandler &) override {} - virtual void handleGetBucketInfo(const storage::spi::Bucket &, - IBucketInfoResultHandler &) override {} - virtual void handleCreateBucket(FeedToken, const storage::spi::Bucket &) override {} - virtual void handleDeleteBucket(FeedToken, const storage::spi::Bucket &) override {} - virtual void handleGetModifiedBuckets(IBucketIdListResultHandler &) override {} - virtual void handleSplit(FeedToken, - const storage::spi::Bucket &, - const storage::spi::Bucket &, - const storage::spi::Bucket &) override {} - virtual void handleJoin(FeedToken, - const storage::spi::Bucket &, - const storage::spi::Bucket &, - const storage::spi::Bucket &) override {} - virtual RetrieversSP getDocumentRetrievers(storage::spi::ReadConsistency) override { return RetrieversSP(); } - virtual BucketGuard::UP lockBucket(const storage::spi::Bucket &) override { return BucketGuard::UP(); } - virtual void handleListActiveBuckets(IBucketIdListResultHandler &) override {} - virtual void handlePopulateActiveBuckets(document::BucketId::List &, - IGenericResultHandler &) override {} + void initialize() override {} + void handlePut(FeedToken, const storage::spi::Bucket &, storage::spi::Timestamp, const document::Document::SP &) override {} + void handleUpdate(FeedToken, const storage::spi::Bucket &, storage::spi::Timestamp, const document::DocumentUpdate::SP &) override {} + void handleRemove(FeedToken, const storage::spi::Bucket &, storage::spi::Timestamp, const document::DocumentId &) override {} + void handleListBuckets(IBucketIdListResultHandler &) override {} + void handleSetClusterState(const storage::spi::ClusterState &, IGenericResultHandler &) override {} + void handleSetActiveState(const storage::spi::Bucket &, storage::spi::BucketInfo::ActiveState, IGenericResultHandler &) override {} + void handleGetBucketInfo(const storage::spi::Bucket &, IBucketInfoResultHandler &) override {} + void handleCreateBucket(FeedToken, const storage::spi::Bucket &) override {} + void handleDeleteBucket(FeedToken, const storage::spi::Bucket &) override {} + void handleGetModifiedBuckets(IBucketIdListResultHandler &) override {} + void handleSplit(FeedToken, const storage::spi::Bucket &, const storage::spi::Bucket &, const storage::spi::Bucket &) override {} + void handleJoin(FeedToken, const storage::spi::Bucket &, const storage::spi::Bucket &, const storage::spi::Bucket &) override {} + + RetrieversSP getDocumentRetrievers(storage::spi::ReadConsistency) override { return RetrieversSP(); } + BucketGuard::UP lockBucket(const storage::spi::Bucket &) override { return BucketGuard::UP(); } + void handleListActiveBuckets(IBucketIdListResultHandler &) override {} + void handlePopulateActiveBuckets(document::BucketId::List &, IGenericResultHandler &) override {} }; BucketSpace space_1(1); diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index 705a27c7fc3..73580416e65 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -5,6 +5,8 @@ #include <vespa/document/fieldset/fieldsets.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/test/make_bucket_space.h> +#include <vespa/document/fieldvalue/document.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/persistence/spi/documentselection.h> #include <vespa/persistence/spi/test.h> #include <vespa/persistence/spi/test.h> diff --git a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h index 31bd7c27c85..ca4a1a28c77 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h @@ -9,12 +9,9 @@ #include <vespa/searchlib/attribute/iattributemanager.h> #include <vespa/searchlib/common/serialnum.h> -namespace search -{ - +namespace search { class IDestructorCallback; class ISequencedTaskExecutor; - } namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_writer.h b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_writer.h index 4275acc7f80..ac16c8b4073 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_writer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_writer.h @@ -6,10 +6,12 @@ #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/query/base.h> #include <vespa/searchlib/common/serialnum.h> -#include <vespa/document/fieldvalue/document.h> -#include <vespa/document/update/documentupdate.h> namespace search { class IDestructorCallback; } +namespace document { + class DocumentUpdate; + class Document; +} namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/index/i_index_writer.h b/searchcore/src/vespa/searchcore/proton/index/i_index_writer.h index 8a087dd826b..e42b8282941 100644 --- a/searchcore/src/vespa/searchcore/proton/index/i_index_writer.h +++ b/searchcore/src/vespa/searchcore/proton/index/i_index_writer.h @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/document/fieldvalue/document.h> -#include <vespa/document/update/documentupdate.h> #include <vespa/searchcorespi/index/iindexmanager.h> #include <vespa/searchlib/query/base.h> #include <vespa/searchlib/common/serialnum.h> @@ -22,19 +20,13 @@ public: virtual ~IIndexWriter() {} - virtual const IIndexManager::SP &getIndexManager() const = 0; + virtual const std::shared_ptr<IIndexManager> &getIndexManager() const = 0; // feed interface - virtual void put(search::SerialNum serialNum, - const document::Document &doc, - const search::DocumentIdT lid) = 0; - virtual void remove(search::SerialNum serialNum, - const search::DocumentIdT lid) = 0; - virtual void commit(search::SerialNum serialNum, - OnWriteDoneType onWriteDone) = 0; - - virtual void - heartBeat(search::SerialNum serialNum) = 0; + virtual void put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid) = 0; + virtual void remove(search::SerialNum serialNum, const search::DocumentIdT lid) = 0; + virtual void commit(search::SerialNum serialNum, OnWriteDoneType onWriteDone) = 0; + virtual void heartBeat(search::SerialNum serialNum) = 0; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp b/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp index 842de3d5b24..42480826d2b 100644 --- a/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp +++ b/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp @@ -1,12 +1,12 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "index_writer.h" +#include <vespa/document/fieldvalue/document.h> #include <vespa/log/log.h> LOG_SETUP(".proton.server.indexadapter"); using document::Document; -using document::FieldValue; namespace proton { @@ -15,7 +15,7 @@ IndexWriter::IndexWriter(const IIndexManager::SP &mgr) { } -IndexWriter::~IndexWriter() {} +IndexWriter::~IndexWriter() = default; bool IndexWriter::ignoreOperation(search::SerialNum serialNum) const { @@ -23,9 +23,7 @@ IndexWriter::ignoreOperation(search::SerialNum serialNum) const { } void -IndexWriter::put(search::SerialNum serialNum, - const document::Document &doc, - const search::DocumentIdT lid) +IndexWriter::put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid) { if (ignoreOperation(serialNum)) { return; @@ -45,14 +43,12 @@ IndexWriter::put(search::SerialNum serialNum, } void -IndexWriter::remove(search::SerialNum serialNum, - const search::DocumentIdT lid) +IndexWriter::remove(search::SerialNum serialNum, const search::DocumentIdT lid) { if (serialNum <= _mgr->getFlushedSerialNum()) { return; } - VLOG(getDebugLevel(lid, NULL), "Handle remove: serial(%" PRIu64 "), lid(%u)", - serialNum, lid); + VLOG(getDebugLevel(lid, NULL), "Handle remove: serial(%" PRIu64 "), lid(%u)", serialNum, lid); _mgr->removeDocument(lid, serialNum); } @@ -71,5 +67,4 @@ IndexWriter::heartBeat(search::SerialNum serialNum) _mgr->heartBeat(serialNum); } - } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp index 3a695e6d5f9..e658bc0cfa0 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp @@ -3,6 +3,7 @@ #include "document_iterator.h" #include <vespa/document/select/gid_filter.h> #include <vespa/document/select/node.h> +#include <vespa/document/fieldvalue/document.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/stllike/hash_map.h> #include <algorithm> @@ -16,7 +17,6 @@ using storage::spi::Timestamp; using document::Document; using document::DocumentId; - namespace proton { namespace { @@ -92,7 +92,7 @@ DocumentIterator::DocumentIterator(const storage::spi::Bucket &bucket, { } -DocumentIterator::~DocumentIterator() {} +DocumentIterator::~DocumentIterator() = default; void DocumentIterator::add(const IDocumentRetriever::SP &retriever) diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.h index 2b2679a12ee..285b3cb2afa 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.h @@ -10,6 +10,7 @@ #include <vespa/persistence/spi/selection.h> #include <vespa/persistence/spi/result.h> #include <vespa/persistence/spi/read_consistency.h> +#include <vespa/document/fieldset/fieldset.h> namespace proton { @@ -39,12 +40,9 @@ private: bool isWeakRead() const { return _readConsistency == ReadConsistency::WEAK; } public: - DocumentIterator(const storage::spi::Bucket &bucket, - const document::FieldSet& fields, - const storage::spi::Selection &selection, - storage::spi::IncludedVersions versions, - ssize_t defaultSerializedSize, - bool ignoreMaxBytes, + DocumentIterator(const storage::spi::Bucket &bucket, const document::FieldSet& fields, + const storage::spi::Selection &selection, storage::spi::IncludedVersions versions, + ssize_t defaultSerializedSize, bool ignoreMaxBytes, ReadConsistency readConsistency=ReadConsistency::STRONG); ~DocumentIterator(); void add(const IDocumentRetriever::SP &retriever); diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.cpp index 5dbf65ec6b5..579bab5ab8b 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.cpp @@ -2,6 +2,7 @@ #include "i_document_retriever.h" #include <vespa/persistence/spi/read_consistency.h> +#include <vespa/document/fieldvalue/document.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.h index c683763e6e1..fbee932bbd1 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/i_document_retriever.h @@ -2,7 +2,6 @@ #pragma once -#include <vespa/document/fieldvalue/document.h> #include <persistence/spi/types.h> #include <vespa/persistence/spi/bucket.h> #include <vespa/persistence/spi/read_consistency.h> @@ -10,11 +9,11 @@ #include <vespa/searchlib/docstore/idocumentstore.h> #include <vespa/searchcore/proton/common/cachedselect.h> #include <vespa/searchlib/query/base.h> -#include <memory> #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h> -namespace proton -{ +namespace document { class Document; } + +namespace proton { /** * This is an interface that allows retrieval of documents by local id and document metadata @@ -26,16 +25,18 @@ class IDocumentRetriever public: using ReadConsistency = storage::spi::ReadConsistency; using ReadGuard = IDocumentMetaStoreContext::IReadGuard::UP; - typedef std::unique_ptr<IDocumentRetriever> UP; - typedef std::shared_ptr<IDocumentRetriever> SP; + using UP = std::unique_ptr<IDocumentRetriever>; + using SP = std::shared_ptr<IDocumentRetriever>; + + using LidVector = search::IDocumentStore::LidVector; + using DocumentUP = std::unique_ptr<document::Document>; - typedef search::IDocumentStore::LidVector LidVector; virtual ~IDocumentRetriever() {} virtual const document::DocumentTypeRepo &getDocumentTypeRepo() const = 0; virtual void getBucketMetaData(const storage::spi::Bucket &bucket, search::DocumentMetaData::Vector &result) const = 0; virtual search::DocumentMetaData getDocumentMetaData(const document::DocumentId &id) const = 0; - virtual document::Document::UP getDocument(search::DocumentIdT lid) const = 0; + virtual DocumentUP getDocument(search::DocumentIdT lid) const = 0; virtual ReadGuard getReadGuard() const = 0; virtual uint32_t getDocIdLimit() const = 0; /** diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/ipersistencehandler.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/ipersistencehandler.h index cd87c18a214..82a9c8174fa 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/ipersistencehandler.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/ipersistencehandler.h @@ -4,11 +4,13 @@ #include "bucket_guard.h" #include "i_document_retriever.h" #include "resulthandler.h" -#include <vespa/document/fieldvalue/document.h> -#include <vespa/document/update/documentupdate.h> #include <vespa/persistence/spi/abstractpersistenceprovider.h> #include <vespa/searchcore/proton/common/feedtoken.h> +namespace document { + class Document; + class DocumentUpdate; +} namespace proton { /** @@ -19,13 +21,12 @@ namespace proton { class IPersistenceHandler { protected: IPersistenceHandler() = default; + using DocumentUpdateSP = std::shared_ptr<document::DocumentUpdate>; + using DocumentSP = std::shared_ptr<document::Document>; public: - /** - * Convenience typedefs. - */ - typedef std::unique_ptr<IPersistenceHandler> UP; - typedef std::shared_ptr<IPersistenceHandler> SP; - typedef std::shared_ptr<std::vector<IDocumentRetriever::SP> > RetrieversSP; + using UP = std::unique_ptr<IPersistenceHandler>; + using SP = std::shared_ptr<IPersistenceHandler>; + using RetrieversSP = std::shared_ptr<std::vector<IDocumentRetriever::SP> >; IPersistenceHandler(const IPersistenceHandler &) = delete; IPersistenceHandler & operator = (const IPersistenceHandler &) = delete; @@ -40,63 +41,39 @@ public: */ virtual void initialize() = 0; - virtual void handlePut(FeedToken token, - const storage::spi::Bucket &bucket, - storage::spi::Timestamp timestamp, - const document::Document::SP &doc) = 0; + virtual void handlePut(FeedToken token, const storage::spi::Bucket &bucket, + storage::spi::Timestamp timestamp, const DocumentSP &doc) = 0; - virtual void handleUpdate(FeedToken token, - const storage::spi::Bucket &bucket, - storage::spi::Timestamp timestamp, - const document::DocumentUpdate::SP &upd) = 0; + virtual void handleUpdate(FeedToken token, const storage::spi::Bucket &bucket, + storage::spi::Timestamp timestamp, const DocumentUpdateSP &upd) = 0; - virtual void handleRemove(FeedToken token, - const storage::spi::Bucket &bucket, - storage::spi::Timestamp timestamp, - const document::DocumentId &id) = 0; + virtual void handleRemove(FeedToken token, const storage::spi::Bucket &bucket, + storage::spi::Timestamp timestamp, const document::DocumentId &id) = 0; virtual void handleListBuckets(IBucketIdListResultHandler &resultHandler) = 0; - - virtual void handleSetClusterState(const storage::spi::ClusterState &calc, - IGenericResultHandler &resultHandler) = 0; + virtual void handleSetClusterState(const storage::spi::ClusterState &calc, IGenericResultHandler &resultHandler) = 0; virtual void handleSetActiveState(const storage::spi::Bucket &bucket, storage::spi::BucketInfo::ActiveState newState, IGenericResultHandler &resultHandler) = 0; - virtual void handleGetBucketInfo(const storage::spi::Bucket &bucket, - IBucketInfoResultHandler &resultHandler) = 0; - - virtual void - handleCreateBucket(FeedToken token, - const storage::spi::Bucket &bucket) = 0; - - virtual void handleDeleteBucket(FeedToken token, - const storage::spi::Bucket &bucket) = 0; - + virtual void handleGetBucketInfo(const storage::spi::Bucket &bucket, IBucketInfoResultHandler &resultHandler) = 0; + virtual void handleCreateBucket(FeedToken token, const storage::spi::Bucket &bucket) = 0; + virtual void handleDeleteBucket(FeedToken token, const storage::spi::Bucket &bucket) = 0; virtual void handleGetModifiedBuckets(IBucketIdListResultHandler &resultHandler) = 0; - virtual void - handleSplit(FeedToken token, - const storage::spi::Bucket &source, - const storage::spi::Bucket &target1, - const storage::spi::Bucket &target2) = 0; + virtual void handleSplit(FeedToken token, const storage::spi::Bucket &source, + const storage::spi::Bucket &target1, const storage::spi::Bucket &target2) = 0; - virtual void - handleJoin(FeedToken token, - const storage::spi::Bucket &source, - const storage::spi::Bucket &target1, - const storage::spi::Bucket &target2) = 0; + virtual void handleJoin(FeedToken token, const storage::spi::Bucket &source, + const storage::spi::Bucket &target1, const storage::spi::Bucket &target2) = 0; virtual RetrieversSP getDocumentRetrievers(storage::spi::ReadConsistency consistency) = 0; virtual BucketGuard::UP lockBucket(const storage::spi::Bucket &bucket) = 0; - virtual void - handleListActiveBuckets(IBucketIdListResultHandler &resultHandler) = 0; + virtual void handleListActiveBuckets(IBucketIdListResultHandler &resultHandler) = 0; - virtual void - handlePopulateActiveBuckets(document::BucketId::List &buckets, - IGenericResultHandler &resultHandler) = 0; + virtual void handlePopulateActiveBuckets(document::BucketId::List &buckets, IGenericResultHandler &resultHandler) = 0; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp index 056497d137e..bab3494ca5c 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp @@ -5,6 +5,9 @@ #include "transport_latch.h" #include <vespa/metrics/loadmetric.h> #include <vespa/vespalib/stllike/hash_set.h> +#include <vespa/document/fieldvalue/document.h> +#include <vespa/document/update/documentupdate.h> + #include <vespa/log/log.h> LOG_SETUP(".proton.persistenceengine.persistenceengine"); @@ -138,11 +141,9 @@ public: BucketInfo b1 = _result.getBucketInfo(); BucketInfo b2 = result.getBucketInfo(); BucketInfo::ReadyState ready = - (b1.getReady() == b2.getReady() ? b1.getReady() : - BucketInfo::NOT_READY); + (b1.getReady() == b2.getReady() ? b1.getReady() : BucketInfo::NOT_READY); BucketInfo::ActiveState active = - (b1.getActive() == b2.getActive() ? b1.getActive() : - BucketInfo::NOT_ACTIVE); + (b1.getActive() == b2.getActive() ? b1.getActive() : BucketInfo::NOT_ACTIVE); _result = BucketInfoResult( BucketInfo(BucketChecksum(b1.getChecksum() + b2.getChecksum()), b1.getDocumentCount() + b2.getDocumentCount(), diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h index f0e7b7057de..f2ab35e0ccf 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h @@ -4,10 +4,10 @@ #include "document_iterator.h" #include "i_resource_write_filter.h" #include "persistence_handler_map.h" +#include "ipersistencehandler.h" #include <vespa/document/bucket/bucketspace.h> #include <vespa/persistence/spi/abstractpersistenceprovider.h> #include <vespa/searchcore/proton/common/handlermap.hpp> -#include <vespa/searchcore/proton/persistenceengine/ipersistencehandler.h> #include <mutex> #include <shared_mutex> #include <unordered_map> @@ -47,13 +47,8 @@ private: DocumentIterator it; bool in_use; std::vector<BucketGuard::UP> bucket_guards; - IteratorEntry(storage::spi::ReadConsistency readConsistency, - const Bucket &b, - const document::FieldSet& f, - const Selection &s, - IncludedVersions v, - ssize_t defaultSerializedSize, - bool ignoreMaxBytes) + IteratorEntry(storage::spi::ReadConsistency readConsistency, const Bucket &b, const document::FieldSet& f, + const Selection &s, IncludedVersions v, ssize_t defaultSerializedSize, bool ignoreMaxBytes) : handler_sequence(), it(b, f, s, v, defaultSerializedSize, ignoreMaxBytes, readConsistency), in_use(false), @@ -80,8 +75,7 @@ private: mutable ExtraModifiedBuckets _extraModifiedBuckets; mutable std::shared_timed_mutex _rwMutex; - IPersistenceHandler::SP getHandler(document::BucketSpace bucketSpace, - const DocTypeName &docType) const; + IPersistenceHandler::SP getHandler(document::BucketSpace bucketSpace, const DocTypeName &docType) const; HandlerSnapshot::UP getHandlerSnapshot() const; HandlerSnapshot::UP getHandlerSnapshot(document::BucketSpace bucketSpace) const; @@ -91,16 +85,13 @@ private: public: typedef std::unique_ptr<PersistenceEngine> UP; - PersistenceEngine(IPersistenceEngineOwner &owner, - const IResourceWriteFilter &writeFilter, + PersistenceEngine(IPersistenceEngineOwner &owner, const IResourceWriteFilter &writeFilter, ssize_t defaultSerializedSize, bool ignoreMaxBytes); ~PersistenceEngine(); - IPersistenceHandler::SP putHandler(document::BucketSpace bucketSpace, - const DocTypeName &docType, + IPersistenceHandler::SP putHandler(document::BucketSpace bucketSpace, const DocTypeName &docType, const IPersistenceHandler::SP &handler); - IPersistenceHandler::SP removeHandler(document::BucketSpace bucketSpace, - const DocTypeName &docType); + IPersistenceHandler::SP removeHandler(document::BucketSpace bucketSpace, const DocTypeName &docType); // Implements PersistenceProvider virtual Result initialize() override; @@ -109,10 +100,12 @@ public: virtual Result setClusterState(BucketSpace bucketSpace, const ClusterState& calc) override; virtual Result setActiveState(const Bucket& bucket, BucketInfo::ActiveState newState) override; virtual BucketInfoResult getBucketInfo(const Bucket&) const override; - virtual Result put(const Bucket&, Timestamp, const document::Document::SP&, Context&) override; + virtual Result put(const Bucket&, Timestamp, const std::shared_ptr<document::Document>&, Context&) override; virtual RemoveResult remove(const Bucket&, Timestamp, const document::DocumentId&, Context&) override; - virtual UpdateResult update(const Bucket&, Timestamp, const document::DocumentUpdate::SP&, Context&) override; - virtual GetResult get(const Bucket&, const document::FieldSet&, const document::DocumentId&, Context&) const override; + virtual UpdateResult update(const Bucket&, Timestamp, + const std::shared_ptr<document::DocumentUpdate>&, Context&) override; + virtual GetResult get(const Bucket&, const document::FieldSet&, + const document::DocumentId&, Context&) const override; virtual CreateIteratorResult createIterator(const Bucket&, const document::FieldSet&, const Selection&, IncludedVersions, Context&) override; virtual IterateResult iterate(IteratorId, uint64_t maxByteSize, Context&) const override; diff --git a/searchcore/src/vespa/searchcore/proton/server/commit_and_wait_document_retriever.h b/searchcore/src/vespa/searchcore/proton/server/commit_and_wait_document_retriever.h index 4855b4f95e9..ec1f2cbcdc3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/commit_and_wait_document_retriever.h +++ b/searchcore/src/vespa/searchcore/proton/server/commit_and_wait_document_retriever.h @@ -4,6 +4,7 @@ #include <vespa/searchcore/proton/persistenceengine/i_document_retriever.h> #include <vespa/searchcore/proton/server/icommitable.h> +#include <vespa/document/fieldvalue/document.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp index 1c3a5c94733..a195471d493 100644 --- a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp @@ -2,9 +2,9 @@ #include "docstorevalidator.h" #include <vespa/searchlib/common/bitvector.h> +#include <vespa/document/fieldvalue/document.h> -namespace proton -{ +namespace proton { DocStoreValidator::DocStoreValidator(IDocumentMetaStore &dms) : _dms(dms), diff --git a/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp b/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp index 81bdddba345..3c73532fbba 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentbucketmover.cpp @@ -7,6 +7,7 @@ #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store.h> #include <vespa/searchcore/proton/feedoperation/moveoperation.h> #include <vespa/searchcore/proton/persistenceengine/i_document_retriever.h> +#include <vespa/document/fieldvalue/document.h> using document::BucketId; using document::Document; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h index df44c6c09e6..c4083c3db7a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h @@ -20,7 +20,10 @@ namespace vespa::config::search::internal { } namespace vespa::config::search::summary { namespace internal { class InternalJuniperrcType; } } -namespace document { class DocumentTypeRepo; } +namespace document { + class DocumentTypeRepo; + class DocumentType; +} namespace document::internal { class InternalDocumenttypesType; } namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp index c3c0add2b85..858e1d51d3f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp @@ -8,7 +8,6 @@ using document::Document; using document::DocumentUpdate; -using document::FieldUpdate; using search::index::Schema; namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp index 90b9bbc7f34..e8dc4eecbf3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp @@ -10,6 +10,7 @@ #include <vespa/document/base/exceptions.h> #include <vespa/document/datatype/documenttype.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/searchcore/proton/bucketdb/ibucketdbhandler.h> #include <vespa/searchcore/proton/persistenceengine/i_resource_write_filter.h> #include <vespa/searchcore/proton/persistenceengine/transport_latch.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp index 90aa884bf97..a77aa302fea 100644 --- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_handler.cpp @@ -6,6 +6,7 @@ #include <vespa/searchcore/proton/docsummary/isummarymanager.h> #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h> #include <vespa/searchlib/common/idestructorcallback.h> +#include <vespa/document/fieldvalue/document.h> using document::BucketId; using document::Document; diff --git a/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.cpp b/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.cpp index 541de44d44e..beee2716cc7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.cpp @@ -10,6 +10,8 @@ #include <vespa/searchcore/proton/feedoperation/removeoperation.h> #include <vespa/searchcore/proton/feedoperation/splitbucketoperation.h> #include <vespa/searchcore/proton/feedoperation/updateoperation.h> +#include <vespa/document/fieldvalue/document.h> +#include <vespa/document/update/documentupdate.h> using storage::spi::Bucket; using storage::spi::Timestamp; @@ -37,37 +39,23 @@ PersistenceHandlerProxy::initialize() } void -PersistenceHandlerProxy::handlePut(FeedToken token, - const Bucket &bucket, - Timestamp timestamp, - const document::Document::SP &doc) +PersistenceHandlerProxy::handlePut(FeedToken token, const Bucket &bucket, Timestamp timestamp, const DocumentSP &doc) { - FeedOperation::UP op(new PutOperation(bucket.getBucketId().stripUnused(), - timestamp, doc)); + FeedOperation::UP op(new PutOperation(bucket.getBucketId().stripUnused(), timestamp, doc)); _feedHandler.handleOperation(token, std::move(op)); } void -PersistenceHandlerProxy::handleUpdate(FeedToken token, - const Bucket &bucket, - Timestamp timestamp, - const document::DocumentUpdate::SP &upd) -{ - FeedOperation::UP op(new UpdateOperation(bucket.getBucketId(). - stripUnused(), - timestamp, upd)); +PersistenceHandlerProxy::handleUpdate(FeedToken token, const Bucket &bucket, Timestamp timestamp, const DocumentUpdateSP &upd) +{ + FeedOperation::UP op(new UpdateOperation(bucket.getBucketId().stripUnused(), timestamp, upd)); _feedHandler.handleOperation(token, std::move(op)); } void -PersistenceHandlerProxy::handleRemove(FeedToken token, - const Bucket &bucket, - Timestamp timestamp, - const document::DocumentId &id) -{ - FeedOperation::UP op(new RemoveOperation(bucket.getBucketId(). - stripUnused(), - timestamp, id)); +PersistenceHandlerProxy::handleRemove(FeedToken token, const Bucket &bucket, Timestamp timestamp, const document::DocumentId &id) +{ + FeedOperation::UP op(new RemoveOperation(bucket.getBucketId().stripUnused(), timestamp, id)); _feedHandler.handleOperation(token, std::move(op)); } @@ -78,44 +66,36 @@ PersistenceHandlerProxy::handleListBuckets(IBucketIdListResultHandler &resultHan } void -PersistenceHandlerProxy::handleSetClusterState(const storage::spi::ClusterState &calc, - IGenericResultHandler &resultHandler) +PersistenceHandlerProxy::handleSetClusterState(const storage::spi::ClusterState &calc, IGenericResultHandler &resultHandler) { _clusterStateHandler.handleSetClusterState(calc, resultHandler); } void -PersistenceHandlerProxy::handleSetActiveState( - const storage::spi::Bucket &bucket, - storage::spi::BucketInfo::ActiveState newState, - IGenericResultHandler &resultHandler) +PersistenceHandlerProxy::handleSetActiveState(const storage::spi::Bucket &bucket, + storage::spi::BucketInfo::ActiveState newState, + IGenericResultHandler &resultHandler) { - _bucketHandler.handleSetCurrentState(bucket.getBucketId().stripUnused(), - newState, resultHandler); + _bucketHandler.handleSetCurrentState(bucket.getBucketId().stripUnused(), newState, resultHandler); } void -PersistenceHandlerProxy::handleGetBucketInfo(const Bucket &bucket, - IBucketInfoResultHandler &resultHandler) +PersistenceHandlerProxy::handleGetBucketInfo(const Bucket &bucket, IBucketInfoResultHandler &resultHandler) { _bucketHandler.handleGetBucketInfo(bucket, resultHandler); } void -PersistenceHandlerProxy::handleCreateBucket(FeedToken token, - const Bucket &bucket) +PersistenceHandlerProxy::handleCreateBucket(FeedToken token, const Bucket &bucket) { - FeedOperation::UP op(new CreateBucketOperation(bucket.getBucketId(). - stripUnused())); + FeedOperation::UP op(new CreateBucketOperation(bucket.getBucketId().stripUnused())); _feedHandler.handleOperation(token, std::move(op)); } void -PersistenceHandlerProxy::handleDeleteBucket(FeedToken token, - const Bucket &bucket) +PersistenceHandlerProxy::handleDeleteBucket(FeedToken token, const Bucket &bucket) { - FeedOperation::UP op(new DeleteBucketOperation(bucket.getBucketId(). - stripUnused())); + FeedOperation::UP op(new DeleteBucketOperation(bucket.getBucketId().stripUnused())); _feedHandler.handleOperation(token, std::move(op)); } @@ -126,32 +106,20 @@ PersistenceHandlerProxy::handleGetModifiedBuckets(IBucketIdListResultHandler &re } void -PersistenceHandlerProxy::handleSplit(FeedToken token, - const Bucket &source, - const Bucket &target1, - const Bucket &target2) -{ - FeedOperation::UP op(new SplitBucketOperation(source.getBucketId(). - stripUnused(), - target1.getBucketId(). - stripUnused(), - target2.getBucketId(). - stripUnused())); +PersistenceHandlerProxy::handleSplit(FeedToken token, const Bucket &source, const Bucket &target1, const Bucket &target2) +{ + FeedOperation::UP op(new SplitBucketOperation(source.getBucketId().stripUnused(), + target1.getBucketId().stripUnused(), + target2.getBucketId().stripUnused())); _feedHandler.handleOperation(token, std::move(op)); } void -PersistenceHandlerProxy::handleJoin(FeedToken token, - const Bucket &source1, - const Bucket &source2, - const Bucket &target) -{ - FeedOperation::UP op(new JoinBucketsOperation(source1.getBucketId(). - stripUnused(), - source2.getBucketId(). - stripUnused(), - target.getBucketId(). - stripUnused())); +PersistenceHandlerProxy::handleJoin(FeedToken token, const Bucket &source1, const Bucket &source2, const Bucket &target) +{ + auto op = std::make_unique<JoinBucketsOperation>(source1.getBucketId().stripUnused(), + source2.getBucketId().stripUnused(), + target.getBucketId().stripUnused()); _feedHandler.handleOperation(token, std::move(op)); } @@ -168,16 +136,13 @@ PersistenceHandlerProxy::lockBucket(const storage::spi::Bucket &bucket) } void -PersistenceHandlerProxy::handleListActiveBuckets( - IBucketIdListResultHandler &resultHandler) +PersistenceHandlerProxy::handleListActiveBuckets(IBucketIdListResultHandler &resultHandler) { _bucketHandler.handleListActiveBuckets(resultHandler); } void -PersistenceHandlerProxy::handlePopulateActiveBuckets( - document::BucketId::List &buckets, - IGenericResultHandler &resultHandler) +PersistenceHandlerProxy::handlePopulateActiveBuckets(document::BucketId::List &buckets, IGenericResultHandler &resultHandler) { _bucketHandler.handlePopulateActiveBuckets(buckets, resultHandler); } diff --git a/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h b/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h index 499740de52a..3e3b3dd6fb6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h +++ b/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h @@ -22,68 +22,41 @@ public: virtual ~PersistenceHandlerProxy(); - /** - * Implements IPersistenceHandler. - */ - virtual void initialize() override; - virtual void handlePut(FeedToken token, - const storage::spi::Bucket &bucket, - storage::spi::Timestamp timestamp, - const document::Document::SP &doc) override; + void initialize() override; + void handlePut(FeedToken token, const storage::spi::Bucket &bucket, + storage::spi::Timestamp timestamp, const DocumentSP &doc) override; - virtual void handleUpdate(FeedToken token, - const storage::spi::Bucket &bucket, - storage::spi::Timestamp timestamp, - const document::DocumentUpdate::SP &upd) override; + void handleUpdate(FeedToken token, const storage::spi::Bucket &bucket, + storage::spi::Timestamp timestamp, const DocumentUpdateSP &upd) override; - virtual void handleRemove(FeedToken token, - const storage::spi::Bucket &bucket, - storage::spi::Timestamp timestamp, - const document::DocumentId &id) override; + void handleRemove(FeedToken token, const storage::spi::Bucket &bucket, + storage::spi::Timestamp timestamp, + const document::DocumentId &id) override; - virtual void handleListBuckets(IBucketIdListResultHandler &resultHandler) override; + void handleListBuckets(IBucketIdListResultHandler &resultHandler) override; + void handleSetClusterState(const storage::spi::ClusterState &calc, IGenericResultHandler &resultHandler) override; - virtual void handleSetClusterState(const storage::spi::ClusterState &calc, - IGenericResultHandler &resultHandler) override; + void handleSetActiveState(const storage::spi::Bucket &bucket, storage::spi::BucketInfo::ActiveState newState, + IGenericResultHandler &resultHandler) override; - virtual void handleSetActiveState(const storage::spi::Bucket &bucket, - storage::spi::BucketInfo::ActiveState newState, - IGenericResultHandler &resultHandler) override; + void handleGetBucketInfo(const storage::spi::Bucket &bucket, IBucketInfoResultHandler &resultHandler) override; + void handleCreateBucket(FeedToken token, const storage::spi::Bucket &bucket) override; + void handleDeleteBucket(FeedToken token, const storage::spi::Bucket &bucket) override; + void handleGetModifiedBuckets(IBucketIdListResultHandler &resultHandler) override; - virtual void handleGetBucketInfo(const storage::spi::Bucket &bucket, - IBucketInfoResultHandler &resultHandler) override; + void handleSplit(FeedToken token, const storage::spi::Bucket &source, + const storage::spi::Bucket &target1, const storage::spi::Bucket &target2) override; - virtual void - handleCreateBucket(FeedToken token, - const storage::spi::Bucket &bucket) override; + void handleJoin(FeedToken token, const storage::spi::Bucket &source, + const storage::spi::Bucket &target1, const storage::spi::Bucket &target2) override; - virtual void handleDeleteBucket(FeedToken token, - const storage::spi::Bucket &bucket) override; + RetrieversSP getDocumentRetrievers(storage::spi::ReadConsistency consistency) override; + BucketGuard::UP lockBucket(const storage::spi::Bucket &bucket) override; - virtual void handleGetModifiedBuckets(IBucketIdListResultHandler &resultHandler) override; + void handleListActiveBuckets(IBucketIdListResultHandler &resultHandler) override; - virtual void - handleSplit(FeedToken token, - const storage::spi::Bucket &source, - const storage::spi::Bucket &target1, - const storage::spi::Bucket &target2) override; - - virtual void - handleJoin(FeedToken token, - const storage::spi::Bucket &source, - const storage::spi::Bucket &target1, - const storage::spi::Bucket &target2) override; - - virtual RetrieversSP getDocumentRetrievers(storage::spi::ReadConsistency consistency) override; - virtual BucketGuard::UP lockBucket(const storage::spi::Bucket &bucket) override; - - virtual void - handleListActiveBuckets(IBucketIdListResultHandler &resultHandler) override; - - virtual void - handlePopulateActiveBuckets(document::BucketId::List &buckets, - IGenericResultHandler &resultHandler) override; + void handlePopulateActiveBuckets(document::BucketId::List &buckets, IGenericResultHandler &resultHandler) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp index da57f886364..ab47a72e899 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp @@ -14,6 +14,7 @@ #include <vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h> #include <vespa/document/datatype/documenttype.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/fieldvalue/document.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/log/log.h> diff --git a/searchcorespi/src/vespa/searchcorespi/index/iindexmanager.h b/searchcorespi/src/vespa/searchcorespi/index/iindexmanager.h index c529fe01dee..be439d499dd 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/iindexmanager.h +++ b/searchcorespi/src/vespa/searchcorespi/index/iindexmanager.h @@ -1,20 +1,15 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/document/fieldvalue/document.h> +#include "indexsearchable.h" #include <vespa/searchcommon/common/schema.h> #include <vespa/searchcorespi/flush/flushstats.h> #include <vespa/searchcorespi/flush/iflushtarget.h> #include <vespa/searchlib/common/serialnum.h> #include <vespa/vespalib/util/closure.h> -#include "indexsearchable.h" - -namespace search -{ - -class IDestructorCallback; -} +namespace search { class IDestructorCallback; } +namespace document { class Document; } namespace searchcorespi { diff --git a/searchlib/src/tests/docstore/document_store/document_store_test.cpp b/searchlib/src/tests/docstore/document_store/document_store_test.cpp index 2ab24a00557..0ef04d0e722 100644 --- a/searchlib/src/tests/docstore/document_store/document_store_test.cpp +++ b/searchlib/src/tests/docstore/document_store/document_store_test.cpp @@ -3,6 +3,7 @@ #include <vespa/searchlib/docstore/logdocumentstore.h> #include <vespa/searchlib/docstore/cachestats.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/fieldvalue/document.h> using namespace search; using CompressionConfig = vespalib::compression::CompressionConfig; diff --git a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp index ac645998198..0a3c3788c98 100644 --- a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp +++ b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp @@ -9,6 +9,7 @@ #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/datatype/documenttype.h> #include <vespa/document/repo/configbuilder.h> +#include <vespa/document/fieldvalue/document.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/threadstackexecutor.h> diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index ed99003c2f7..a22c44e843c 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -4,6 +4,7 @@ #include <vespa/document/repo/configbuilder.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/datatype/documenttype.h> +#include <vespa/document/fieldvalue/document.h> #include <vespa/searchlib/docstore/chunkformats.h> #include <vespa/searchlib/docstore/logdocumentstore.h> #include <vespa/searchlib/docstore/storebybucket.h> diff --git a/searchlib/src/vespa/searchlib/common/i_compactable_lid_space.h b/searchlib/src/vespa/searchlib/common/i_compactable_lid_space.h index 4c8e8a19456..ba28bec3604 100644 --- a/searchlib/src/vespa/searchlib/common/i_compactable_lid_space.h +++ b/searchlib/src/vespa/searchlib/common/i_compactable_lid_space.h @@ -2,8 +2,10 @@ #pragma once -namespace search { -namespace common { +#include <cstdint> +#include <cstddef> + +namespace search::common { /** * Interface for a component that has a lid space that can be compacted and shrunk. @@ -34,5 +36,3 @@ struct ICompactableLidSpace { }; } -} - diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp index 9b88383bbf1..59e92b112fa 100644 --- a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp @@ -4,6 +4,7 @@ #include "documentstore.h" #include "visitcache.h" #include "ibucketizer.h" +#include <vespa/document/fieldvalue/document.h> #include <vespa/vespalib/stllike/cache.hpp> #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/util/compressor.h> diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.h b/searchlib/src/vespa/searchlib/docstore/documentstore.h index e6e4364e6ab..08b042d99c5 100644 --- a/searchlib/src/vespa/searchlib/docstore/documentstore.h +++ b/searchlib/src/vespa/searchlib/docstore/documentstore.h @@ -3,7 +3,8 @@ #pragma once #include "idocumentstore.h" -#include "idatastore.h" +#include <vespa/vespalib/util/compressionconfig.h> + namespace search { @@ -62,7 +63,7 @@ public: DocumentStore(const Config & config, IDataStore & store); ~DocumentStore(); - document::Document::UP read(DocumentIdT lid, const document::DocumentTypeRepo &repo) const override; + DocumentUP read(DocumentIdT lid, const document::DocumentTypeRepo &repo) const override; void visit(const LidVector & lids, const document::DocumentTypeRepo &repo, IDocumentVisitor & visitor) const override; void write(uint64_t synkToken, DocumentIdT lid, const document::Document& doc) override; void write(uint64_t synkToken, DocumentIdT lid, const vespalib::nbostream & os) override; diff --git a/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp b/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp index a17f376d911..44708d11539 100644 --- a/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp @@ -1,16 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "idocumentstore.h" +#include <vespa/document/fieldvalue/document.h> namespace search { -IDocumentStore::IDocumentStore() -{ -} +IDocumentStore::IDocumentStore() = default; -IDocumentStore::~IDocumentStore() -{ -} +IDocumentStore::~IDocumentStore() = default; void IDocumentStore::visit(const LidVector & lids, const document::DocumentTypeRepo &repo, IDocumentVisitor & visitor) const { for (uint32_t lid : lids) { diff --git a/searchlib/src/vespa/searchlib/docstore/idocumentstore.h b/searchlib/src/vespa/searchlib/docstore/idocumentstore.h index a7302c9c1a5..d4827366619 100644 --- a/searchlib/src/vespa/searchlib/docstore/idocumentstore.h +++ b/searchlib/src/vespa/searchlib/docstore/idocumentstore.h @@ -2,12 +2,18 @@ #pragma once -#include <vespa/document/fieldvalue/document.h> +#include "idatastore.h" #include <vespa/searchlib/common/i_compactable_lid_space.h> -#include <vespa/searchlib/docstore/idatastore.h> #include <vespa/searchlib/query/base.h> #include <future> +namespace document { + class Document; + class DocumentTypeRepo; +} + +namespace vespalib { class nbostream; } + namespace search { class CacheStats; @@ -15,16 +21,18 @@ class CacheStats; class IDocumentStoreReadVisitor { public: + using DocumentSP = std::shared_ptr<document::Document>; virtual ~IDocumentStoreReadVisitor() { } - virtual void visit(uint32_t lid, const std::shared_ptr<document::Document> &doc) = 0; + virtual void visit(uint32_t lid, const DocumentSP &doc) = 0; virtual void visit(uint32_t lid) = 0; }; class IDocumentStoreRewriteVisitor { public: + using DocumentSP = std::shared_ptr<document::Document>; virtual ~IDocumentStoreRewriteVisitor() { } - virtual void visit(uint32_t lid, const std::shared_ptr<document::Document> &doc) = 0; + virtual void visit(uint32_t lid, const DocumentSP &doc) = 0; }; class IDocumentStoreVisitorProgress @@ -38,8 +46,9 @@ public: class IDocumentVisitor { public: + using DocumentUP = std::unique_ptr<document::Document>; virtual ~IDocumentVisitor() { } - virtual void visit(uint32_t lid, document::Document::UP doc) = 0; + virtual void visit(uint32_t lid, DocumentUP doc) = 0; virtual bool allowVisitCaching() const = 0; private: }; @@ -57,6 +66,7 @@ public: **/ using SP = std::shared_ptr<IDocumentStore>; using LidVector = std::vector<uint32_t>; + using DocumentUP = std::unique_ptr<document::Document>; /** @@ -74,7 +84,7 @@ public: * @param lid The local ID associated with the document. * @return NULL if there is no document associated with the lid. **/ - virtual document::Document::UP read(DocumentIdT lid, const document::DocumentTypeRepo &repo) const = 0; + virtual DocumentUP read(DocumentIdT lid, const document::DocumentTypeRepo &repo) const = 0; virtual void visit(const LidVector & lidVector, const document::DocumentTypeRepo &repo, IDocumentVisitor & visitor) const; /** diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.h b/searchlib/src/vespa/searchlib/docstore/visitcache.h index 5070f645557..eb035ac2a2c 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.h +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.h @@ -8,6 +8,8 @@ #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/vespalib/util/alloc.h> +#include <vespa/vespalib/util/memory.h> +#include <vespa/vespalib/util/compressionconfig.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/document/util/bytebuffer.h> diff --git a/storage/src/tests/bucketdb/bucketmanagertest.cpp b/storage/src/tests/bucketdb/bucketmanagertest.cpp index d42330086f0..d12e6b90b2a 100644 --- a/storage/src/tests/bucketdb/bucketmanagertest.cpp +++ b/storage/src/tests/bucketdb/bucketmanagertest.cpp @@ -5,6 +5,7 @@ #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/datatype/documenttype.h> #include <vespa/document/fieldvalue/document.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/storage/bucketdb/bucketmanager.h> #include <vespa/storage/persistence/filestorage/filestormanager.h> diff --git a/storage/src/tests/distributor/externaloperationhandlertest.cpp b/storage/src/tests/distributor/externaloperationhandlertest.cpp index fea4ae15efc..81b0293b0c0 100644 --- a/storage/src/tests/distributor/externaloperationhandlertest.cpp +++ b/storage/src/tests/distributor/externaloperationhandlertest.cpp @@ -6,6 +6,7 @@ #include <vespa/storage/distributor/distributormetricsset.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/document/test/make_document_bucket.h> using document::test::makeDocumentBucket; diff --git a/storage/src/tests/distributor/updateoperationtest.cpp b/storage/src/tests/distributor/updateoperationtest.cpp index 9de304db497..fd880effda9 100644 --- a/storage/src/tests/distributor/updateoperationtest.cpp +++ b/storage/src/tests/distributor/updateoperationtest.cpp @@ -8,6 +8,7 @@ #include <vespa/storageapi/message/bucket.h> #include <tests/distributor/distributortestutil.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/document/test/make_document_bucket.h> #include <vespa/storage/distributor/operations/external/updateoperation.h> #include <vespa/vespalib/testkit/test_kit.h> diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp index 396cc0d70de..f15921e447d 100644 --- a/storage/src/tests/persistence/persistencetestutils.cpp +++ b/storage/src/tests/persistence/persistencetestutils.cpp @@ -1,13 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include "persistencetestutils.h" #include <vespa/document/datatype/documenttype.h> #include <vespa/storageapi/message/persistence.h> -#include <tests/persistence/persistencetestutils.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/test/make_document_bucket.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> #include <vespa/persistence/spi/test.h> #include <vespa/document/update/assignvalueupdate.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/exceptions.h> diff --git a/storage/src/tests/persistence/persistencetestutils.h b/storage/src/tests/persistence/persistencetestutils.h index 22ab954cc6a..34d4c397f09 100644 --- a/storage/src/tests/persistence/persistencetestutils.h +++ b/storage/src/tests/persistence/persistencetestutils.h @@ -145,11 +145,11 @@ public: bool headerOnly) { return doGetOnDisk(0, bucketId, docId, headerOnly); } - document::DocumentUpdate::SP createBodyUpdate( + std::shared_ptr<document::DocumentUpdate> createBodyUpdate( const document::DocumentId& id, const document::FieldValue& updateValue); - document::DocumentUpdate::SP createHeaderUpdate( + std::shared_ptr<document::DocumentUpdate> createHeaderUpdate( const document::DocumentId& id, const document::FieldValue& updateValue); @@ -172,7 +172,7 @@ public: uint16_t disk = 0); spi::UpdateResult doUpdate(document::BucketId bid, - const document::DocumentUpdate::SP& update, + const std::shared_ptr<document::DocumentUpdate>& update, spi::Timestamp time, uint16_t disk = 0); diff --git a/storage/src/tests/persistence/testandsettest.cpp b/storage/src/tests/persistence/testandsettest.cpp index caf24c4a8fe..c729df1e7eb 100644 --- a/storage/src/tests/persistence/testandsettest.cpp +++ b/storage/src/tests/persistence/testandsettest.cpp @@ -6,6 +6,7 @@ #include <vespa/document/test/make_document_bucket.h> #include <vespa/documentapi/messagebus/messages/testandsetcondition.h> #include <vespa/document/fieldvalue/fieldvalues.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/document/update/assignvalueupdate.h> #include <vespa/persistence/spi/test.h> #include <functional> diff --git a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp index 170b5385f72..7df598bed97 100644 --- a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp +++ b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp @@ -13,6 +13,7 @@ #include <tests/common/testhelper.h> #include <tests/common/dummystoragelink.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/document/test/make_document_bucket.h> #include <vespa/storage/storageserver/changedbucketownershiphandler.h> diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp index 768e104e02b..0eeb4eeb84d 100644 --- a/storage/src/vespa/storage/persistence/persistencethread.cpp +++ b/storage/src/vespa/storage/persistence/persistencethread.cpp @@ -7,6 +7,7 @@ #include <vespa/storageapi/message/bucketsplitting.h> #include <vespa/storage/common/bucketoperationlogger.h> #include <vespa/document/fieldset/fieldsetrepo.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/util/exceptions.h> @@ -192,9 +193,8 @@ PersistenceThread::handleRepairBucket(RepairBucketCommand& cmd) LOG(debug, "Repair(%s): %s", cmd.getBucketId().toString().c_str(), (cmd.verifyBody() ? "Verifying body" : "Not verifying body")); api::BucketInfo before = _env.getBucketInfo(cmd.getBucket()); - spi::Result result = - _spi.maintain(spi::Bucket(cmd.getBucket(), spi::PartitionId(_env._partition)), - cmd.verifyBody() ? spi::HIGH : spi::LOW); + spi::Result result = _spi.maintain(spi::Bucket(cmd.getBucket(), spi::PartitionId(_env._partition)), + cmd.verifyBody() ? spi::HIGH : spi::LOW); if (checkForError(result, *tracker)) { api::BucketInfo after = _env.getBucketInfo(cmd.getBucket()); @@ -229,8 +229,7 @@ PersistenceThread::handleCreateBucket(api::CreateBucketCommand& cmd) auto tracker = std::make_unique<MessageTracker>(_env._metrics.createBuckets,_env._component.getClock()); LOG(debug, "CreateBucket(%s)", cmd.getBucketId().toString().c_str()); if (_env._fileStorHandler.isMerging(cmd.getBucket())) { - LOG(warning, "Bucket %s was merging at create time. Unexpected.", - cmd.getBucketId().toString().c_str()); + LOG(warning, "Bucket %s was merging at create time. Unexpected.", cmd.getBucketId().toString().c_str()); DUMP_LOGGED_BUCKET_OPERATIONS(cmd.getBucketId()); } spi::Bucket spiBucket(cmd.getBucket(), spi::PartitionId(_env._partition)); @@ -250,22 +249,18 @@ bool bucketStatesAreSemanticallyEqual(const api::BucketInfo& a, const api::Bucke // where Proton starts reporting actual document sizes, and will eventually // converge to a stable value. But for now, ignore it to prevent false positive // error logs and non-deleted buckets. - return ((a.getChecksum() == b.getChecksum()) - && (a.getDocumentCount() == b.getDocumentCount())); + return ((a.getChecksum() == b.getChecksum()) && (a.getDocumentCount() == b.getDocumentCount())); } } bool -PersistenceThread::checkProviderBucketInfoMatches(const spi::Bucket& bucket, - const api::BucketInfo& info) const +PersistenceThread::checkProviderBucketInfoMatches(const spi::Bucket& bucket, const api::BucketInfo& info) const { spi::BucketInfoResult result(_spi.getBucketInfo(bucket)); if (result.hasError()) { - LOG(error, - "getBucketInfo(%s) failed before deleting bucket; got error '%s'", - bucket.toString().c_str(), - result.getErrorMessage().c_str()); + LOG(error, "getBucketInfo(%s) failed before deleting bucket; got error '%s'", + bucket.toString().c_str(), result.getErrorMessage().c_str()); return false; } api::BucketInfo providerInfo(_env.convertBucketInfo(result.getBucketInfo())); @@ -280,9 +275,7 @@ PersistenceThread::checkProviderBucketInfoMatches(const spi::Bucket& bucket, "bucket has %s. Deletion has been rejected to ensure data is not " "lost, but bucket may remain out of sync until service has been " "restarted.", - bucket.toString().c_str(), - info.toString().c_str(), - providerInfo.toString().c_str()); + bucket.toString().c_str(), info.toString().c_str(), providerInfo.toString().c_str()); return false; } return true; @@ -387,9 +380,7 @@ PersistenceThread::handleCreateIterator(CreateIteratorCommand& cmd) MessageTracker::UP PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) { - MessageTracker::UP tracker(new MessageTracker( - _env._metrics.splitBuckets, - _env._component.getClock())); + auto tracker = std::make_unique<MessageTracker>(_env._metrics.splitBuckets,_env._component.getClock()); NotificationGuard notifyGuard(*_bucketOwnershipNotifier); // Calculate the various bucket ids involved. @@ -400,17 +391,15 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) } if (cmd.getMaxSplitBits() <= cmd.getBucketId().getUsedBits()) { tracker->fail(api::ReturnCode::ILLEGAL_PARAMETERS, - "Max lit bits must be set higher " - "than the number of bits used in the bucket to split"); + "Max lit bits must be set higher than the number of bits used in the bucket to split"); return tracker; } spi::Bucket spiBucket(cmd.getBucket(), spi::PartitionId(_env._partition)); SplitBitDetector::Result targetInfo; if (_env._config.enableMultibitSplitOptimalization) { - targetInfo = SplitBitDetector::detectSplit( - _spi, spiBucket, cmd.getMaxSplitBits(), - _context, cmd.getMinDocCount(), cmd.getMinByteSize()); + targetInfo = SplitBitDetector::detectSplit(_spi, spiBucket, cmd.getMaxSplitBits(), + _context, cmd.getMinDocCount(), cmd.getMinByteSize()); } if (targetInfo.empty() || !_env._config.enableMultibitSplitOptimalization) { document::BucketId src(cmd.getBucketId()); @@ -449,13 +438,10 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) } } #endif - spi::Result result = _spi.split( - spiBucket, - spi::Bucket(target1, spi::PartitionId(lock1.disk)), - spi::Bucket(target2, spi::PartitionId(lock2.disk)), _context); + spi::Result result = _spi.split(spiBucket, spi::Bucket(target1, spi::PartitionId(lock1.disk)), + spi::Bucket(target2, spi::PartitionId(lock2.disk)), _context); if (result.hasError()) { - tracker->fail(_env.convertErrorCode(result), - result.getErrorMessage()); + tracker->fail(_env.convertErrorCode(result), result.getErrorMessage()); return tracker; } // After split we need to take all bucket db locks to update them. @@ -466,8 +452,7 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) api::SplitBucketReply & splitReply = *reply; tracker->setReply(std::move(reply)); - typedef std::pair<StorBucketDatabase::WrappedEntry, - FileStorHandler::RemapInfo> TargetInfo; + typedef std::pair<StorBucketDatabase::WrappedEntry, FileStorHandler::RemapInfo> TargetInfo; std::vector<TargetInfo> targets; for (uint32_t i = 0; i < 2; i++) { const document::Bucket &target(i == 0 ? target1 : target2); @@ -478,8 +463,7 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) target.getBucketId(), "PersistenceThread::handleSplitBucket - Target", StorBucketDatabase::CREATE_IF_NONEXISTING), FileStorHandler::RemapInfo(target, disk))); - targets.back().first->setBucketInfo( - _env.getBucketInfo(target, disk)); + targets.back().first->setBucketInfo(_env.getBucketInfo(target, disk)); targets.back().first->disk = disk; } if (LOG_WOULD_LOG(spam)) { @@ -494,41 +478,30 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) targ2.getMetaCount()); } FileStorHandler::RemapInfo source(cmd.getBucket(), _env._partition); - _env._fileStorHandler.remapQueueAfterSplit( - source, targets[0].second, targets[1].second); - bool ownershipChanged( - !_bucketOwnershipNotifier->distributorOwns( - cmd.getSourceIndex(), cmd.getBucket())); + _env._fileStorHandler.remapQueueAfterSplit(source, targets[0].second, targets[1].second); + bool ownershipChanged(!_bucketOwnershipNotifier->distributorOwns(cmd.getSourceIndex(), cmd.getBucket())); // Now release all the bucketdb locks. for (uint32_t i = 0; i < targets.size(); i++) { if (ownershipChanged) { - notifyGuard.notifyAlways(targets[i].second.bucket, - targets[i].first->getBucketInfo()); + notifyGuard.notifyAlways(targets[i].second.bucket, targets[i].first->getBucketInfo()); } // The entries vector has the source bucket in element zero, so indexing // that with i+1 - if (targets[i].second.foundInQueue - || targets[i].first->getMetaCount() > 0) - { + if (targets[i].second.foundInQueue || targets[i].first->getMetaCount() > 0) { if (targets[i].first->getMetaCount() == 0) { // Fake that the bucket has content so it is not deleted. targets[i].first->info.setMetaCount(1); // Must make sure target bucket exists when we have pending ops // to an empty target bucket, since the provider will have // implicitly erased it by this point. - spi::Bucket createTarget( - spi::Bucket(targets[i].second.bucket, - spi::PartitionId(targets[i].second.diskIndex))); - LOG(debug, - "Split target %s was empty, but re-creating it since " - "there are remapped operations queued to it", + spi::Bucket createTarget(spi::Bucket(targets[i].second.bucket, + spi::PartitionId(targets[i].second.diskIndex))); + LOG(debug, "Split target %s was empty, but re-creating it since there are remapped operations queued to it", createTarget.toString().c_str()); _spi.createBucket(createTarget, _context); } - splitReply.getSplitInfo().push_back( - api::SplitBucketReply::Entry( - targets[i].second.bucket.getBucketId(), - targets[i].first->getBucketInfo())); + splitReply.getSplitInfo().emplace_back(targets[i].second.bucket.getBucketId(), + targets[i].first->getBucketInfo()); targets[i].first.write(); } else { targets[i].first.remove(); @@ -536,8 +509,7 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) } if (sourceEntry.exist()) { if (ownershipChanged) { - notifyGuard.notifyAlways(cmd.getBucket(), - sourceEntry->getBucketInfo()); + notifyGuard.notifyAlways(cmd.getBucket(), sourceEntry->getBucketInfo()); } // Delete the old entry. sourceEntry.remove(); @@ -546,30 +518,24 @@ PersistenceThread::handleSplitBucket(api::SplitBucketCommand& cmd) } bool -PersistenceThread::validateJoinCommand( - const api::JoinBucketsCommand& cmd, - MessageTracker& tracker) const +PersistenceThread::validateJoinCommand(const api::JoinBucketsCommand& cmd, MessageTracker& tracker) const { if (cmd.getSourceBuckets().size() != 2) { tracker.fail(ReturnCode::ILLEGAL_PARAMETERS, - "Join needs exactly two buckets to be joined together" - + cmd.getBucketId().toString()); + "Join needs exactly two buckets to be joined together" + cmd.getBucketId().toString()); return false; } // Verify that source and target buckets look sane. for (uint32_t i = 0; i < cmd.getSourceBuckets().size(); i++) { if (cmd.getSourceBuckets()[i] == cmd.getBucketId()) { tracker.fail(ReturnCode::ILLEGAL_PARAMETERS, - "Join had both source and target bucket " - + cmd.getBucketId().toString()); + "Join had both source and target bucket " + cmd.getBucketId().toString()); return false; } if (!cmd.getBucketId().contains(cmd.getSourceBuckets()[i])) { tracker.fail(ReturnCode::ILLEGAL_PARAMETERS, - "Source bucket " + - cmd.getSourceBuckets()[i].toString() - + " is not contained in target " - + cmd.getBucketId().toString()); + "Source bucket " + cmd.getSourceBuckets()[i].toString() + + " is not contained in target " + cmd.getBucketId().toString()); return false; } } @@ -579,9 +545,7 @@ PersistenceThread::validateJoinCommand( MessageTracker::UP PersistenceThread::handleJoinBuckets(api::JoinBucketsCommand& cmd) { - MessageTracker::UP tracker(new MessageTracker( - _env._metrics.joinBuckets, - _env._component.getClock())); + auto tracker = std::make_unique<MessageTracker>(_env._metrics.joinBuckets,_env._component.getClock()); if (!validateJoinCommand(cmd, *tracker)) { return tracker; } @@ -594,11 +558,8 @@ PersistenceThread::handleJoinBuckets(api::JoinBucketsCommand& cmd) { // Create empty bucket for target. StorBucketDatabase::WrappedEntry entry = - _env.getBucketDatabase(destBucket.getBucketSpace()).get( - destBucket.getBucketId(), - "join", - StorBucketDatabase::CREATE_IF_NONEXISTING); - + _env.getBucketDatabase(destBucket.getBucketSpace()).get(destBucket.getBucketId(), "join", + StorBucketDatabase::CREATE_IF_NONEXISTING); entry->disk = _env._partition; entry.write(); } @@ -644,13 +605,10 @@ PersistenceThread::handleJoinBuckets(api::JoinBucketsCommand& cmd) document::Bucket srcBucket(destBucket.getBucketSpace(), cmd.getSourceBuckets()[i]); uint16_t disk = (i == 0) ? lock1.disk : lock2.disk; FileStorHandler::RemapInfo target(cmd.getBucket(), _env._partition); - _env._fileStorHandler.remapQueueAfterJoin( - FileStorHandler::RemapInfo(srcBucket, disk), - target); + _env._fileStorHandler.remapQueueAfterJoin(FileStorHandler::RemapInfo(srcBucket, disk), target); // Remove source from bucket db. - StorBucketDatabase::WrappedEntry entry( - _env.getBucketDatabase(srcBucket.getBucketSpace()).get( - srcBucket.getBucketId(), "join-remove-source")); + StorBucketDatabase::WrappedEntry entry = + _env.getBucketDatabase(srcBucket.getBucketSpace()).get(srcBucket.getBucketId(), "join-remove-source"); if (entry.exist()) { lastModified = std::max(lastModified, entry->info.getLastModified()); entry.remove(); @@ -658,13 +616,10 @@ PersistenceThread::handleJoinBuckets(api::JoinBucketsCommand& cmd) } { StorBucketDatabase::WrappedEntry entry = - _env.getBucketDatabase(destBucket.getBucketSpace()).get( - destBucket.getBucketId(), - "join", - StorBucketDatabase::CREATE_IF_NONEXISTING); + _env.getBucketDatabase(destBucket.getBucketSpace()).get(destBucket.getBucketId(), "join", + StorBucketDatabase::CREATE_IF_NONEXISTING); if (entry->info.getLastModified() == 0) { - entry->info.setLastModified( - std::max(lastModified, entry->info.getLastModified())); + entry->info.setLastModified(std::max(lastModified, entry->info.getLastModified())); } entry.write(); } @@ -674,28 +629,21 @@ PersistenceThread::handleJoinBuckets(api::JoinBucketsCommand& cmd) MessageTracker::UP PersistenceThread::handleSetBucketState(api::SetBucketStateCommand& cmd) { - MessageTracker::UP tracker(new MessageTracker( - _env._metrics.setBucketStates, - _env._component.getClock())); + auto tracker = std::make_unique<MessageTracker>(_env._metrics.setBucketStates,_env._component.getClock()); NotificationGuard notifyGuard(*_bucketOwnershipNotifier); LOG(debug, "handleSetBucketState(): %s", cmd.toString().c_str()); spi::Bucket bucket(cmd.getBucket(), spi::PartitionId(_env._partition)); bool shouldBeActive(cmd.getState() == api::SetBucketStateCommand::ACTIVE); - spi::BucketInfo::ActiveState newState( - shouldBeActive - ? spi::BucketInfo::ACTIVE - : spi::BucketInfo::NOT_ACTIVE); + spi::BucketInfo::ActiveState newState(shouldBeActive ? spi::BucketInfo::ACTIVE : spi::BucketInfo::NOT_ACTIVE); spi::Result result(_spi.setActiveState(bucket, newState)); if (checkForError(result, *tracker)) { - StorBucketDatabase::WrappedEntry entry(_env.getBucketDatabase(bucket.getBucket().getBucketSpace()).get( - cmd.getBucketId(), "handleSetBucketState")); + StorBucketDatabase::WrappedEntry + entry = _env.getBucketDatabase(bucket.getBucket().getBucketSpace()).get(cmd.getBucketId(), "handleSetBucketState"); if (entry.exist()) { entry->info.setActive(newState == spi::BucketInfo::ACTIVE); - notifyGuard.notifyIfOwnershipChanged(cmd.getBucket(), - cmd.getSourceIndex(), - entry->info); + notifyGuard.notifyIfOwnershipChanged(cmd.getBucket(), cmd.getSourceIndex(), entry->info); entry.write(); } else { LOG(warning, "Got OK setCurrentState result from provider for %s, " @@ -703,8 +651,7 @@ PersistenceThread::handleSetBucketState(api::SetBucketStateCommand& cmd) cmd.getBucketId().toString().c_str()); } - tracker->setReply(api::StorageReply::SP( - new api::SetBucketStateReply(cmd))); + tracker->setReply(std::make_shared<api::SetBucketStateReply>(cmd)); } return tracker; @@ -713,17 +660,13 @@ PersistenceThread::handleSetBucketState(api::SetBucketStateCommand& cmd) MessageTracker::UP PersistenceThread::handleInternalBucketJoin(InternalBucketJoinCommand& cmd) { - MessageTracker::UP tracker(new MessageTracker( - _env._metrics.internalJoin, - _env._component.getClock())); + auto tracker = std::make_unique<MessageTracker>(_env._metrics.internalJoin,_env._component.getClock()); document::Bucket destBucket = cmd.getBucket(); { // Create empty bucket for target. StorBucketDatabase::WrappedEntry entry = _env.getBucketDatabase(destBucket.getBucketSpace()).get( - destBucket.getBucketId(), - "join", - StorBucketDatabase::CREATE_IF_NONEXISTING); + destBucket.getBucketId(), "join", StorBucketDatabase::CREATE_IF_NONEXISTING); entry->disk = _env._partition; entry.write(); @@ -734,10 +677,7 @@ PersistenceThread::handleInternalBucketJoin(InternalBucketJoinCommand& cmd) spi::Bucket(destBucket, spi::PartitionId(cmd.getDiskOfInstanceToKeep())), _context); if (checkForError(result, *tracker)) { - tracker->setReply( - api::StorageReply::SP( - new InternalBucketJoinReply(cmd, - _env.getBucketInfo(cmd.getBucket())))); + tracker->setReply(std::make_shared<InternalBucketJoinReply>(cmd, _env.getBucketInfo(cmd.getBucket()))); } return tracker; } @@ -745,17 +685,14 @@ PersistenceThread::handleInternalBucketJoin(InternalBucketJoinCommand& cmd) MessageTracker::UP PersistenceThread::handleRecheckBucketInfo(RecheckBucketInfoCommand& cmd) { - MessageTracker::UP tracker(new MessageTracker( - _env._metrics.recheckBucketInfo, _env._component.getClock())); + auto tracker = std::make_unique<MessageTracker>(_env._metrics.recheckBucketInfo, _env._component.getClock()); document::Bucket bucket(cmd.getBucket()); api::BucketInfo info(_env.getBucketInfo(bucket)); NotificationGuard notifyGuard(*_bucketOwnershipNotifier); { // Update bucket database StorBucketDatabase::WrappedEntry entry( - _component->getBucketDatabase(bucket.getBucketSpace()).get( - bucket.getBucketId(), - "handleRecheckBucketInfo")); + _component->getBucketDatabase(bucket.getBucketSpace()).get(bucket.getBucketId(), "handleRecheckBucketInfo")); if (entry.exist()) { api::BucketInfo prevInfo(entry->getBucketInfo()); @@ -799,30 +736,23 @@ PersistenceThread::handleCommandSplitByType(api::StorageCommand& msg) return handleSplitBucket(static_cast<api::SplitBucketCommand&>(msg)); // Depends on iterators case api::MessageType::STATBUCKET_ID: - return _processAllHandler.handleStatBucket( - static_cast<api::StatBucketCommand&>(msg), _context); + return _processAllHandler.handleStatBucket(static_cast<api::StatBucketCommand&>(msg), _context); case api::MessageType::REMOVELOCATION_ID: - return _processAllHandler.handleRemoveLocation( - static_cast<api::RemoveLocationCommand&>(msg), _context); + return _processAllHandler.handleRemoveLocation(static_cast<api::RemoveLocationCommand&>(msg), _context); case api::MessageType::MERGEBUCKET_ID: - return _mergeHandler.handleMergeBucket( - static_cast<api::MergeBucketCommand&>(msg), _context); + return _mergeHandler.handleMergeBucket(static_cast<api::MergeBucketCommand&>(msg), _context); case api::MessageType::GETBUCKETDIFF_ID: - return _mergeHandler.handleGetBucketDiff( - static_cast<api::GetBucketDiffCommand&>(msg), _context); + return _mergeHandler.handleGetBucketDiff(static_cast<api::GetBucketDiffCommand&>(msg), _context); case api::MessageType::APPLYBUCKETDIFF_ID: - return _mergeHandler.handleApplyBucketDiff( - static_cast<api::ApplyBucketDiffCommand&>(msg), _context); + return _mergeHandler.handleApplyBucketDiff(static_cast<api::ApplyBucketDiffCommand&>(msg), _context); case api::MessageType::SETBUCKETSTATE_ID: - return handleSetBucketState( - static_cast<api::SetBucketStateCommand&>(msg)); + return handleSetBucketState(static_cast<api::SetBucketStateCommand&>(msg)); case api::MessageType::INTERNAL_ID: switch(static_cast<api::InternalCommand&>(msg).getType()) { case GetIterCommand::ID: return handleGetIter(static_cast<GetIterCommand&>(msg)); case CreateIteratorCommand::ID: - return handleCreateIterator( - static_cast<CreateIteratorCommand&>(msg)); + return handleCreateIterator(static_cast<CreateIteratorCommand&>(msg)); case ReadBucketList::ID: return handleReadBucketList(static_cast<ReadBucketList&>(msg)); case ReadBucketInfo::ID: @@ -830,18 +760,13 @@ PersistenceThread::handleCommandSplitByType(api::StorageCommand& msg) case RepairBucketCommand::ID: return handleRepairBucket(static_cast<RepairBucketCommand&>(msg)); case BucketDiskMoveCommand::ID: - return _diskMoveHandler.handleBucketDiskMove( - static_cast<BucketDiskMoveCommand&>(msg), _context); + return _diskMoveHandler.handleBucketDiskMove(static_cast<BucketDiskMoveCommand&>(msg), _context); case InternalBucketJoinCommand::ID: - return handleInternalBucketJoin( - static_cast<InternalBucketJoinCommand&>(msg)); + return handleInternalBucketJoin(static_cast<InternalBucketJoinCommand&>(msg)); case RecheckBucketInfoCommand::ID: - return handleRecheckBucketInfo( - static_cast<RecheckBucketInfoCommand&>(msg)); + return handleRecheckBucketInfo(static_cast<RecheckBucketInfoCommand&>(msg)); default: - LOG(warning, - "Persistence thread received unhandled internal command %s", - msg.toString().c_str()); + LOG(warning, "Persistence thread received unhandled internal command %s", msg.toString().c_str()); break; } default: @@ -853,13 +778,11 @@ PersistenceThread::handleCommandSplitByType(api::StorageCommand& msg) MessageTracker::UP PersistenceThread::handleCommand(api::StorageCommand& msg) { - _context = spi::Context(msg.getLoadType(), msg.getPriority(), - msg.getTrace().getLevel()); + _context = spi::Context(msg.getLoadType(), msg.getPriority(), msg.getTrace().getLevel()); MessageTracker::UP mtracker(handleCommandSplitByType(msg)); if (mtracker.get() != 0) { if (mtracker->getReply().get() != 0) { - mtracker->getReply()->getTrace().getRoot().addChild( - _context.getTrace().getRoot()); + mtracker->getReply()->getTrace().getRoot().addChild(_context.getTrace().getRoot()); } else { msg.getTrace().getRoot().addChild(_context.getTrace().getRoot()); } @@ -872,14 +795,10 @@ PersistenceThread::handleReply(api::StorageReply& reply) { switch (reply.getType().getId()) { case api::MessageType::GETBUCKETDIFF_REPLY_ID: - _mergeHandler.handleGetBucketDiffReply( - static_cast<api::GetBucketDiffReply&>(reply), - _env._fileStorHandler); + _mergeHandler.handleGetBucketDiffReply(static_cast<api::GetBucketDiffReply&>(reply), _env._fileStorHandler); break; case api::MessageType::APPLYBUCKETDIFF_REPLY_ID: - _mergeHandler.handleApplyBucketDiffReply( - static_cast<api::ApplyBucketDiffReply&>(reply), - _env._fileStorHandler); + _mergeHandler.handleApplyBucketDiffReply(static_cast<api::ApplyBucketDiffReply&>(reply), _env._fileStorHandler); break; default: break; @@ -889,8 +808,7 @@ PersistenceThread::handleReply(api::StorageReply& reply) MessageTracker::UP PersistenceThread::processMessage(api::StorageMessage& msg) { - MBUS_TRACE(msg.getTrace(), 5, - "PersistenceThread: Processing message in persistence layer"); + MBUS_TRACE(msg.getTrace(), 5, "PersistenceThread: Processing message in persistence layer"); ++_env._metrics.operations; if (msg.getType().isReply()) { @@ -903,8 +821,7 @@ PersistenceThread::processMessage(api::StorageMessage& msg) LOG(debug, "Caught exception for %s: %s", msg.toString().c_str(), e.what()); } } else { - api::StorageCommand& initiatingCommand = - static_cast<api::StorageCommand&>(msg); + api::StorageCommand& initiatingCommand = static_cast<api::StorageCommand&>(msg); try { int64_t startTime(_component->getClock().getTimeInMillis().getTime()); @@ -913,8 +830,7 @@ PersistenceThread::processMessage(api::StorageMessage& msg) LOG(spam, "Message content: %s", msg.toString(true).c_str()); auto tracker(handleCommand(initiatingCommand)); if (!tracker.get()) { - LOG(debug, "Received unsupported command %s", - msg.getType().getName().c_str()); + LOG(debug, "Received unsupported command %s", msg.getType().getName().c_str()); } else { tracker->generateReply(initiatingCommand); if ((tracker->getReply().get() @@ -925,29 +841,21 @@ PersistenceThread::processMessage(api::StorageMessage& msg) } } - int64_t stopTime( - _component->getClock().getTimeInMillis().getTime()); + int64_t stopTime(_component->getClock().getTimeInMillis().getTime()); if (stopTime - startTime >= _warnOnSlowOperations) { LOGBT(warning, msg.getType().toString(), - "Slow processing of message %s on disk %u. " - "Processing time: %" PRId64 " ms (>=%d ms)", - msg.toString().c_str(), _env._partition, - stopTime - startTime, _warnOnSlowOperations); + "Slow processing of message %s on disk %u. Processing time: %" PRId64 " ms (>=%d ms)", + msg.toString().c_str(), _env._partition, stopTime - startTime, _warnOnSlowOperations); } else { - LOGBT(spam, msg.getType().toString(), - "Processing time of message %s on disk %u: %" PRId64 " ms", - msg.toString(true).c_str(), _env._partition, - stopTime - startTime); + LOGBT(spam, msg.getType().toString(), "Processing time of message %s on disk %u: %" PRId64 " ms", + msg.toString(true).c_str(), _env._partition, stopTime - startTime); } return tracker; } catch (std::exception& e) { - LOG(debug, "Caught exception for %s: %s", - msg.toString().c_str(), - e.what()); + LOG(debug, "Caught exception for %s: %s", msg.toString().c_str(), e.what()); api::StorageReply::SP reply(initiatingCommand.makeReply().release()); - reply->setResult(api::ReturnCode( - api::ReturnCode::INTERNAL_FAILURE, e.what())); + reply->setResult(api::ReturnCode(api::ReturnCode::INTERNAL_FAILURE, e.what())); _env._fileStorHandler.sendReply(reply); } } @@ -1016,8 +924,7 @@ PersistenceThread::flushAllReplies( uint32_t errorCode = _env.convertErrorCode(result); if (errorCode != 0) { for (uint32_t i = 0; i < replies.size(); ++i) { - replies[i]->getReply()->setResult( - api::ReturnCode((api::ReturnCode::Result)errorCode, result.getErrorMessage())); + replies[i]->getReply()->setResult(api::ReturnCode((api::ReturnCode::Result)errorCode, result.getErrorMessage())); } } } catch (std::exception& e) { @@ -1041,8 +948,7 @@ void PersistenceThread::processMessages(FileStorHandler::LockedMessage & lock) document::Bucket bucket = lock.first->getBucket(); while (lock.second) { - LOG(debug, "Inside while loop %d, nodeIndex %d, ptr=%p", - _env._partition, _env._nodeIndex, lock.second.get()); + LOG(debug, "Inside while loop %d, nodeIndex %d, ptr=%p", _env._partition, _env._nodeIndex, lock.second.get()); std::shared_ptr<api::StorageMessage> msg(lock.second); bool batchable = isBatchable(*msg); @@ -1077,7 +983,6 @@ void PersistenceThread::processMessages(FileStorHandler::LockedMessage & lock) } else { LOG(spam, "Sending reply up: %s %zu", tracker->getReply()->toString().c_str(), tracker->getReply()->getMsgId()); - _env._fileStorHandler.sendReply(tracker->getReply()); break; } diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp index a1be0def20b..44050264484 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp @@ -6,6 +6,7 @@ #include "storagereply.h" #include <vespa/storageapi/message/bucketsplitting.h> #include <vespa/storageapi/message/visitor.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/document/bucket/fixed_bucket_spaces.h> #include <sstream> diff --git a/storageapi/src/vespa/storageapi/message/persistence.cpp b/storageapi/src/vespa/storageapi/message/persistence.cpp index 10dbc9f1313..c1db27b4c1a 100644 --- a/storageapi/src/vespa/storageapi/message/persistence.cpp +++ b/storageapi/src/vespa/storageapi/message/persistence.cpp @@ -1,12 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "persistence.h" +#include <vespa/document/fieldvalue/document.h> +#include <vespa/document/update/documentupdate.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/asciistream.h> #include <ostream> -namespace storage { -namespace api { +namespace storage::api { IMPLEMENT_COMMAND(PutCommand, PutReply) IMPLEMENT_REPLY(PutReply) @@ -22,22 +23,25 @@ IMPLEMENT_REPLY(RevertReply) TestAndSetCommand::TestAndSetCommand(const MessageType & messageType, const document::Bucket &bucket) : BucketInfoCommand(messageType, bucket) {} -TestAndSetCommand::~TestAndSetCommand() { } +TestAndSetCommand::~TestAndSetCommand() = default; -PutCommand::PutCommand(const document::Bucket &bucket, - const document::Document::SP& doc, Timestamp time) +PutCommand::PutCommand(const document::Bucket &bucket, const DocumentSP& doc, Timestamp time) : TestAndSetCommand(MessageType::PUT, bucket), _doc(doc), _timestamp(time), _updateTimestamp(0) { if (_doc.get() == 0) { - throw vespalib::IllegalArgumentException( - "Cannot put a null document", VESPA_STRLOC); + throw vespalib::IllegalArgumentException("Cannot put a null document", VESPA_STRLOC); } } -PutCommand::~PutCommand() {} +PutCommand::~PutCommand() = default; + +const document::DocumentId& +PutCommand::getDocumentId() const { + return _doc->getId(); +} vespalib::string PutCommand::getSummary() const @@ -52,8 +56,7 @@ PutCommand::getSummary() const } void -PutCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const +PutCommand::print(std::ostream& out, bool verbose, const std::string& indent) const { out << "Put(" << getBucketId() << ", " << _doc->getId() << ", timestamp " << _timestamp << ", size " @@ -76,15 +79,13 @@ PutReply::PutReply(const PutCommand& cmd, bool wasFoundFlag) { } -PutReply::~PutReply() {} +PutReply::~PutReply() = default; void PutReply::print(std::ostream& out, bool verbose, - const std::string& indent) const + const std::string& indent) const { - out << "PutReply(" - << _docId.toString() << ", " << getBucketId() << ", timestamp " - << _timestamp; + out << "PutReply(" << _docId.toString() << ", " << getBucketId() << ", timestamp " << _timestamp; if (hasBeenRemapped()) { out << " (was remapped)"; @@ -97,28 +98,29 @@ PutReply::print(std::ostream& out, bool verbose, } } -UpdateCommand::UpdateCommand(const document::Bucket &bucket, - const document::DocumentUpdate::SP& update, - Timestamp time) +UpdateCommand::UpdateCommand(const document::Bucket &bucket, const document::DocumentUpdate::SP& update, Timestamp time) : TestAndSetCommand(MessageType::UPDATE, bucket), _update(update), _timestamp(time), _oldTimestamp(0) { if (_update.get() == 0) { - throw vespalib::IllegalArgumentException( - "Cannot update a null update", VESPA_STRLOC); + throw vespalib::IllegalArgumentException("Cannot update a null update", VESPA_STRLOC); } } -UpdateCommand::~UpdateCommand() {} +UpdateCommand::~UpdateCommand() = default; + +const document::DocumentId& +UpdateCommand::getDocumentId() const { + return _update->getId(); +} vespalib::string UpdateCommand::getSummary() const { vespalib::asciistream stream; stream << "Update(BucketId(0x" << vespalib::hex << getBucketId().getId() << "), " - << _update->getId().toString() - << ", timestamp " << vespalib::dec << _timestamp; + << _update->getId().toString() << ", timestamp " << vespalib::dec << _timestamp; if (_oldTimestamp != 0) { stream << ", old timestamp " << _oldTimestamp; } @@ -128,11 +130,9 @@ UpdateCommand::getSummary() const { } void -UpdateCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const +UpdateCommand::print(std::ostream& out, bool verbose, const std::string& indent) const { - out << "Update(" << getBucketId() << ", " << _update->getId() - << ", timestamp " << _timestamp; + out << "Update(" << getBucketId() << ", " << _update->getId() << ", timestamp " << _timestamp; if (_oldTimestamp != 0) { out << ", old timestamp " << _oldTimestamp; } @@ -154,11 +154,10 @@ UpdateReply::UpdateReply(const UpdateCommand& cmd, Timestamp oldTimestamp) { } -UpdateReply::~UpdateReply() {} +UpdateReply::~UpdateReply() = default; void -UpdateReply::print(std::ostream& out, bool verbose, - const std::string& indent) const +UpdateReply::print(std::ostream& out, bool verbose, const std::string& indent) const { out << "UpdateReply(" << _docId.toString() << ", " << getBucketId() << ", timestamp " @@ -176,8 +175,7 @@ UpdateReply::print(std::ostream& out, bool verbose, } } -GetCommand::GetCommand(const document::Bucket &bucket, - const document::DocumentId& docId, +GetCommand::GetCommand(const document::Bucket &bucket, const document::DocumentId& docId, const vespalib::stringref & fieldSet, Timestamp before) : BucketInfoCommand(MessageType::GET, bucket), _docId(docId), @@ -186,24 +184,21 @@ GetCommand::GetCommand(const document::Bucket &bucket, { } -GetCommand::~GetCommand() {} +GetCommand::~GetCommand() = default; vespalib::string GetCommand::getSummary() const { vespalib::asciistream stream; - stream << "Get(BucketId(" << vespalib::hex << getBucketId().getId() << "), " - << _docId.toString() - << ", beforetimestamp " << vespalib::dec << _beforeTimestamp - << ')'; + stream << "Get(BucketId(" << vespalib::hex << getBucketId().getId() << "), " << _docId.toString() + << ", beforetimestamp " << vespalib::dec << _beforeTimestamp << ')'; return stream.str(); } void -GetCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const +GetCommand::print(std::ostream& out, bool verbose, const std::string& indent) const { out << "Get(" << getBucketId() << ", " << _docId << ")"; if (verbose) { @@ -212,9 +207,7 @@ GetCommand::print(std::ostream& out, bool verbose, } } -GetReply::GetReply(const GetCommand& cmd, - const document::Document::SP& doc, - Timestamp lastModified) +GetReply::GetReply(const GetCommand& cmd, const DocumentSP& doc, Timestamp lastModified) : BucketInfoReply(cmd), _docId(cmd.getDocumentId()), _fieldSet(cmd.getFieldSet()), @@ -224,30 +217,26 @@ GetReply::GetReply(const GetCommand& cmd, { } -GetReply::~GetReply() {} +GetReply::~GetReply() = default; void -GetReply::print(std::ostream& out, bool verbose, - const std::string& indent) const +GetReply::print(std::ostream& out, bool verbose, const std::string& indent) const { - out << "GetReply(" << getBucketId() << ", " << _docId - << ", timestamp " << _lastModifiedTime << ")"; + out << "GetReply(" << getBucketId() << ", " << _docId << ", timestamp " << _lastModifiedTime << ")"; if (verbose) { out << " : "; BucketReply::print(out, verbose, indent); } } -RemoveCommand::RemoveCommand(const document::Bucket &bucket, - const document::DocumentId& docId, - Timestamp timestamp) +RemoveCommand::RemoveCommand(const document::Bucket &bucket, const document::DocumentId& docId, Timestamp timestamp) : TestAndSetCommand(MessageType::REMOVE, bucket), _docId(docId), _timestamp(timestamp) { } -RemoveCommand::~RemoveCommand() {} +RemoveCommand::~RemoveCommand() = default; vespalib::string RemoveCommand::getSummary() const { @@ -258,11 +247,9 @@ RemoveCommand::getSummary() const { return stream.str(); } void -RemoveCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const +RemoveCommand::print(std::ostream& out, bool verbose, const std::string& indent) const { - out << "Remove(" << getBucketId() << ", " << _docId - << ", timestamp " << _timestamp << ")"; + out << "Remove(" << getBucketId() << ", " << _docId << ", timestamp " << _timestamp << ")"; if (verbose) { out << " : "; BucketInfoCommand::print(out, verbose, indent); @@ -277,14 +264,12 @@ RemoveReply::RemoveReply(const RemoveCommand& cmd, Timestamp oldTimestamp) { } -RemoveReply::~RemoveReply() {} +RemoveReply::~RemoveReply() = default; void -RemoveReply::print(std::ostream& out, bool verbose, - const std::string& indent) const +RemoveReply::print(std::ostream& out, bool verbose, const std::string& indent) const { - out << "RemoveReply(" << getBucketId() << ", " << _docId - << ", timestamp " << _timestamp; + out << "RemoveReply(" << getBucketId() << ", " << _docId << ", timestamp " << _timestamp; if (_oldTimestamp != 0) { out << ", removed doc from " << _oldTimestamp; } else { @@ -297,18 +282,16 @@ RemoveReply::print(std::ostream& out, bool verbose, } } -RevertCommand::RevertCommand(const document::Bucket &bucket, - const std::vector<Timestamp>& revertTokens) +RevertCommand::RevertCommand(const document::Bucket &bucket, const std::vector<Timestamp>& revertTokens) : BucketInfoCommand(MessageType::REVERT, bucket), _tokens(revertTokens) { } -RevertCommand::~RevertCommand() {} +RevertCommand::~RevertCommand() = default; void -RevertCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const +RevertCommand::print(std::ostream& out, bool verbose, const std::string& indent) const { out << "Revert(" << getBucketId(); if (verbose) { @@ -330,11 +313,10 @@ RevertReply::RevertReply(const RevertCommand& cmd) { } -RevertReply::~RevertReply() {} +RevertReply::~RevertReply() = default; void -RevertReply::print(std::ostream& out, bool verbose, - const std::string& indent) const +RevertReply::print(std::ostream& out, bool verbose, const std::string& indent) const { out << "RevertReply(" << getBucketId() << ")"; if (verbose) { @@ -343,5 +325,4 @@ RevertReply::print(std::ostream& out, bool verbose, } } -} // api -} // storage +} diff --git a/storageapi/src/vespa/storageapi/message/persistence.h b/storageapi/src/vespa/storageapi/message/persistence.h index 60d10c40648..bda1bd0f038 100644 --- a/storageapi/src/vespa/storageapi/message/persistence.h +++ b/storageapi/src/vespa/storageapi/message/persistence.h @@ -6,21 +6,22 @@ */ #pragma once -#include <vespa/document/base/documentid.h> -#include <vespa/document/fieldvalue/document.h> -#include <vespa/document/update/documentupdate.h> #include <vespa/storageapi/messageapi/bucketinforeply.h> #include <vespa/storageapi/defs.h> +#include <vespa/document/base/documentid.h> #include <vespa/documentapi/messagebus/messages/testandsetcondition.h> -namespace storage { -namespace api { +namespace document { + class DocumentUpdate; + class Document; +} +namespace storage::api { using documentapi::TestAndSetCondition; +using DocumentSP = std::shared_ptr<document::Document>; class TestAndSetCommand : public BucketInfoCommand { TestAndSetCondition _condition; - public: TestAndSetCommand(const MessageType & messageType, const document::Bucket &bucket); ~TestAndSetCommand(); @@ -42,12 +43,12 @@ public: * @brief Command for adding a document to the storage system. */ class PutCommand : public TestAndSetCommand { - document::Document::SP _doc; - Timestamp _timestamp; - Timestamp _updateTimestamp; + DocumentSP _doc; + Timestamp _timestamp; + Timestamp _updateTimestamp; public: - PutCommand(const document::Bucket &bucket, const document::Document::SP&, Timestamp); + PutCommand(const document::Bucket &bucket, const DocumentSP&, Timestamp); ~PutCommand(); void setTimestamp(Timestamp ts) { _timestamp = ts; } @@ -60,8 +61,8 @@ public: void setUpdateTimestamp(Timestamp ts) { _updateTimestamp = ts; } Timestamp getUpdateTimestamp() const { return _updateTimestamp; } - const document::Document::SP& getDocument() const { return _doc; } - const document::DocumentId& getDocumentId() const override { return _doc->getId(); } + const DocumentSP& getDocument() const { return _doc; } + const document::DocumentId& getDocumentId() const override; Timestamp getTimestamp() const { return _timestamp; } vespalib::string getSummary() const override; @@ -78,7 +79,7 @@ public: */ class PutReply : public BucketInfoReply { document::DocumentId _docId; - document::Document::SP _document; // Not serialized + DocumentSP _document; // Not serialized Timestamp _timestamp; Timestamp _updateTimestamp; bool _wasFound; @@ -89,7 +90,7 @@ public: const document::DocumentId& getDocumentId() const { return _docId; } bool hasDocument() const { return _document.get(); } - const document::Document::SP& getDocument() const { return _document; } + const DocumentSP& getDocument() const { return _document; } Timestamp getTimestamp() const { return _timestamp; }; Timestamp getUpdateTimestamp() const { return _updateTimestamp; } @@ -108,21 +109,20 @@ public: * @brief Command for updating a document to the storage system. */ class UpdateCommand : public TestAndSetCommand { - document::DocumentUpdate::SP _update; + std::shared_ptr<document::DocumentUpdate> _update; Timestamp _timestamp; Timestamp _oldTimestamp; public: UpdateCommand(const document::Bucket &bucket, - const document::DocumentUpdate::SP&, Timestamp); + const std::shared_ptr<document::DocumentUpdate>&, Timestamp); ~UpdateCommand(); void setTimestamp(Timestamp ts) { _timestamp = ts; } void setOldTimestamp(Timestamp ts) { _oldTimestamp = ts; } - const document::DocumentUpdate::SP& getUpdate() const { return _update; } - const document::DocumentId& getDocumentId() const override - { return _update->getId(); } + const std::shared_ptr<document::DocumentUpdate>& getUpdate() const { return _update; } + const document::DocumentId& getDocumentId() const override; Timestamp getTimestamp() const { return _timestamp; } Timestamp getOldTimestamp() const { return _oldTimestamp; } @@ -211,17 +211,17 @@ public: class GetReply : public BucketInfoReply { document::DocumentId _docId; // In case of not found, we want id still vespalib::string _fieldSet; - document::Document::SP _doc; // Null pointer if not found + DocumentSP _doc; // Null pointer if not found Timestamp _beforeTimestamp; Timestamp _lastModifiedTime; public: GetReply(const GetCommand& cmd, - const document::Document::SP& doc = document::Document::SP(), + const DocumentSP& doc = DocumentSP(), Timestamp lastModified = 0); ~GetReply(); - const document::Document::SP& getDocument() const { return _doc; } + const DocumentSP& getDocument() const { return _doc; } const document::DocumentId& getDocumentId() const { return _docId; } const vespalib::string& getFieldSet() const { return _fieldSet; } @@ -311,5 +311,4 @@ public: DECLARE_STORAGEREPLY(RevertReply, onRevertReply) }; -} // api -} // storage +} diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h index 25fa01758ca..814ae33bfe3 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h +++ b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h @@ -14,8 +14,7 @@ #include "bucketcommand.h" -namespace storage { -namespace api { +namespace storage::api { class BucketInfoCommand : public BucketCommand { protected: @@ -27,6 +26,5 @@ public: void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; -} // api -} // storage +} diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h index d4308f2d4e4..5b784267da2 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h +++ b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h @@ -16,15 +16,13 @@ #include "bucketinfocommand.h" #include <vespa/storageapi/buckets/bucketinfo.h> -namespace storage { -namespace api { +namespace storage::api { class BucketInfoReply : public BucketReply { BucketInfo _result; protected: - BucketInfoReply(const BucketInfoCommand& cmd, - const ReturnCode& code = ReturnCode(ReturnCode::OK)); + BucketInfoReply(const BucketInfoCommand& cmd, const ReturnCode& code = ReturnCode(ReturnCode::OK)); public: DECLARE_POINTER_TYPEDEFS(BucketInfoReply); @@ -34,5 +32,4 @@ public: void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; -} // api -} // storage +} diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h index b0f98d91152..5b4e6963fd9 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h +++ b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h @@ -10,8 +10,7 @@ #include "storagereply.h" -namespace storage { -namespace api { +namespace storage::api { class BucketCommand; @@ -20,23 +19,20 @@ class BucketReply : public StorageReply { document::BucketId _originalBucket; protected: - BucketReply(const BucketCommand& cmd, - const ReturnCode& code = ReturnCode(ReturnCode::OK)); + BucketReply(const BucketCommand& cmd, const ReturnCode& code = ReturnCode(ReturnCode::OK)); public: DECLARE_POINTER_TYPEDEFS(BucketReply); document::Bucket getBucket() const override { return _bucket; } - virtual bool hasSingleBucketId() const override { return true; } + bool hasSingleBucketId() const override { return true; } bool hasBeenRemapped() const { return (_originalBucket.getRawId() != 0); } - const document::BucketId& getOriginalBucketId() const - { return _originalBucket; } + const document::BucketId& getOriginalBucketId() const { return _originalBucket; } /** The deserialization code need access to set the remapping. */ void remapBucketId(const document::BucketId& bucket); void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; -} // api -} // storage +} |