From cbf4dd2d3c91185d9dc02d09a75cef8aa5d09afd Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 11 Oct 2024 20:49:53 +0200 Subject: [PATCH] Make it clearer when values are passed by reference. --- .../tests/proton/common/index_writer_test.cpp | 4 +- .../documentdb/combiningfeedview_test.cpp | 10 ++-- .../feedhandler/feedhandler_test.cpp | 6 +- .../tests/proton/documentdb/feedview_test.cpp | 20 +++---- .../documentdb/storeonlyfeedview_test.cpp | 16 ++--- .../proton/attribute/attribute_writer.cpp | 56 ++++++++--------- .../proton/attribute/attribute_writer.h | 20 +++---- .../proton/attribute/i_attribute_writer.h | 18 +++--- .../searchcore/proton/index/i_index_writer.h | 4 +- .../searchcore/proton/index/index_writer.cpp | 4 +- .../searchcore/proton/index/index_writer.h | 4 +- .../searchcore/proton/index/indexmanager.h | 4 +- .../proton/index/memoryindexwrapper.h | 4 +- .../proton/server/combiningfeedview.cpp | 12 ++-- .../proton/server/combiningfeedview.h | 12 ++-- .../proton/server/fast_access_feed_view.cpp | 16 ++--- .../proton/server/fast_access_feed_view.h | 16 ++--- .../searchcore/proton/server/ifeedview.h | 14 ++--- .../proton/server/searchable_feed_view.cpp | 28 ++++----- .../proton/server/searchable_feed_view.h | 28 ++++----- .../proton/server/storeonlyfeedview.cpp | 52 ++++++++-------- .../proton/server/storeonlyfeedview.h | 60 +++++++++---------- .../searchcore/proton/test/dummy_feed_view.h | 12 ++-- .../proton/test/mock_index_manager.h | 4 +- .../proton/test/mock_index_writer.h | 4 +- .../vespa/searchcorespi/index/iindexmanager.h | 6 +- .../vespa/searchcorespi/index/imemoryindex.h | 6 +- .../searchcorespi/index/indexmaintainer.cpp | 4 +- .../searchcorespi/index/indexmaintainer.h | 4 +- .../memoryindex/document_inverter.cpp | 4 +- .../searchlib/memoryindex/document_inverter.h | 6 +- .../searchlib/memoryindex/invert_task.cpp | 2 +- .../vespa/searchlib/memoryindex/invert_task.h | 6 +- .../searchlib/memoryindex/memory_index.cpp | 4 +- .../searchlib/memoryindex/memory_index.h | 6 +- .../vespa/searchlib/memoryindex/push_task.cpp | 2 +- .../vespa/searchlib/memoryindex/push_task.h | 6 +- 37 files changed, 242 insertions(+), 242 deletions(-) diff --git a/searchcore/src/tests/proton/common/index_writer_test.cpp b/searchcore/src/tests/proton/common/index_writer_test.cpp index 9f39d6ec66d9..72636c010d8f 100644 --- a/searchcore/src/tests/proton/common/index_writer_test.cpp +++ b/searchcore/src/tests/proton/common/index_writer_test.cpp @@ -51,7 +51,7 @@ struct MyIndexManager : public proton::test::MockIndexManager return toString(removes[lid]); } // Implements IIndexManager - void putDocument(uint32_t lid, const Document &, SerialNum serialNum, OnWriteDoneType) override { + void putDocument(uint32_t lid, const Document &, SerialNum serialNum, const OnWriteDoneType&) override { puts[lid].push_back(serialNum); } void removeDocuments(LidVector lids, SerialNum serialNum) override { @@ -59,7 +59,7 @@ struct MyIndexManager : public proton::test::MockIndexManager removes[lid].push_back(serialNum); } } - void commit(SerialNum serialNum, OnWriteDoneType) override { + void commit(SerialNum serialNum, const OnWriteDoneType&) override { commitSerial = serialNum; } SerialNum getCurrentSerialNum() const override { diff --git a/searchcore/src/tests/proton/documentdb/combiningfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/combiningfeedview_test.cpp index 6ac2ccc0a9be..6ca58f2edda2 100644 --- a/searchcore/src/tests/proton/documentdb/combiningfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/combiningfeedview_test.cpp @@ -71,12 +71,12 @@ struct MyFeedView : public test::DummyFeedView void prepareRemove(RemoveOperation &) override { ++_prepareRemove; } void handleRemove(FeedToken, const RemoveOperation &) override { ++_handleRemove; } void prepareDeleteBucket(DeleteBucketOperation &) override { ++_prepareDeleteBucket; } - void handleDeleteBucket(const DeleteBucketOperation &, DoneCallback) override { ++_handleDeleteBucket; } + void handleDeleteBucket(const DeleteBucketOperation &, const DoneCallback&) override { ++_handleDeleteBucket; } void prepareMove(MoveOperation &) override { ++_prepareMove; } - void handleMove(const MoveOperation &, DoneCallback) override { ++_handleMove; } - void heartBeat(SerialNum, DoneCallback) override { ++_heartBeat; } - void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &, DoneCallback) override { ++_handlePrune; } - void handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback) override { + void handleMove(const MoveOperation &, const DoneCallback&) override { ++_handleMove; } + void heartBeat(SerialNum, const DoneCallback&) override { ++_heartBeat; } + void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &, const DoneCallback&) override { ++_handlePrune; } + void handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback&) override { _wantedLidLimit = op.getLidLimit(); } }; diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 7f319549e62b..f0ab172c574d 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -253,9 +253,9 @@ struct MyFeedView : public test::DummyFeedView { (void) token; ++remove_count; } - void handleMove(const MoveOperation &, DoneCallback) override { ++move_count; } - void heartBeat(SerialNum, DoneCallback) override { ++heartbeat_count; } - void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &, DoneCallback) override { ++prune_removed_count; } + void handleMove(const MoveOperation &, const DoneCallback&) override { ++move_count; } + void heartBeat(SerialNum, const DoneCallback&) override { ++heartbeat_count; } + void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &, const DoneCallback&) override { ++prune_removed_count; } const ISimpleDocumentMetaStore *getDocumentMetaStorePtr() const override { return nullptr; } diff --git a/searchcore/src/tests/proton/documentdb/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview_test.cpp index d6378a38a6c0..c4a60fd59bc0 100644 --- a/searchcore/src/tests/proton/documentdb/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview_test.cpp @@ -159,7 +159,7 @@ struct MyIndexWriter : public test::MockIndexWriter _wantedLidLimit(0), _tracer(tracer) {} - void put(SerialNum serialNum, const document::Document &doc, const DocumentIdT lid, OnWriteDoneType) override { + void put(SerialNum serialNum, const document::Document &doc, const DocumentIdT lid, const OnWriteDoneType&) override { (void) doc; _tracer.tracePut(indexAdapterTypeName, serialNum, lid); } @@ -170,7 +170,7 @@ struct MyIndexWriter : public test::MockIndexWriter _tracer.traceRemove(indexAdapterTypeName, serialNum, lid); } } - void commit(SerialNum serialNum, OnWriteDoneType) override { + void commit(SerialNum serialNum, const OnWriteDoneType&) override { ++_commitCount; _tracer.traceCommit(indexAdapterTypeName, serialNum); } @@ -343,18 +343,18 @@ struct MyAttributeWriter : public IAttributeWriter auto itr = _attrMap.find(attrName); return ((itr == _attrMap.end()) ? nullptr : itr->second.get()); } - void put(SerialNum serialNum, const document::Document &doc, DocumentIdT lid, OnWriteDoneType) override { + void put(SerialNum serialNum, const document::Document &doc, DocumentIdT lid, const OnWriteDoneType&) override { _putSerial = serialNum; _putDocId = doc.getId(); _putLid = lid; _tracer.tracePut(attributeAdapterTypeName, serialNum, lid); } - void remove(SerialNum serialNum, DocumentIdT lid, OnWriteDoneType) override { + void remove(SerialNum serialNum, DocumentIdT lid, const OnWriteDoneType&) override { _removeSerial = serialNum; _removeLid = lid; _tracer.traceRemove(attributeAdapterTypeName, serialNum, lid); } - void remove(const LidVector & lidsToRemove, SerialNum serialNum, OnWriteDoneType) override { + void remove(const LidVector & lidsToRemove, SerialNum serialNum, const OnWriteDoneType&) override { for (uint32_t lid : lidsToRemove) { LOG(info, "MyAttributeAdapter::remove(): serialNum(%" PRIu64 "), docId(%u)", serialNum, lid); _removes.push_back(lid); @@ -362,7 +362,7 @@ struct MyAttributeWriter : public IAttributeWriter } } void update(SerialNum serialNum, const document::DocumentUpdate &upd, - DocumentIdT lid, OnWriteDoneType, IFieldUpdateCallback & onUpdate) override { + DocumentIdT lid, const OnWriteDoneType&, IFieldUpdateCallback & onUpdate) override { _updateSerial = serialNum; _updateDocId = upd.getId(); _updateLid = lid; @@ -371,23 +371,23 @@ struct MyAttributeWriter : public IAttributeWriter onUpdate.onUpdateField(fieldUpdate.getField(), attr); } } - void update(SerialNum serialNum, const document::Document &doc, DocumentIdT lid, OnWriteDoneType) override { + void update(SerialNum serialNum, const document::Document &doc, DocumentIdT lid, const OnWriteDoneType&) override { (void) serialNum; (void) doc; (void) lid; } - void heartBeat(SerialNum, OnWriteDoneType) override { ++_heartBeatCount; } + void heartBeat(SerialNum, const OnWriteDoneType&) override { ++_heartBeatCount; } void compactLidSpace(uint32_t wantedLidLimit, SerialNum ) override { _wantedLidLimit = wantedLidLimit; } const proton::IAttributeManager::SP &getAttributeManager() const override { return _mgr; } - void forceCommit(const CommitParam & param, OnWriteDoneType) override { + void forceCommit(const CommitParam & param, const OnWriteDoneType&) override { ++_commitCount; _tracer.traceCommit(attributeAdapterTypeName, param.lastSerialNum()); } - void drain(OnWriteDoneType onDone) override { + void drain(const OnWriteDoneType& onDone) override { (void) onDone; } diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp index 8006fffe8e81..f1e1afb05ff8 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp @@ -104,19 +104,19 @@ struct MyMinimalFeedView : public MyMinimalFeedViewBase, public StoreOnlyFeedVie outstandingMoveOps(outstandingMoveOps_) { } - void removeAttributes(SerialNum s, const LidVector &l, OnWriteDoneType onWriteDone) override { + void removeAttributes(SerialNum s, const LidVector &l, const OnWriteDoneType& onWriteDone) override { StoreOnlyFeedView::removeAttributes(s, l, onWriteDone); ++removeMultiAttributesCount; } - void removeIndexedFields(SerialNum s, const LidVector &l, OnWriteDoneType onWriteDone) override { + void removeIndexedFields(SerialNum s, const LidVector &l, const OnWriteDoneType& onWriteDone) override { StoreOnlyFeedView::removeIndexedFields(s, l, onWriteDone); ++removeMultiIndexFieldsCount; } - void heartBeatIndexedFields(SerialNum s, DoneCallback onDone) override { + void heartBeatIndexedFields(SerialNum s, const DoneCallback& onDone) override { StoreOnlyFeedView::heartBeatIndexedFields(s, onDone); ++heartBeatIndexedFieldsCount; } - void heartBeatAttributes(SerialNum s, DoneCallback onDone) override { + void heartBeatAttributes(SerialNum s, const DoneCallback& onDone) override { StoreOnlyFeedView::heartBeatAttributes(s, onDone); ++heartBeatAttributesCount; } @@ -146,26 +146,26 @@ struct MoveOperationFeedView : public MyMinimalFeedView { onWriteDoneContexts() {} ~MoveOperationFeedView() override; - void putAttributes(SerialNum, search::DocumentIdT, const document::Document &, OnPutDoneType onWriteDone) override { + void putAttributes(SerialNum, search::DocumentIdT, const document::Document &, const OnPutDoneType& onWriteDone) override { ++putAttributesCount; EXPECT_EQUAL(1, outstandingMoveOps); std::lock_guard guard(_mutex); onWriteDoneContexts.push_back(onWriteDone); } void putIndexedFields(SerialNum, search::DocumentIdT, const document::Document::SP &, - OnOperationDoneType onWriteDone) override { + const OnOperationDoneType& onWriteDone) override { ++putIndexFieldsCount; EXPECT_EQUAL(1, outstandingMoveOps); std::lock_guard guard(_mutex); onWriteDoneContexts.push_back(onWriteDone); } - void removeAttributes(SerialNum, search::DocumentIdT, OnRemoveDoneType onWriteDone) override { + void removeAttributes(SerialNum, search::DocumentIdT, const OnRemoveDoneType& onWriteDone) override { ++removeAttributesCount; EXPECT_EQUAL(1, outstandingMoveOps); std::lock_guard guard(_mutex); onWriteDoneContexts.push_back(onWriteDone); } - void removeIndexedFields(SerialNum, search::DocumentIdT, OnRemoveDoneType onWriteDone) override { + void removeIndexedFields(SerialNum, search::DocumentIdT, const OnRemoveDoneType& onWriteDone) override { ++removeIndexFieldsCount; EXPECT_EQUAL(1, outstandingMoveOps); std::lock_guard guard(_mutex); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp index 4849dc5a9a43..c5c4c731c4c0 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp @@ -158,7 +158,7 @@ ensureLidSpace(SerialNum serialNum, DocumentIdT lid, AttributeVector &attr) void applyPutToAttribute(SerialNum serialNum, const FieldValue::UP &fieldValue, DocumentIdT lid, - AttributeVector &attr, AttributeWriter::OnWriteDoneType) + AttributeVector &attr, const AttributeWriter::OnWriteDoneType&) { ensureLidSpace(serialNum, lid, attr); if (fieldValue.get()) { @@ -199,7 +199,7 @@ complete_put_to_attribute(SerialNum serial_num, uint32_t docid, AttributeVector& attr, std::future result_future, - AttributeWriter::OnWriteDoneType) + const AttributeWriter::OnWriteDoneType&) { ensureLidSpace(serial_num, docid, attr); auto result = result_future.get(); @@ -213,7 +213,7 @@ complete_put_to_attribute(SerialNum serial_num, void applyRemoveToAttribute(SerialNum serialNum, DocumentIdT lid, - AttributeVector &attr, AttributeWriter::OnWriteDoneType) + AttributeVector &attr, const AttributeWriter::OnWriteDoneType&) { ensureLidSpace(serialNum, lid, attr); attr.clearDoc(lid); @@ -246,7 +246,7 @@ applyHeartBeat(SerialNum serialNum, AttributeVector &attr) } void -applyCommit(CommitParam param, AttributeWriter::OnWriteDoneType , AttributeVector &attr) +applyCommit(CommitParam param, const AttributeWriter::OnWriteDoneType& , AttributeVector &attr) { SerialNum serialNum = param.lastSerialNum(); if (attr.getStatus().getLastSyncToken() <= serialNum) { @@ -342,15 +342,15 @@ class PutTask : public vespalib::Executor::Task const SerialNum _serialNum; const uint32_t _lid; const bool _allAttributes; - std::remove_reference_t _onWriteDone; + const AttributeWriter::OnWriteDoneType _onWriteDone; const Document& _doc; public: - PutTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, const Document& doc, uint32_t lid, bool allAttributes, AttributeWriter::OnWriteDoneType onWriteDone); + PutTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, const Document& doc, uint32_t lid, bool allAttributes, const AttributeWriter::OnWriteDoneType& onWriteDone); ~PutTask() override; void run() override; }; -PutTask::PutTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, const Document& doc, uint32_t lid, bool allAttributes, AttributeWriter::OnWriteDoneType onWriteDone) +PutTask::PutTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, const Document& doc, uint32_t lid, bool allAttributes, const AttributeWriter::OnWriteDoneType& onWriteDone) : _wc(wc), _serialNum(serialNum), _lid(lid), @@ -461,17 +461,17 @@ class CompletePutTask : public vespalib::Executor::Task { const uint32_t _docid; AttributeVector& _attr; std::future _result_future; - std::remove_reference_t _on_write_done; + const AttributeWriter::OnWriteDoneType _on_write_done; public: CompletePutTask(PreparePutTask& prepare_task, - AttributeWriter::OnWriteDoneType on_write_done); + const AttributeWriter::OnWriteDoneType& on_write_done); ~CompletePutTask() override; void run() override; }; CompletePutTask::CompletePutTask(PreparePutTask& prepare_task, - AttributeWriter::OnWriteDoneType on_write_done) + const AttributeWriter::OnWriteDoneType& on_write_done) : _serial_num(prepare_task.serial_num()), _docid(prepare_task.docid()), _attr(prepare_task.attr()), @@ -495,14 +495,14 @@ class RemoveTask : public vespalib::Executor::Task const AttributeWriter::WriteContext &_wc; const SerialNum _serialNum; const uint32_t _lid; - std::remove_reference_t _onWriteDone; + const AttributeWriter::OnWriteDoneType _onWriteDone; public: - RemoveTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, uint32_t lid, AttributeWriter::OnWriteDoneType onWriteDone); + RemoveTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, uint32_t lid, const AttributeWriter::OnWriteDoneType& onWriteDone); ~RemoveTask() override; void run() override; }; -RemoveTask::RemoveTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, uint32_t lid, AttributeWriter::OnWriteDoneType onWriteDone) +RemoveTask::RemoveTask(const AttributeWriter::WriteContext &wc, SerialNum serialNum, uint32_t lid, const AttributeWriter::OnWriteDoneType& onWriteDone) : _wc(wc), _serialNum(serialNum), _lid(lid), @@ -530,12 +530,12 @@ class BatchRemoveTask : public vespalib::Executor::Task const AttributeWriter::WriteContext &_writeCtx; const SerialNum _serialNum; const LidVector _lidsToRemove; - std::remove_reference_t _onWriteDone; + const AttributeWriter::OnWriteDoneType _onWriteDone; public: BatchRemoveTask(const AttributeWriter::WriteContext &writeCtx, SerialNum serialNum, const LidVector &lidsToRemove, - AttributeWriter::OnWriteDoneType onWriteDone) + const AttributeWriter::OnWriteDoneType& onWriteDone) : _writeCtx(writeCtx), _serialNum(serialNum), _lidsToRemove(lidsToRemove), @@ -561,15 +561,15 @@ class CommitTask : public vespalib::Executor::Task { const AttributeWriter::WriteContext &_wc; const CommitParam _param; - std::remove_reference_t _onWriteDone; + const AttributeWriter::OnWriteDoneType _onWriteDone; public: - CommitTask(const AttributeWriter::WriteContext &wc, CommitParam param, AttributeWriter::OnWriteDoneType onWriteDone); + CommitTask(const AttributeWriter::WriteContext &wc, CommitParam param, const AttributeWriter::OnWriteDoneType& onWriteDone); ~CommitTask() override; void run() override; }; -CommitTask::CommitTask(const AttributeWriter::WriteContext &wc, CommitParam param, AttributeWriter::OnWriteDoneType onWriteDone) +CommitTask::CommitTask(const AttributeWriter::WriteContext &wc, CommitParam param, const AttributeWriter::OnWriteDoneType& onWriteDone) : _wc(wc), _param(param), _onWriteDone(onWriteDone) @@ -624,7 +624,7 @@ AttributeWriter::setupWriteContexts() void AttributeWriter::internalPut(SerialNum serialNum, const Document &doc, DocumentIdT lid, - bool allAttributes, OnWriteDoneType onWriteDone) + bool allAttributes, const OnWriteDoneType& onWriteDone) { for (const auto &wc : _writeContexts) { if (allAttributes && wc.use_two_phase_put()) { @@ -644,7 +644,7 @@ AttributeWriter::internalPut(SerialNum serialNum, const Document &doc, DocumentI } void -AttributeWriter::internalRemove(SerialNum serialNum, DocumentIdT lid, OnWriteDoneType onWriteDone) +AttributeWriter::internalRemove(SerialNum serialNum, DocumentIdT lid, const OnWriteDoneType& onWriteDone) { for (const auto &wc : _writeContexts) { auto removeTask = std::make_unique(wc, serialNum, lid, onWriteDone); @@ -678,7 +678,7 @@ AttributeWriter::~AttributeWriter() { } void -AttributeWriter::drain(OnWriteDoneType onDone) { +AttributeWriter::drain(const OnWriteDoneType& onDone) { for (const auto &wc : _writeContexts) { _attributeFieldWriter.executeLambda(wc.getExecutorId(), [onDone] () { (void) onDone; }); @@ -699,7 +699,7 @@ AttributeWriter::getWritableAttribute(const std::string &name) const } void -AttributeWriter::put(SerialNum serialNum, const Document &doc, DocumentIdT lid, OnWriteDoneType onWriteDone) +AttributeWriter::put(SerialNum serialNum, const Document &doc, DocumentIdT lid, const OnWriteDoneType& onWriteDone) { LOG(spam, "Handle put: serial(%" PRIu64 "), docId(%s), lid(%u), document(%s)", serialNum, doc.getId().toString().c_str(), lid, doc.toString(true).c_str()); @@ -707,7 +707,7 @@ AttributeWriter::put(SerialNum serialNum, const Document &doc, DocumentIdT lid, } void -AttributeWriter::update(SerialNum serialNum, const Document &doc, DocumentIdT lid, OnWriteDoneType onWriteDone) +AttributeWriter::update(SerialNum serialNum, const Document &doc, DocumentIdT lid, const OnWriteDoneType& onWriteDone) { LOG(spam, "Handle update: serial(%" PRIu64 "), docId(%s), lid(%u), document(%s)", serialNum, doc.getId().toString().c_str(), lid, doc.toString(true).c_str()); @@ -715,13 +715,13 @@ AttributeWriter::update(SerialNum serialNum, const Document &doc, DocumentIdT li } void -AttributeWriter::remove(SerialNum serialNum, DocumentIdT lid, OnWriteDoneType onWriteDone) +AttributeWriter::remove(SerialNum serialNum, DocumentIdT lid, const OnWriteDoneType& onWriteDone) { internalRemove(serialNum, lid, onWriteDone); } void -AttributeWriter::remove(const LidVector &lidsToRemove, SerialNum serialNum, OnWriteDoneType onWriteDone) +AttributeWriter::remove(const LidVector &lidsToRemove, SerialNum serialNum, const OnWriteDoneType& onWriteDone) { for (const auto &writeCtx : _writeContexts) { auto removeTask = std::make_unique(writeCtx, serialNum, lidsToRemove, onWriteDone); @@ -750,7 +750,7 @@ get_single_assign_update_field_value(const FieldUpdate& update) void AttributeWriter::update(SerialNum serialNum, const DocumentUpdate &upd, DocumentIdT lid, - OnWriteDoneType onWriteDone, IFieldUpdateCallback & onUpdate) + const OnWriteDoneType& onWriteDone, IFieldUpdateCallback & onUpdate) { LOG(debug, "Inspecting update for document %d.", lid); std::vector> args; @@ -799,7 +799,7 @@ AttributeWriter::update(SerialNum serialNum, const DocumentUpdate &upd, Document } void -AttributeWriter::heartBeat(SerialNum serialNum, OnWriteDoneType onDone) +AttributeWriter::heartBeat(SerialNum serialNum, const OnWriteDoneType& onDone) { for (auto entry : _attrMap) { _attributeFieldWriter.execute(entry.second.executor_id,[serialNum, attr=entry.second.attribute, onDone]() { @@ -811,7 +811,7 @@ AttributeWriter::heartBeat(SerialNum serialNum, OnWriteDoneType onDone) void -AttributeWriter::forceCommit(const CommitParam & param, OnWriteDoneType onWriteDone) +AttributeWriter::forceCommit(const CommitParam & param, const OnWriteDoneType& onWriteDone) { if (_mgr->getImportedAttributes() != nullptr) { std::vector> importedAttrs; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h index 9dd0fb9b5f68..135b019ae2e3 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h @@ -89,8 +89,8 @@ class AttributeWriter : public IAttributeWriter void setupWriteContexts(); void setupAttributeMapping(); void internalPut(SerialNum serialNum, const Document &doc, DocumentIdT lid, - bool allAttributes, OnWriteDoneType onWriteDone); - void internalRemove(SerialNum serialNum, DocumentIdT lid, OnWriteDoneType onWriteDone); + bool allAttributes, const OnWriteDoneType& onWriteDone); + void internalRemove(SerialNum serialNum, DocumentIdT lid, const OnWriteDoneType& onWriteDone); public: AttributeWriter(proton::IAttributeManager::SP mgr); @@ -103,22 +103,22 @@ class AttributeWriter : public IAttributeWriter */ std::vector getWritableAttributes() const override; search::AttributeVector *getWritableAttribute(const std::string &name) const override; - void put(SerialNum serialNum, const Document &doc, DocumentIdT lid, OnWriteDoneType onWriteDone) override; - void remove(SerialNum serialNum, DocumentIdT lid, OnWriteDoneType onWriteDone) override; - void remove(const LidVector &lidVector, SerialNum serialNum, OnWriteDoneType onWriteDone) override; + void put(SerialNum serialNum, const Document &doc, DocumentIdT lid, const OnWriteDoneType& onWriteDone) override; + void remove(SerialNum serialNum, DocumentIdT lid, const OnWriteDoneType& onWriteDone) override; + void remove(const LidVector &lidVector, SerialNum serialNum, const OnWriteDoneType& onWriteDone) override; void update(SerialNum serialNum, const DocumentUpdate &upd, DocumentIdT lid, - OnWriteDoneType onWriteDone, IFieldUpdateCallback & onUpdate) override; - void update(SerialNum serialNum, const Document &doc, DocumentIdT lid, OnWriteDoneType onWriteDone) override; - void heartBeat(SerialNum serialNum, OnWriteDoneType onDone) override; + const OnWriteDoneType& onWriteDone, IFieldUpdateCallback & onUpdate) override; + void update(SerialNum serialNum, const Document &doc, DocumentIdT lid, const OnWriteDoneType& onWriteDone) override; + void heartBeat(SerialNum serialNum, const OnWriteDoneType& onDone) override; void compactLidSpace(uint32_t wantedLidLimit, SerialNum serialNum) override; const proton::IAttributeManager::SP &getAttributeManager() const override { return _mgr; } - void forceCommit(const CommitParam & param, OnWriteDoneType onWriteDone) override; + void forceCommit(const CommitParam & param, const OnWriteDoneType& onWriteDone) override; void onReplayDone(uint32_t docIdLimit) override; bool hasStructFieldAttribute() const override; - void drain(OnWriteDoneType onWriteDone) override; + void drain(const OnWriteDoneType& onWriteDone) override; // Should only be used for unit testing. const std::vector& get_write_contexts() const { 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 11301b3a4cdc..7991abd0ebea 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_writer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_writer.h @@ -31,26 +31,26 @@ class IAttributeWriter { using DocumentIdT = search::DocumentIdT; using DocumentUpdate = document::DocumentUpdate; using Document = document::Document; - using OnWriteDoneType = const std::shared_ptr &; + using OnWriteDoneType = std::shared_ptr; virtual ~IAttributeWriter() = default; virtual std::vector getWritableAttributes() const = 0; virtual search::AttributeVector *getWritableAttribute(const std::string &attrName) const = 0; - virtual void put(SerialNum serialNum, const Document &doc, DocumentIdT lid, OnWriteDoneType onWriteDone) = 0; - virtual void remove(SerialNum serialNum, DocumentIdT lid, OnWriteDoneType onWriteDone) = 0; - virtual void remove(const LidVector &lidVector, SerialNum serialNum, OnWriteDoneType onWriteDone) = 0; + virtual void put(SerialNum serialNum, const Document &doc, DocumentIdT lid, const OnWriteDoneType& onWriteDone) = 0; + virtual void remove(SerialNum serialNum, DocumentIdT lid, const OnWriteDoneType& onWriteDone) = 0; + virtual void remove(const LidVector &lidVector, SerialNum serialNum, const OnWriteDoneType& onWriteDone) = 0; /** * Update the underlying attributes based on the content of the given DocumentUpdate. * The OnWriteDoneType instance should ensure the lifetime of the given DocumentUpdate instance. */ virtual void update(SerialNum serialNum, const DocumentUpdate &upd, DocumentIdT lid, - OnWriteDoneType onWriteDone, IFieldUpdateCallback & onUpdate) = 0; + const OnWriteDoneType& onWriteDone, IFieldUpdateCallback & onUpdate) = 0; /* * Update the underlying struct field attributes based on updated document. */ - virtual void update(SerialNum serialNum, const Document &doc, DocumentIdT lid, OnWriteDoneType onWriteDone) = 0; - virtual void heartBeat(SerialNum serialNum, OnWriteDoneType onDone) = 0; + virtual void update(SerialNum serialNum, const Document &doc, DocumentIdT lid, const OnWriteDoneType& onWriteDone) = 0; + virtual void heartBeat(SerialNum serialNum, const OnWriteDoneType& onDone) = 0; /** * Compact the lid space of the underlying attribute vectors. */ @@ -60,11 +60,11 @@ class IAttributeWriter { /** * Commit all underlying attribute vectors with the given param. */ - virtual void forceCommit(const CommitParam & param, OnWriteDoneType onWriteDone) = 0; + virtual void forceCommit(const CommitParam & param, const OnWriteDoneType& onWriteDone) = 0; virtual void onReplayDone(uint32_t docIdLimit) = 0; virtual bool hasStructFieldAttribute() const = 0; - virtual void drain(OnWriteDoneType onWriteDone) = 0; + virtual void drain(const OnWriteDoneType& onWriteDone) = 0; }; } // 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 0ee294753353..2793f4750665 100644 --- a/searchcore/src/vespa/searchcore/proton/index/i_index_writer.h +++ b/searchcore/src/vespa/searchcore/proton/index/i_index_writer.h @@ -24,14 +24,14 @@ class IIndexWriter { virtual const std::shared_ptr &getIndexManager() const = 0; // feed interface - virtual void put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid, OnWriteDoneType on_write_done) = 0; + virtual void put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid, const OnWriteDoneType& on_write_done) = 0; void remove(search::SerialNum serialNum, search::DocumentIdT lid) { LidVector lids; lids.push_back(lid); removeDocs(serialNum, std::move(lids)); } virtual void removeDocs(search::SerialNum serialNum, LidVector lids) = 0; - virtual void commit(search::SerialNum serialNum, OnWriteDoneType onWriteDone) = 0; + virtual void commit(search::SerialNum serialNum, const OnWriteDoneType& onWriteDone) = 0; virtual void heartBeat(search::SerialNum serialNum) = 0; virtual void compactLidSpace(search::SerialNum serialNum, const search::DocumentIdT lid) = 0; }; diff --git a/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp b/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp index af57a074e1d7..a1dbf2c868a7 100644 --- a/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp +++ b/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp @@ -24,7 +24,7 @@ IndexWriter::ignoreOperation(search::SerialNum serialNum) const { } void -IndexWriter::put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid, OnWriteDoneType on_write_done) +IndexWriter::put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid, const OnWriteDoneType& on_write_done) { if (ignoreOperation(serialNum)) { return; @@ -56,7 +56,7 @@ IndexWriter::removeDocs(search::SerialNum serialNum, LidVector lids) } void -IndexWriter::commit(search::SerialNum serialNum, OnWriteDoneType onWriteDone) +IndexWriter::commit(search::SerialNum serialNum, const OnWriteDoneType& onWriteDone) { if (serialNum <= _mgr->getFlushedSerialNum()) { return; diff --git a/searchcore/src/vespa/searchcore/proton/index/index_writer.h b/searchcore/src/vespa/searchcore/proton/index/index_writer.h index 37f9322ee117..8c17102ea209 100644 --- a/searchcore/src/vespa/searchcore/proton/index/index_writer.h +++ b/searchcore/src/vespa/searchcore/proton/index/index_writer.h @@ -18,9 +18,9 @@ class IndexWriter : public IIndexWriter, ~IndexWriter() override; const IIndexManager::SP & getIndexManager() const override { return _mgr; } - void put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid, OnWriteDoneType on_write_done) override; + void put(search::SerialNum serialNum, const document::Document &doc, const search::DocumentIdT lid, const OnWriteDoneType& on_write_done) override; void removeDocs(search::SerialNum serialNum, LidVector lids) override; - void commit(search::SerialNum serialNum, OnWriteDoneType onWriteDone) override; + void commit(search::SerialNum serialNum, const OnWriteDoneType& onWriteDone) override; void heartBeat(search::SerialNum serialNum) override; void compactLidSpace(search::SerialNum serialNum, const search::DocumentIdT lid) override; diff --git a/searchcore/src/vespa/searchcore/proton/index/indexmanager.h b/searchcore/src/vespa/searchcore/proton/index/indexmanager.h index 7c1eb1737acb..c0e8eb9df0d8 100644 --- a/searchcore/src/vespa/searchcore/proton/index/indexmanager.h +++ b/searchcore/src/vespa/searchcore/proton/index/indexmanager.h @@ -86,7 +86,7 @@ class IndexManager : public searchcorespi::IIndexManager /** * Implements searchcorespi::IIndexManager **/ - void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, OnWriteDoneType on_write_done) override { + void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, const OnWriteDoneType& on_write_done) override { _maintainer.putDocument(lid, doc, serialNum, on_write_done); } @@ -94,7 +94,7 @@ class IndexManager : public searchcorespi::IIndexManager _maintainer.removeDocuments(std::move(lids), serialNum); } - void commit(SerialNum serialNum, OnWriteDoneType onWriteDone) override { + void commit(SerialNum serialNum, const OnWriteDoneType& onWriteDone) override { _maintainer.commit(serialNum, onWriteDone); } diff --git a/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h b/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h index ba6724feb61c..b51698bf60ed 100644 --- a/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h +++ b/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h @@ -77,7 +77,7 @@ class MemoryIndexWrapper : public searchcorespi::index::IMemoryIndex { vespalib::MemoryUsage getMemoryUsage() const override { return _index.getMemoryUsage(); } - void insertDocument(uint32_t lid, const document::Document &doc, OnWriteDoneType on_write_done) override { + void insertDocument(uint32_t lid, const document::Document &doc, const OnWriteDoneType& on_write_done) override { _index.insertDocument(lid, doc, on_write_done); } void removeDocuments(LidVector lids) override { @@ -86,7 +86,7 @@ class MemoryIndexWrapper : public searchcorespi::index::IMemoryIndex { uint64_t getStaticMemoryFootprint() const override { return _index.getStaticMemoryFootprint(); } - void commit(OnWriteDoneType onWriteDone, SerialNum serialNum) override { + void commit(const OnWriteDoneType& onWriteDone, SerialNum serialNum) override { _index.commit(onWriteDone); _serialNum.store(serialNum, std::memory_order_relaxed); } diff --git a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp index 612b31b01230..7ef8b99c52b9 100644 --- a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp @@ -186,7 +186,7 @@ CombiningFeedView::prepareDeleteBucket(DeleteBucketOperation &delOp) } void -CombiningFeedView::handleDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) +CombiningFeedView::handleDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) { for (const auto &view : _views) { view->handleDeleteBucket(delOp, onDone); @@ -209,7 +209,7 @@ CombiningFeedView::prepareMove(MoveOperation &moveOp) } void -CombiningFeedView::handleMove(const MoveOperation &moveOp, DoneCallback moveDoneCtx) +CombiningFeedView::handleMove(const MoveOperation &moveOp, const DoneCallback& moveDoneCtx) { assert(moveOp.getValidDbdId()); uint32_t subDbId = moveOp.getSubDbId(); @@ -224,7 +224,7 @@ CombiningFeedView::handleMove(const MoveOperation &moveOp, DoneCallback moveDone } void -CombiningFeedView::heartBeat(search::SerialNum serialNum, DoneCallback onDone) +CombiningFeedView::heartBeat(search::SerialNum serialNum, const DoneCallback& onDone) { for (const auto &view : _views) { view->heartBeat(serialNum, onDone); @@ -232,7 +232,7 @@ CombiningFeedView::heartBeat(search::SerialNum serialNum, DoneCallback onDone) } void -CombiningFeedView::forceCommit(const CommitParam & param, DoneCallback onDone) +CombiningFeedView::forceCommit(const CommitParam & param, const DoneCallback& onDone) { for (const auto &view : _views) { view->forceCommit(param, onDone); @@ -241,13 +241,13 @@ CombiningFeedView::forceCommit(const CommitParam & param, DoneCallback onDone) void CombiningFeedView:: -handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, DoneCallback onDone) +handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, const DoneCallback& onDone) { getRemFeedView()->handlePruneRemovedDocuments(pruneOp, onDone); } void -CombiningFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) +CombiningFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) { uint32_t subDbId = op.getSubDbId(); assert(subDbId < _views.size()); diff --git a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h index 2890aa7ac0f8..4e8952675ecd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h +++ b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.h @@ -49,7 +49,7 @@ class CombiningFeedView : public IFeedView } vespalib::Trinary shouldBeReady(const document::BucketId &bucket) const; - void forceCommit(const CommitParam & param, DoneCallback onDone) override; + void forceCommit(const CommitParam & param, const DoneCallback& onDone) override; public: using SP = std::shared_ptr; @@ -74,11 +74,11 @@ class CombiningFeedView : public IFeedView void prepareDeleteBucket(DeleteBucketOperation &delOp) override; bool isMoveStillValid(const MoveOperation & moveOp) const override; void prepareMove(MoveOperation &putOp) override; - void handleDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) override; - void handleMove(const MoveOperation &moveOp, DoneCallback onDone) override; - void heartBeat(search::SerialNum serialNum, DoneCallback onDone) override; - void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, DoneCallback onDone) override; - void handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) override; + void handleDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) override; + void handleMove(const MoveOperation &moveOp, const DoneCallback& onDone) override; + void heartBeat(search::SerialNum serialNum, const DoneCallback& onDone) override; + void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, const DoneCallback& onDone) override; + void handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) override; // Called by document db executor void setCalculator(const std::shared_ptr &newCalc); 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 d5fcd0a4f076..140eddb4770d 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 @@ -19,20 +19,20 @@ namespace proton { * Otherwise we can drop it and ack the operation right away. */ void -FastAccessFeedView::putAttributes(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, OnPutDoneType onWriteDone) +FastAccessFeedView::putAttributes(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, const OnPutDoneType& onWriteDone) { _attributeWriter->put(serialNum, doc, lid, onWriteDone); } void FastAccessFeedView::updateAttributes(SerialNum serialNum, search::DocumentIdT lid, const DocumentUpdate &upd, - OnOperationDoneType onWriteDone, IFieldUpdateCallback & onUpdate) + const OnOperationDoneType& onWriteDone, IFieldUpdateCallback & onUpdate) { _attributeWriter->update(serialNum, upd, lid, onWriteDone, onUpdate); } void -FastAccessFeedView::updateAttributes(SerialNum serialNum, Lid lid, FutureDoc futureDoc, OnOperationDoneType onWriteDone) +FastAccessFeedView::updateAttributes(SerialNum serialNum, Lid lid, FutureDoc futureDoc, const OnOperationDoneType& onWriteDone) { if (_attributeWriter->hasStructFieldAttribute()) { const std::unique_ptr & doc = futureDoc.get(); @@ -43,19 +43,19 @@ FastAccessFeedView::updateAttributes(SerialNum serialNum, Lid lid, FutureDoc fut } void -FastAccessFeedView::removeAttributes(SerialNum serialNum, search::DocumentIdT lid, OnRemoveDoneType onWriteDone) +FastAccessFeedView::removeAttributes(SerialNum serialNum, search::DocumentIdT lid, const OnRemoveDoneType& onWriteDone) { _attributeWriter->remove(serialNum, lid, onWriteDone); } void -FastAccessFeedView::removeAttributes(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone) +FastAccessFeedView::removeAttributes(SerialNum serialNum, const LidVector &lidsToRemove, const OnWriteDoneType& onWriteDone) { _attributeWriter->remove(lidsToRemove, serialNum, onWriteDone); } void -FastAccessFeedView::heartBeatAttributes(SerialNum serialNum, DoneCallback onDone) +FastAccessFeedView::heartBeatAttributes(SerialNum serialNum, const DoneCallback& onDone) { _attributeWriter->heartBeat(serialNum, onDone); } @@ -69,7 +69,7 @@ FastAccessFeedView::FastAccessFeedView(StoreOnlyFeedView::Context storeOnlyCtx, FastAccessFeedView::~FastAccessFeedView() = default; void -FastAccessFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) +FastAccessFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) { // Drain pending PutDoneContext and ForceCommitContext objects forceCommitAndWait(search::CommitParam(op.getSerialNum())); @@ -79,7 +79,7 @@ FastAccessFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, Do } void -FastAccessFeedView::internalForceCommit(const CommitParam & param, OnForceCommitDoneType onCommitDone) +FastAccessFeedView::internalForceCommit(const CommitParam & param, const OnForceCommitDoneType& onCommitDone) { _attributeWriter->forceCommit(param, onCommitDone); onCommitDone->registerCommittedDocIdLimit(_metaStore.getCommittedDocIdLimit(), &_docIdLimit); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h index 00496a7e868a..0db95ebc1a19 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h @@ -36,19 +36,19 @@ class FastAccessFeedView : public StoreOnlyFeedView const IAttributeWriter::SP _attributeWriter; DocIdLimit &_docIdLimit; - void putAttributes(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, OnPutDoneType onWriteDone) override; + void putAttributes(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, const OnPutDoneType& onWriteDone) override; void updateAttributes(SerialNum serialNum, search::DocumentIdT lid, const document::DocumentUpdate &upd, - OnOperationDoneType onWriteDone, IFieldUpdateCallback & onUpdate) override; - void updateAttributes(SerialNum serialNum, Lid lid, FutureDoc doc, OnOperationDoneType onWriteDone) override; - void removeAttributes(SerialNum serialNum, search::DocumentIdT lid, OnRemoveDoneType onWriteDone) override; + const OnOperationDoneType& onWriteDone, IFieldUpdateCallback & onUpdate) override; + void updateAttributes(SerialNum serialNum, Lid lid, FutureDoc doc, const OnOperationDoneType& onWriteDone) override; + void removeAttributes(SerialNum serialNum, search::DocumentIdT lid, const OnRemoveDoneType& onWriteDone) override; - void removeAttributes(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone) override; + void removeAttributes(SerialNum serialNum, const LidVector &lidsToRemove, const OnWriteDoneType& onWriteDone) override; - void heartBeatAttributes(SerialNum serialNum, DoneCallback onDone) override; + void heartBeatAttributes(SerialNum serialNum, const DoneCallback& onDone) override; protected: - void internalForceCommit(const CommitParam & param, OnForceCommitDoneType onCommitDone) override; + void internalForceCommit(const CommitParam & param, const OnForceCommitDoneType& onCommitDone) override; public: FastAccessFeedView(StoreOnlyFeedView::Context storeOnlyCtx, const PersistentParams ¶ms, const Context &ctx); @@ -62,7 +62,7 @@ class FastAccessFeedView : public StoreOnlyFeedView return _docIdLimit; } - void handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) override; + void handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/ifeedview.h b/searchcore/src/vespa/searchcore/proton/server/ifeedview.h index d3a43b535dae..8cc5798c2aaa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/ifeedview.h +++ b/searchcore/src/vespa/searchcore/proton/server/ifeedview.h @@ -29,7 +29,7 @@ class IFeedView IFeedView() = default; public: using SP = std::shared_ptr; - using DoneCallback = const std::shared_ptr &; + using DoneCallback = std::shared_ptr; using IDestructorCallbackSP = std::shared_ptr; using CommitParam = search::CommitParam; @@ -58,12 +58,12 @@ class IFeedView virtual void prepareDeleteBucket(DeleteBucketOperation &delOp) = 0; [[nodiscard]] virtual bool isMoveStillValid(const MoveOperation & moveOp) const = 0; virtual void prepareMove(MoveOperation &putOp) = 0; - virtual void handleDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) = 0; - virtual void handleMove(const MoveOperation &putOp, DoneCallback onDone) = 0; - virtual void heartBeat(search::SerialNum serialNum, DoneCallback onDone) = 0; - virtual void forceCommit(const CommitParam & param, DoneCallback onDone) = 0; - virtual void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation & pruneOp, DoneCallback onDone) = 0; - virtual void handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) = 0; + virtual void handleDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) = 0; + virtual void handleMove(const MoveOperation &putOp, const DoneCallback& onDone) = 0; + virtual void heartBeat(search::SerialNum serialNum, const DoneCallback& onDone) = 0; + virtual void forceCommit(const CommitParam & param, const DoneCallback& onDone) = 0; + virtual void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation & pruneOp, const DoneCallback& onDone) = 0; + virtual void handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) = 0; void forceCommit(CommitParam param) { forceCommit(param, IDestructorCallbackSP()); } void forceCommit(search::SerialNum serialNum) { forceCommit(CommitParam(serialNum)); } void forceCommitAndWait(CommitParam param); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp index 5368265e46b2..9918ac36cb03 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp @@ -41,7 +41,7 @@ SearchableFeedView::~SearchableFeedView() = default; void SearchableFeedView::putIndexedFields(SerialNum serialNum, search::DocumentIdT lid, const DocumentSP &newDoc, - OnOperationDoneType onWriteDone) + const OnOperationDoneType& onWriteDone) { if (!hasIndexedFields()) { return; @@ -53,7 +53,7 @@ SearchableFeedView::putIndexedFields(SerialNum serialNum, search::DocumentIdT li } void -SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, OnOperationDoneType onWriteDone) +SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, const OnOperationDoneType& onWriteDone) { (void) onWriteDone; assert(_writeService.index().isCurrentThread()); @@ -65,13 +65,13 @@ SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid } void -SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const DocumentSP &doc, OnOperationDoneType onWriteDone) +SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const DocumentSP &doc, const OnOperationDoneType& onWriteDone) { performIndexPut(serialNum, lid, *doc, onWriteDone); } void -SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid, FutureDoc futureDoc, OnOperationDoneType onWriteDone) +SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid, FutureDoc futureDoc, const OnOperationDoneType& onWriteDone) { const auto &doc = futureDoc.get(); if (doc) { @@ -80,7 +80,7 @@ SearchableFeedView::performIndexPut(SerialNum serialNum, search::DocumentIdT lid } void -SearchableFeedView::heartBeatIndexedFields(SerialNum serialNum, DoneCallback onDone) +SearchableFeedView::heartBeatIndexedFields(SerialNum serialNum, const DoneCallback& onDone) { _writeService.index().execute(makeLambdaTask([this, serialNum, onDone] { (void) onDone; @@ -95,7 +95,7 @@ SearchableFeedView::performIndexHeartBeat(SerialNum serialNum) } void -SearchableFeedView::updateIndexedFields(SerialNum serialNum, search::DocumentIdT lid, FutureDoc futureDoc, OnOperationDoneType onWriteDone) +SearchableFeedView::updateIndexedFields(SerialNum serialNum, search::DocumentIdT lid, FutureDoc futureDoc, const OnOperationDoneType& onWriteDone) { _writeService.index().execute( makeLambdaTask([serialNum, lid, futureDoc = std::move(futureDoc), @@ -105,7 +105,7 @@ SearchableFeedView::updateIndexedFields(SerialNum serialNum, search::DocumentIdT } void -SearchableFeedView::removeIndexedFields(SerialNum serialNum, search::DocumentIdT lid, OnRemoveDoneType onWriteDone) +SearchableFeedView::removeIndexedFields(SerialNum serialNum, search::DocumentIdT lid, const OnRemoveDoneType& onWriteDone) { if (!hasIndexedFields()) { return; @@ -118,7 +118,7 @@ SearchableFeedView::removeIndexedFields(SerialNum serialNum, search::DocumentIdT void -SearchableFeedView::performIndexRemove(SerialNum serialNum, search::DocumentIdT lid, OnRemoveDoneType onWriteDone) +SearchableFeedView::performIndexRemove(SerialNum serialNum, search::DocumentIdT lid, const OnRemoveDoneType& onWriteDone) { (void) onWriteDone; assert(_writeService.index().isCurrentThread()); @@ -130,7 +130,7 @@ SearchableFeedView::performIndexRemove(SerialNum serialNum, search::DocumentIdT } void -SearchableFeedView::performIndexRemove(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone) +SearchableFeedView::performIndexRemove(SerialNum serialNum, const LidVector &lidsToRemove, const OnWriteDoneType& onWriteDone) { (void) onWriteDone; assert(_writeService.index().isCurrentThread()); @@ -145,7 +145,7 @@ SearchableFeedView::performIndexRemove(SerialNum serialNum, const LidVector &lid void SearchableFeedView::removeIndexedFields(SerialNum serialNum, const LidVector &lidsToRemove, - OnWriteDoneType onWriteDone) + const OnWriteDoneType& onWriteDone) { if (!hasIndexedFields()) return; @@ -157,20 +157,20 @@ SearchableFeedView::removeIndexedFields(SerialNum serialNum, const LidVector &li } void -SearchableFeedView::internalDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) +SearchableFeedView::internalDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) { Parent::internalDeleteBucket(delOp, onDone); } void -SearchableFeedView::performIndexForceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone) +SearchableFeedView::performIndexForceCommit(SerialNum serialNum, const OnForceCommitDoneType& onCommitDone) { assert(_writeService.index().isCurrentThread()); _indexWriter->commit(serialNum, onCommitDone); } void -SearchableFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) +SearchableFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) { Parent::handleCompactLidSpace(op, onDone); vespalib::Gate gate; @@ -183,7 +183,7 @@ SearchableFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, Do } void -SearchableFeedView::internalForceCommit(const CommitParam & param, OnForceCommitDoneType onCommitDone) +SearchableFeedView::internalForceCommit(const CommitParam & param, const OnForceCommitDoneType& onCommitDone) { Parent::internalForceCommit(param, onCommitDone); _writeService.index().execute( diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h index 0145bc586f65..fe9e87ba938b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h @@ -34,23 +34,23 @@ class SearchableFeedView : public FastAccessFeedView bool hasIndexedFields() const { return _hasIndexedFields; } - void performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, OnOperationDoneType onWriteDone); - void performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const DocumentSP &doc, OnOperationDoneType onWriteDone); - void performIndexPut(SerialNum serialNum, search::DocumentIdT lid, FutureDoc doc, OnOperationDoneType onWriteDone); - void performIndexRemove(SerialNum serialNum, search::DocumentIdT lid, OnRemoveDoneType onWriteDone); - void performIndexRemove(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone); + void performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, const OnOperationDoneType& onWriteDone); + void performIndexPut(SerialNum serialNum, search::DocumentIdT lid, const DocumentSP &doc, const OnOperationDoneType& onWriteDone); + void performIndexPut(SerialNum serialNum, search::DocumentIdT lid, FutureDoc doc, const OnOperationDoneType& onWriteDone); + void performIndexRemove(SerialNum serialNum, search::DocumentIdT lid, const OnRemoveDoneType& onWriteDone); + void performIndexRemove(SerialNum serialNum, const LidVector &lidsToRemove, const OnWriteDoneType& onWriteDone); void performIndexHeartBeat(SerialNum serialNum); - void internalDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) override; - void heartBeatIndexedFields(SerialNum serialNum, DoneCallback onDone) override; + void internalDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) override; + void heartBeatIndexedFields(SerialNum serialNum, const DoneCallback& onDone) override; - void putIndexedFields(SerialNum serialNum, search::DocumentIdT lid, const DocumentSP &newDoc, OnOperationDoneType onWriteDone) override; - void updateIndexedFields(SerialNum serialNum, search::DocumentIdT lid, FutureDoc newDoc, OnOperationDoneType onWriteDone) override; - void removeIndexedFields(SerialNum serialNum, search::DocumentIdT lid, OnRemoveDoneType onWriteDone) override; - void removeIndexedFields(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone) override; + void putIndexedFields(SerialNum serialNum, search::DocumentIdT lid, const DocumentSP &newDoc, const OnOperationDoneType& onWriteDone) override; + void updateIndexedFields(SerialNum serialNum, search::DocumentIdT lid, FutureDoc newDoc, const OnOperationDoneType& onWriteDone) override; + void removeIndexedFields(SerialNum serialNum, search::DocumentIdT lid, const OnRemoveDoneType& onWriteDone) override; + void removeIndexedFields(SerialNum serialNum, const LidVector &lidsToRemove, const OnWriteDoneType& onWriteDone) override; - void performIndexForceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone); - void internalForceCommit(const CommitParam & param, OnForceCommitDoneType onCommitDone) override; + void performIndexForceCommit(SerialNum serialNum, const OnForceCommitDoneType& onCommitDone); + void internalForceCommit(const CommitParam & param, const OnForceCommitDoneType& onCommitDone) override; public: SearchableFeedView(StoreOnlyFeedView::Context storeOnlyCtx, const PersistentParams ¶ms, @@ -58,7 +58,7 @@ class SearchableFeedView : public FastAccessFeedView ~SearchableFeedView() override; const IIndexWriter::SP &getIndexWriter() const { return _indexWriter; } - void handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) override; + void handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp index 44f7a8a5e559..fae5c5ed8d8f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp @@ -217,7 +217,7 @@ StoreOnlyFeedView::Context::Context(Context &&) noexcept = default; StoreOnlyFeedView::Context::~Context() = default; void -StoreOnlyFeedView::forceCommit(const CommitParam & param, DoneCallback onDone) +StoreOnlyFeedView::forceCommit(const CommitParam & param, const DoneCallback& onDone) { if (useDocumentMetaStore(param.lastSerialNum())) { _metaStore.commit(param); @@ -229,7 +229,7 @@ StoreOnlyFeedView::forceCommit(const CommitParam & param, DoneCallback onDone) } void -StoreOnlyFeedView::internalForceCommit(const CommitParam & param, OnForceCommitDoneType onCommitDone) +StoreOnlyFeedView::internalForceCommit(const CommitParam & param, const OnForceCommitDoneType& onCommitDone) { LOG(debug, "internalForceCommit: serial=%" PRIu64 ".", param.lastSerialNum()); _writeService.summary().execute(makeLambdaTask([onDone=onCommitDone]() {(void) onDone;})); @@ -248,10 +248,10 @@ StoreOnlyFeedView::get_pending_lid_token(const DocumentOperation &op) } void -StoreOnlyFeedView::putAttributes(SerialNum, Lid, const Document &, OnPutDoneType) {} +StoreOnlyFeedView::putAttributes(SerialNum, Lid, const Document &, const OnPutDoneType&) {} void -StoreOnlyFeedView::putIndexedFields(SerialNum, Lid, const std::shared_ptr &, OnOperationDoneType) {} +StoreOnlyFeedView::putIndexedFields(SerialNum, Lid, const std::shared_ptr &, const OnOperationDoneType&) {} void StoreOnlyFeedView::preparePut(PutOperation &putOp) @@ -318,15 +318,15 @@ StoreOnlyFeedView::internalPut(FeedToken token, const PutOperation &putOp) } void -StoreOnlyFeedView::heartBeatIndexedFields(SerialNum, DoneCallback ) {} +StoreOnlyFeedView::heartBeatIndexedFields(SerialNum, const DoneCallback&) {} void -StoreOnlyFeedView::heartBeatAttributes(SerialNum, DoneCallback ) {} +StoreOnlyFeedView::heartBeatAttributes(SerialNum, const DoneCallback&) {} void StoreOnlyFeedView::updateAttributes(SerialNum, Lid, const DocumentUpdate & upd, - OnOperationDoneType, IFieldUpdateCallback & onUpdate) + const OnOperationDoneType&, IFieldUpdateCallback & onUpdate) { for (const auto & fieldUpdate : upd.getUpdates()) { onUpdate.onUpdateField(fieldUpdate.getField(), nullptr); @@ -334,12 +334,12 @@ StoreOnlyFeedView::updateAttributes(SerialNum, Lid, const DocumentUpdate & upd, } void -StoreOnlyFeedView::updateAttributes(SerialNum, Lid, FutureDoc, OnOperationDoneType) +StoreOnlyFeedView::updateAttributes(SerialNum, Lid, FutureDoc, const OnOperationDoneType&) { } void -StoreOnlyFeedView::updateIndexedFields(SerialNum, Lid, FutureDoc, OnOperationDoneType) +StoreOnlyFeedView::updateIndexedFields(SerialNum, Lid, FutureDoc, const OnOperationDoneType&) { } @@ -362,7 +362,7 @@ StoreOnlyFeedView::handleUpdate(FeedToken token, const UpdateOperation &updOp) void StoreOnlyFeedView::putSummary(SerialNum serialNum, Lid lid, - FutureStream futureStream, OnOperationDoneType onDone) + FutureStream futureStream, const OnOperationDoneType& onDone) { summaryExecutor().execute( makeLambdaTask([serialNum, lid, futureStream = std::move(futureStream), trackerToken = _pendingLidsForDocStore.produce(lid), onDone, this] () mutable { @@ -376,7 +376,7 @@ StoreOnlyFeedView::putSummary(SerialNum serialNum, Lid lid, } void -StoreOnlyFeedView::putSummaryNoop(FutureStream futureStream, OnOperationDoneType onDone) +StoreOnlyFeedView::putSummaryNoop(FutureStream futureStream, const OnOperationDoneType& onDone) { summaryExecutor().execute( makeLambdaTask([futureStream = std::move(futureStream), onDone] () mutable { @@ -387,7 +387,7 @@ StoreOnlyFeedView::putSummaryNoop(FutureStream futureStream, OnOperationDoneType } void -StoreOnlyFeedView::putSummary(SerialNum serialNum, Lid lid, Document::SP doc, OnOperationDoneType onDone) +StoreOnlyFeedView::putSummary(SerialNum serialNum, Lid lid, Document::SP doc, const OnOperationDoneType& onDone) { summaryExecutor().execute( makeLambdaTask([serialNum, doc = std::move(doc), trackerToken = _pendingLidsForDocStore.produce(lid), onDone, lid, this] { @@ -397,7 +397,7 @@ StoreOnlyFeedView::putSummary(SerialNum serialNum, Lid lid, Document::SP doc, On })); } void -StoreOnlyFeedView::removeSummary(SerialNum serialNum, Lid lid, OnWriteDoneType onDone) { +StoreOnlyFeedView::removeSummary(SerialNum serialNum, Lid lid, const OnWriteDoneType& onDone) { summaryExecutor().execute( makeLambdaTask([serialNum, lid, onDone, trackerToken = _pendingLidsForDocStore.produce(lid), this] { (void) onDone; @@ -406,7 +406,7 @@ StoreOnlyFeedView::removeSummary(SerialNum serialNum, Lid lid, OnWriteDoneType o })); } void -StoreOnlyFeedView::removeSummaries(SerialNum serialNum, const LidVector & lids, OnWriteDoneType onDone) { +StoreOnlyFeedView::removeSummaries(SerialNum serialNum, const LidVector & lids, const OnWriteDoneType& onDone) { std::vector trackerTokens; trackerTokens.reserve(lids.size()); std::for_each(lids.begin(), lids.end(), [this, &trackerTokens](Lid lid) { @@ -423,7 +423,7 @@ StoreOnlyFeedView::removeSummaries(SerialNum serialNum, const LidVector & lids, } void -StoreOnlyFeedView::heartBeatSummary(SerialNum serialNum, DoneCallback onDone) { +StoreOnlyFeedView::heartBeatSummary(SerialNum serialNum, const DoneCallback& onDone) { summaryExecutor().execute( makeLambdaTask([serialNum, this, onDone] { (void) onDone; @@ -541,10 +541,10 @@ StoreOnlyFeedView::lookupDocId(const DocumentId &docId, Lid &lid) const } void -StoreOnlyFeedView::removeAttributes(SerialNum, Lid, OnRemoveDoneType) {} +StoreOnlyFeedView::removeAttributes(SerialNum, Lid, const OnRemoveDoneType&) {} void -StoreOnlyFeedView::removeIndexedFields(SerialNum, Lid, OnRemoveDoneType) {} +StoreOnlyFeedView::removeIndexedFields(SerialNum, Lid, const OnRemoveDoneType&) {} void StoreOnlyFeedView::prepareRemove(RemoveOperation &rmOp) @@ -648,13 +648,13 @@ StoreOnlyFeedView::adjustMetaStore(const DocumentOperation &op, const GlobalId & } void -StoreOnlyFeedView::removeAttributes(SerialNum, const LidVector &, OnWriteDoneType ) {} +StoreOnlyFeedView::removeAttributes(SerialNum, const LidVector &, const OnWriteDoneType&) {} void -StoreOnlyFeedView::removeIndexedFields(SerialNum , const LidVector &, OnWriteDoneType ) {} +StoreOnlyFeedView::removeIndexedFields(SerialNum , const LidVector &, const OnWriteDoneType&) {} size_t -StoreOnlyFeedView::removeDocuments(const RemoveDocumentsOperation &op, bool remove_index_and_attributes, DoneCallback onWriteDone) +StoreOnlyFeedView::removeDocuments(const RemoveDocumentsOperation &op, bool remove_index_and_attributes, const DoneCallback& onWriteDone) { const SerialNum serialNum = op.getSerialNum(); const LidVectorContext::SP &ctx = op.getLidsToRemove(_params._subDbId); @@ -697,13 +697,13 @@ StoreOnlyFeedView::prepareDeleteBucket(DeleteBucketOperation &delOp) } void -StoreOnlyFeedView::handleDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) +StoreOnlyFeedView::handleDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) { internalDeleteBucket(delOp, onDone); } void -StoreOnlyFeedView::internalDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) +StoreOnlyFeedView::internalDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) { size_t rm_count = removeDocuments(delOp, true, onDone); LOG(debug, "internalDeleteBucket(): docType(%s), bucket(%s), lidsToRemove(%zu)", @@ -732,7 +732,7 @@ StoreOnlyFeedView::prepareMove(MoveOperation &moveOp) // CombiningFeedView calls this for both source and target subdb. void -StoreOnlyFeedView::handleMove(const MoveOperation &moveOp, DoneCallback doneCtx) +StoreOnlyFeedView::handleMove(const MoveOperation &moveOp, const DoneCallback& doneCtx) { assert(moveOp.getValidDbdId()); assert(moveOp.getValidPrevDbdId()); @@ -766,7 +766,7 @@ StoreOnlyFeedView::handleMove(const MoveOperation &moveOp, DoneCallback doneCtx) } void -StoreOnlyFeedView::heartBeat(SerialNum serialNum, DoneCallback onDone) +StoreOnlyFeedView::heartBeat(SerialNum serialNum, const DoneCallback& onDone) { assert(_writeService.master().isCurrentThread()); _metaStore.reclaim_unused_memory(); @@ -779,7 +779,7 @@ StoreOnlyFeedView::heartBeat(SerialNum serialNum, DoneCallback onDone) // CombiningFeedView calls this only for the removed subdb. void StoreOnlyFeedView:: -handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, DoneCallback onDone) +handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, const DoneCallback& onDone) { assert(_params._subDbType == SubDbType::REMOVED); assert(pruneOp.getSubDbId() == _params._subDbId); @@ -791,7 +791,7 @@ handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, DoneC } void -StoreOnlyFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) +StoreOnlyFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) { assert(_params._subDbId == op.getSubDbId()); const SerialNum serialNum = op.getSerialNum(); diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h index 542bbb5e7fd7..c500b6b3dffe 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h @@ -54,10 +54,10 @@ class StoreOnlyFeedView : public IFeedView, using Document = document::Document; using DocumentUpdate = document::DocumentUpdate; using OnWriteDoneType = DoneCallback; - using OnForceCommitDoneType =const std::shared_ptr &; - using OnOperationDoneType = const std::shared_ptr &; - using OnPutDoneType = const std::shared_ptr &; - using OnRemoveDoneType = const std::shared_ptr &; + using OnForceCommitDoneType = std::shared_ptr; + using OnOperationDoneType = std::shared_ptr; + using OnPutDoneType = std::shared_ptr; + using OnRemoveDoneType = std::shared_ptr; using FutureDoc = std::shared_future>; using PromisedDoc = std::promise>; using FutureStream = std::future; @@ -138,12 +138,12 @@ class StoreOnlyFeedView : public IFeedView, vespalib::Executor & summaryExecutor() { return _writeService.summary(); } - void putSummary(SerialNum serialNum, Lid lid, FutureStream doc, OnOperationDoneType onDone); - void putSummaryNoop(FutureStream doc, OnOperationDoneType onDone); - void putSummary(SerialNum serialNum, Lid lid, DocumentSP doc, OnOperationDoneType onDone); - void removeSummary(SerialNum serialNum, Lid lid, OnWriteDoneType onDone); - void removeSummaries(SerialNum serialNum, const LidVector & lids, OnWriteDoneType onDone); - void heartBeatSummary(SerialNum serialNum, DoneCallback onDone); + void putSummary(SerialNum serialNum, Lid lid, FutureStream doc, const OnOperationDoneType& onDone); + void putSummaryNoop(FutureStream doc, const OnOperationDoneType& onDone); + void putSummary(SerialNum serialNum, Lid lid, DocumentSP doc, const OnOperationDoneType& onDone); + void removeSummary(SerialNum serialNum, Lid lid, const OnWriteDoneType& onDone); + void removeSummaries(SerialNum serialNum, const LidVector & lids, const OnWriteDoneType& onDone); + void heartBeatSummary(SerialNum serialNum, const DoneCallback& onDone); bool useDocumentStore(SerialNum replaySerialNum) const { return replaySerialNum > _params._flushedDocumentStoreSerialNum; @@ -162,7 +162,7 @@ class StoreOnlyFeedView : public IFeedView, // Removes documents from meta store and document store. // returns the number of documents removed. - size_t removeDocuments(const RemoveDocumentsOperation &op, bool remove_index_and_attribute_fields, DoneCallback onDone); + size_t removeDocuments(const RemoveDocumentsOperation &op, bool remove_index_and_attribute_fields, const DoneCallback& onDone); void internalRemove(FeedToken token, std::shared_ptr done_callback,IPendingLidTracker::Token uncommitted, SerialNum serialNum, Lid lid); @@ -172,26 +172,26 @@ class StoreOnlyFeedView : public IFeedView, PromisedDoc promisedDoc, PromisedStream promisedStream); protected: - virtual void internalDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone); - virtual void heartBeatIndexedFields(SerialNum serialNum, DoneCallback onDone); - virtual void heartBeatAttributes(SerialNum serialNum, DoneCallback onDone); + virtual void internalDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone); + virtual void heartBeatIndexedFields(SerialNum serialNum, const DoneCallback& onDone); + virtual void heartBeatAttributes(SerialNum serialNum, const DoneCallback& onDone); private: - virtual void putAttributes(SerialNum serialNum, Lid lid, const Document &doc, OnPutDoneType onWriteDone); - virtual void putIndexedFields(SerialNum serialNum, Lid lid, const DocumentSP &newDoc, OnOperationDoneType onWriteDone); + virtual void putAttributes(SerialNum serialNum, Lid lid, const Document &doc, const OnPutDoneType& onWriteDone); + virtual void putIndexedFields(SerialNum serialNum, Lid lid, const DocumentSP &newDoc, const OnOperationDoneType& onWriteDone); virtual void updateAttributes(SerialNum serialNum, Lid lid, const DocumentUpdate &upd, - OnOperationDoneType onWriteDone, IFieldUpdateCallback & onUpdate); + const OnOperationDoneType& onWriteDone, IFieldUpdateCallback & onUpdate); - virtual void updateAttributes(SerialNum serialNum, Lid lid, FutureDoc doc, OnOperationDoneType onWriteDone); - virtual void updateIndexedFields(SerialNum serialNum, Lid lid, FutureDoc doc, OnOperationDoneType onWriteDone); - virtual void removeAttributes(SerialNum serialNum, Lid lid, OnRemoveDoneType onWriteDone); - virtual void removeIndexedFields(SerialNum serialNum, Lid lid, OnRemoveDoneType onWriteDone); + virtual void updateAttributes(SerialNum serialNum, Lid lid, FutureDoc doc, const OnOperationDoneType& onWriteDone); + virtual void updateIndexedFields(SerialNum serialNum, Lid lid, FutureDoc doc, const OnOperationDoneType& onWriteDone); + virtual void removeAttributes(SerialNum serialNum, Lid lid, const OnRemoveDoneType& onWriteDone); + virtual void removeIndexedFields(SerialNum serialNum, Lid lid, const OnRemoveDoneType& onWriteDone); protected: - virtual void removeAttributes(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone); - virtual void removeIndexedFields(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone); - virtual void internalForceCommit(const CommitParam & param, OnForceCommitDoneType onCommitDone); + virtual void removeAttributes(SerialNum serialNum, const LidVector &lidsToRemove, const OnWriteDoneType& onWriteDone); + virtual void removeIndexedFields(SerialNum serialNum, const LidVector &lidsToRemove, const OnWriteDoneType& onWriteDone); + virtual void internalForceCommit(const CommitParam & param, const OnForceCommitDoneType& onCommitDone); public: StoreOnlyFeedView(Context ctx, const PersistentParams ¶ms); ~StoreOnlyFeedView() override; @@ -214,12 +214,12 @@ class StoreOnlyFeedView : public IFeedView, void prepareRemove(RemoveOperation &rmOp) override; void handleRemove(FeedToken token, const RemoveOperation &rmOp) override; void prepareDeleteBucket(DeleteBucketOperation &delOp) override; - void handleDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) override; + void handleDeleteBucket(const DeleteBucketOperation &delOp, const DoneCallback& onDone) override; bool isMoveStillValid(const MoveOperation & moveOp) const override; void prepareMove(MoveOperation &putOp) override; - void handleMove(const MoveOperation &putOp, DoneCallback doneCtx) override; - void heartBeat(search::SerialNum serialNum, DoneCallback onDone) override; - void forceCommit(const CommitParam & param, DoneCallback onDone) override; + void handleMove(const MoveOperation &putOp, const DoneCallback& doneCtx) override; + void heartBeat(search::SerialNum serialNum, const DoneCallback& onDone) override; + void forceCommit(const CommitParam & param, const DoneCallback& onDone) override; /** * Prune lids present in operation. Caller must call doneSegment() @@ -227,8 +227,8 @@ class StoreOnlyFeedView : public IFeedView, * * Called by writer thread. */ - void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, DoneCallback onDone) override; - void handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) override; + void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp, const DoneCallback& onDone) override; + void handleCompactLidSpace(const CompactLidSpaceOperation &op, const DoneCallback& onDone) override; std::shared_ptr getUncommittedLidTracker() { return _pendingLidsForCommit; } }; diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_feed_view.h b/searchcore/src/vespa/searchcore/proton/test/dummy_feed_view.h index 751d4464ca7b..9d9dedeae036 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_feed_view.h @@ -25,14 +25,14 @@ struct DummyFeedView : public IFeedView void prepareRemove(RemoveOperation &) override {} void handleRemove(FeedToken, const RemoveOperation &) override {} void prepareDeleteBucket(DeleteBucketOperation &) override {} - void handleDeleteBucket(const DeleteBucketOperation &, DoneCallback) override {} + void handleDeleteBucket(const DeleteBucketOperation &, const DoneCallback&) override {} bool isMoveStillValid(const MoveOperation &) const override { return true; } void prepareMove(MoveOperation &) override {} - void handleMove(const MoveOperation &, DoneCallback) override {} - void heartBeat(search::SerialNum, DoneCallback) override {} - void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &, DoneCallback) override {} - void handleCompactLidSpace(const CompactLidSpaceOperation &, DoneCallback) override {} - void forceCommit(const CommitParam &, DoneCallback) override { } + void handleMove(const MoveOperation &, const DoneCallback&) override {} + void heartBeat(search::SerialNum, const DoneCallback&) override {} + void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &, const DoneCallback&) override {} + void handleCompactLidSpace(const CompactLidSpaceOperation &, const DoneCallback&) override {} + void forceCommit(const CommitParam &, const DoneCallback&) override { } }; } diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_index_manager.h b/searchcore/src/vespa/searchcore/proton/test/mock_index_manager.h index a9f386bfc123..53af2381e7fe 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_index_manager.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_index_manager.h @@ -11,9 +11,9 @@ namespace proton::test { struct MockIndexManager : public searchcorespi::IIndexManager { ~MockIndexManager() override; - void putDocument(uint32_t, const Document &, SerialNum, OnWriteDoneType) override {} + void putDocument(uint32_t, const Document &, SerialNum, const OnWriteDoneType&) override {} void removeDocuments(LidVector, SerialNum) override {} - void commit(SerialNum, OnWriteDoneType) override {} + void commit(SerialNum, const OnWriteDoneType&) override {} SerialNum getCurrentSerialNum() const override { return 0; } SerialNum getFlushedSerialNum() const override { return 0; } searchcorespi::IndexSearchable::SP getSearchable() const override { diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_index_writer.h b/searchcore/src/vespa/searchcore/proton/test/mock_index_writer.h index f9b40a489530..4123e6e39b61 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_index_writer.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_index_writer.h @@ -14,9 +14,9 @@ struct MockIndexWriter : public IIndexWriter MockIndexWriter() : _idxMgr() {} MockIndexWriter(const IIndexManager::SP &idxMgr) : _idxMgr(idxMgr) {} const IIndexManager::SP &getIndexManager() const override { return _idxMgr; } - void put(search::SerialNum, const document::Document &, const search::DocumentIdT, OnWriteDoneType) override {} + void put(search::SerialNum, const document::Document &, const search::DocumentIdT, const OnWriteDoneType&) override {} void removeDocs(search::SerialNum, LidVector) override {} - void commit(search::SerialNum, OnWriteDoneType) override {} + void commit(search::SerialNum, const OnWriteDoneType&) override {} void heartBeat(search::SerialNum) override {} void compactLidSpace(search::SerialNum, const search::DocumentIdT) override {} }; diff --git a/searchcore/src/vespa/searchcorespi/index/iindexmanager.h b/searchcore/src/vespa/searchcorespi/index/iindexmanager.h index b6bbe416562a..a54dc422f645 100644 --- a/searchcore/src/vespa/searchcorespi/index/iindexmanager.h +++ b/searchcore/src/vespa/searchcorespi/index/iindexmanager.h @@ -35,7 +35,7 @@ class IIndexManager { using Schema = search::index::Schema; using LidVector = std::vector; public: - using OnWriteDoneType = const std::shared_ptr &; + using OnWriteDoneType = std::shared_ptr; struct Configure { virtual ~Configure() = default; @@ -97,7 +97,7 @@ class IIndexManager { * @param on_write_done shared object that notifies write done when * destructed. **/ - virtual void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, OnWriteDoneType on_write_done) = 0; + virtual void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, const OnWriteDoneType& on_write_done) = 0; /** * Removes the given document from the index. This method is @@ -130,7 +130,7 @@ class IIndexManager { * @param onWriteDone shared object that notifies write done when * destructed. **/ - virtual void commit(SerialNum serialNum, OnWriteDoneType onWriteDone) = 0; + virtual void commit(SerialNum serialNum, const OnWriteDoneType& onWriteDone) = 0; /** * This method is called on a regular basis to update each component with what is the highest diff --git a/searchcore/src/vespa/searchcorespi/index/imemoryindex.h b/searchcore/src/vespa/searchcorespi/index/imemoryindex.h index 4cfb37cb1ea2..d3fdf2dd9420 100644 --- a/searchcore/src/vespa/searchcorespi/index/imemoryindex.h +++ b/searchcore/src/vespa/searchcorespi/index/imemoryindex.h @@ -18,7 +18,7 @@ namespace searchcorespi::index { struct IMemoryIndex : public searchcorespi::IndexSearchable { using LidVector = std::vector; using SP = std::shared_ptr; - using OnWriteDoneType = const std::shared_ptr &; + using OnWriteDoneType = std::shared_ptr; virtual ~IMemoryIndex() {} /** @@ -44,7 +44,7 @@ struct IMemoryIndex : public searchcorespi::IndexSearchable { * @param doc the document to insert. * @param on_write_done shared object that notifies write done when destructed. */ - virtual void insertDocument(uint32_t lid, const document::Document &doc, OnWriteDoneType on_write_done) = 0; + virtual void insertDocument(uint32_t lid, const document::Document &doc, const OnWriteDoneType& on_write_done) = 0; /** * Removes the given document from this memory index. @@ -61,7 +61,7 @@ struct IMemoryIndex : public searchcorespi::IndexSearchable { /** * Commits the inserts and removes since the last commit, making them searchable. **/ - virtual void commit(OnWriteDoneType onWriteDone, search::SerialNum serialNum) = 0; + virtual void commit(const OnWriteDoneType& onWriteDone, search::SerialNum serialNum) = 0; /** * Flushes this memory index to disk as a disk index. diff --git a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp index 9fa489b31782..f0300a1c4827 100644 --- a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp +++ b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp @@ -1203,7 +1203,7 @@ IndexMaintainer::getNumFrozenMemoryIndexes(void) const } void -IndexMaintainer::putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, OnWriteDoneType on_write_done) +IndexMaintainer::putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, const OnWriteDoneType& on_write_done) { assert(_ctx.getThreadingService().index().isCurrentThread()); LockGuard lock(_index_update_lock); @@ -1254,7 +1254,7 @@ IndexMaintainer::commit(vespalib::Gate& gate) } void -IndexMaintainer::commit(SerialNum serialNum, OnWriteDoneType onWriteDone) +IndexMaintainer::commit(SerialNum serialNum, const OnWriteDoneType& onWriteDone) { assert(_ctx.getThreadingService().index().isCurrentThread()); LockGuard lock(_index_update_lock); diff --git a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h index 3e55f75a5d34..89ded5fd2866 100644 --- a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h +++ b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.h @@ -337,9 +337,9 @@ class IndexMaintainer : public IIndexManager, vespalib::system_time getLastFlushTime() const { return _lastFlushTime; } // Implements IIndexManager - void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, OnWriteDoneType on_write_done) override; + void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum, const OnWriteDoneType& on_write_done) override; void removeDocuments(LidVector lids, SerialNum serialNum) override; - void commit(SerialNum serialNum, OnWriteDoneType onWriteDone) override; + void commit(SerialNum serialNum, const OnWriteDoneType& onWriteDone) override; void heartBeat(search::SerialNum serialNum) override; void compactLidSpace(uint32_t lidLimit, SerialNum serialNum) override; diff --git a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp index 0e52bf93369a..972bb6102255 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.cpp @@ -58,7 +58,7 @@ DocumentInverter::~DocumentInverter() } void -DocumentInverter::invertDocument(uint32_t docId, const Document &doc, OnWriteDoneType on_write_done) +DocumentInverter::invertDocument(uint32_t docId, const Document &doc, const OnWriteDoneType& on_write_done) { auto& invert_threads = _context.get_invert_threads(); auto& invert_contexts = _context.get_invert_contexts(); @@ -88,7 +88,7 @@ DocumentInverter::removeDocuments(LidVector lids) } void -DocumentInverter::pushDocuments(OnWriteDoneType on_write_done) +DocumentInverter::pushDocuments(const OnWriteDoneType& on_write_done) { auto retain = std::make_shared(_ref_count); using PushTasks = std::vector>; diff --git a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h index c389e76b985e..3b15c7640397 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h +++ b/searchlib/src/vespa/searchlib/memoryindex/document_inverter.h @@ -38,7 +38,7 @@ class DocumentInverter { DocumentInverterContext& _context; using LidVector = std::vector; - using OnWriteDoneType = const std::shared_ptr &; + using OnWriteDoneType = std::shared_ptr; std::vector> _inverters; std::vector> _urlInverters; @@ -66,7 +66,7 @@ class DocumentInverter { * NOTE: The caller of this function should sync the 'invert threads' executor first, * to ensure that inverting is completed before pushing starts. */ - void pushDocuments(OnWriteDoneType on_write_done); + void pushDocuments(const OnWriteDoneType& on_write_done); /** * Invert (add) the given document. @@ -75,7 +75,7 @@ class DocumentInverter { * For each text and uri field in the document a task for inverting and adding that * field (using a field inverter) is added to the 'invert threads' executor, then this function returns. **/ - void invertDocument(uint32_t docId, const document::Document &doc, OnWriteDoneType on_write_done); + void invertDocument(uint32_t docId, const document::Document &doc, const OnWriteDoneType& on_write_done); /** * Remove the given document. diff --git a/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp b/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp index d0f63ac3cd69..b97f2b2e7cec 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp @@ -25,7 +25,7 @@ get_field_value(const Document& doc, const std::unique_ptr& field) } -InvertTask::InvertTask(const DocumentInverterContext& inv_context, const InvertContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, uint32_t lid, const document::Document& doc, OnWriteDoneType on_write_done) +InvertTask::InvertTask(const DocumentInverterContext& inv_context, const InvertContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, uint32_t lid, const document::Document& doc, const OnWriteDoneType& on_write_done) : _inv_context(inv_context), _context(context), _inverters(inverters), diff --git a/searchlib/src/vespa/searchlib/memoryindex/invert_task.h b/searchlib/src/vespa/searchlib/memoryindex/invert_task.h index 840d0d0daa79..2a415ebfd193 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/invert_task.h +++ b/searchlib/src/vespa/searchlib/memoryindex/invert_task.h @@ -21,16 +21,16 @@ class UrlFieldInverter; */ class InvertTask : public vespalib::Executor::Task { - using OnWriteDoneType = const std::shared_ptr &; + using OnWriteDoneType = std::shared_ptr; const DocumentInverterContext& _inv_context; const InvertContext& _context; const std::vector>& _inverters; const std::vector>& _uri_inverters; const document::Document& _doc; const uint32_t _lid; - std::remove_reference_t _on_write_done; + const OnWriteDoneType _on_write_done; public: - InvertTask(const DocumentInverterContext& inv_context, const InvertContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, uint32_t lid, const document::Document& doc, OnWriteDoneType on_write_done); + InvertTask(const DocumentInverterContext& inv_context, const InvertContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, uint32_t lid, const document::Document& doc, const OnWriteDoneType& on_write_done); ~InvertTask() override; void run() override; }; diff --git a/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp b/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp index f98fc80b9599..9ffa03a7fd12 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/memory_index.cpp @@ -78,7 +78,7 @@ MemoryIndex::MemoryIndex(const Schema& schema, MemoryIndex::~MemoryIndex() = default; void -MemoryIndex::insertDocument(uint32_t docId, const document::Document &doc, OnWriteDoneType on_write_done) +MemoryIndex::insertDocument(uint32_t docId, const document::Document &doc, const OnWriteDoneType& on_write_done) { if (_frozen) { LOG(warning, "Memory index frozen: ignoring insert of document '%s'(%u): '%s'", @@ -112,7 +112,7 @@ MemoryIndex::removeDocuments(LidVector lids) } void -MemoryIndex::commit(OnWriteDoneType on_write_done) +MemoryIndex::commit(const OnWriteDoneType& on_write_done) { auto& inverter = _inverters->get_active_inverter(); inverter.pushDocuments(on_write_done); diff --git a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h index 48c356eaaae2..1495c47ba78f 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h +++ b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h @@ -45,7 +45,7 @@ class MemoryIndex : public queryeval::Searchable { private: using ISequencedTaskExecutor = vespalib::ISequencedTaskExecutor; using LidVector = std::vector; - using OnWriteDoneType = const std::shared_ptr &; + using OnWriteDoneType = std::shared_ptr; index::Schema _schema; ISequencedTaskExecutor &_invertThreads; ISequencedTaskExecutor &_pushThreads; @@ -111,7 +111,7 @@ class MemoryIndex : public queryeval::Searchable { * If the document is already in the index, the old version will be removed first. * This function is async. commit() must be called for changes to take effect. */ - void insertDocument(uint32_t docId, const document::Document &doc, OnWriteDoneType on_write_done); + void insertDocument(uint32_t docId, const document::Document &doc, const OnWriteDoneType& on_write_done); /** * Remove a document from the underlying field indexes. @@ -125,7 +125,7 @@ class MemoryIndex : public queryeval::Searchable { * * When commit is completed, 'on_write_done' goes out of scope, scheduling completion callback. */ - void commit(OnWriteDoneType on_write_done); + void commit(const OnWriteDoneType& on_write_done); /** * Freeze this index. diff --git a/searchlib/src/vespa/searchlib/memoryindex/push_task.cpp b/searchlib/src/vespa/searchlib/memoryindex/push_task.cpp index 52f9e59b76e1..28afa7cdbacc 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/push_task.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/push_task.cpp @@ -19,7 +19,7 @@ void push_inverter(Inverter& inverter) } -PushTask::PushTask(const PushContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, OnWriteDoneType on_write_done, std::shared_ptr retain) +PushTask::PushTask(const PushContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, const OnWriteDoneType& on_write_done, std::shared_ptr retain) : _context(context), _inverters(inverters), _uri_inverters(uri_inverters), diff --git a/searchlib/src/vespa/searchlib/memoryindex/push_task.h b/searchlib/src/vespa/searchlib/memoryindex/push_task.h index 10e8dd324102..34d65621623e 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/push_task.h +++ b/searchlib/src/vespa/searchlib/memoryindex/push_task.h @@ -22,14 +22,14 @@ class UrlFieldInverter; */ class PushTask : public vespalib::Executor::Task { - using OnWriteDoneType = const std::shared_ptr &; + using OnWriteDoneType = std::shared_ptr; const PushContext& _context; const std::vector>& _inverters; const std::vector>& _uri_inverters; - std::remove_reference_t _on_write_done; + const OnWriteDoneType _on_write_done; std::shared_ptr _retain; public: - PushTask(const PushContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, OnWriteDoneType on_write_done, std::shared_ptr retain); + PushTask(const PushContext& context, const std::vector>& inverters, const std::vector>& uri_inverters, const OnWriteDoneType& on_write_done, std::shared_ptr retain); ~PushTask() override; void run() override; };