diff options
Diffstat (limited to 'searchlib')
6 files changed, 21 insertions, 85 deletions
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 6d0a566021d..944d0a543f5 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 @@ -343,7 +343,7 @@ Fixture::put(const Document &doc, uint32_t lid) { ++_syncToken; assert(lid < _docIdLimit); - _store->write(_syncToken, doc, lid); + _store->write(_syncToken, lid, doc); _valid->slowSetBit(lid); } diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index d41adb2cdef..82a158fd53e 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -464,7 +464,7 @@ public: write(id, makeDoc(_repo, id, false)); } void write(uint32_t id, Document::UP doc) { - getStore().write(_serial++, *doc, id); + getStore().write(_serial++, id, *doc); _inserted[id] = std::move(doc); } void remove(uint32_t id) { diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp index d154250d6a1..d07d4658f1f 100644 --- a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp @@ -242,10 +242,14 @@ DocumentStore::read(DocumentIdT lid, const DocumentTypeRepo &repo) const } void -DocumentStore::write(uint64_t syncToken, const document::Document& doc, DocumentIdT lid) -{ +DocumentStore::write(uint64_t syncToken, DocumentIdT lid, const document::Document& doc) { nbostream stream(12345); doc.serialize(stream); + write(syncToken, lid, stream); +} + +void +DocumentStore::write(uint64_t syncToken, DocumentIdT lid, const vespalib::nbostream & stream) { _backingStore.write(syncToken, lid, stream.peek(), stream.size()); if (useCache()) { _cache->invalidate(lid); @@ -371,7 +375,7 @@ void DocumentStore::WrapVisitor<IDocumentStoreRewriteVisitor>:: rewrite(uint32_t lid, const document::Document &doc) { - _ds.write(_syncToken, doc, lid); + _ds.write(_syncToken, lid, doc); } template <> diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.h b/searchlib/src/vespa/searchlib/docstore/documentstore.h index 82012757924..632e6e266f8 100644 --- a/searchlib/src/vespa/searchlib/docstore/documentstore.h +++ b/searchlib/src/vespa/searchlib/docstore/documentstore.h @@ -60,115 +60,45 @@ public: DocumentStore(const Config & config, IDataStore & store); ~DocumentStore(); - /** - * Make a Document from a stored serialized data blob. - * @param lid The local ID associated with the document. - * @return NULL if there is no document associated with the lid. - **/ document::Document::UP read(DocumentIdT lid, const document::DocumentTypeRepo &repo) const override; void visit(const LidVector & lids, const document::DocumentTypeRepo &repo, IDocumentVisitor & visitor) const override; - - /** - * Serialize and store a document. - * @param doc The document to store - * @param lid The local ID associated with the document - **/ - void write(uint64_t synkToken, const document::Document& doc, DocumentIdT lid) override; - - /** - * Mark a document as removed. A later read() will return NULL for the given lid. - * @param lid The local ID associated with the document - **/ + void write(uint64_t synkToken, DocumentIdT lid, const document::Document& doc) override; + void write(uint64_t synkToken, DocumentIdT lid, const vespalib::nbostream & os) override; void remove(uint64_t syncToken, DocumentIdT lid) override; - - /** - * Flush all in-memory updates to disk. - **/ void flush(uint64_t syncToken) override; uint64_t initFlush(uint64_t synctoken) override; - - - /** - * If possible compact the disk. - **/ void compact(uint64_t syncToken) override; - - /** - * The sync token used for the last successful flush() operation, - * or 0 if no flush() has been performed yet. - * @return Last flushed sync token. - **/ uint64_t lastSyncToken() const override; uint64_t tentativeLastSyncToken() const override; fastos::TimeStamp getLastFlushTime() const override; - - /** - * Get the number of entries (including removed IDs - * or gaps in the local ID sequence) in the document store. - */ uint32_t getDocIdLimit() const override { return _backingStore.getDocIdLimit(); } - - /** - * Calculate memory used by this instance. During flush() actual - * memory usage may be approximately twice the reported amount. - * @return memory usage (in bytes) - **/ size_t memoryUsed() const override { return _backingStore.memoryUsed(); } size_t getDiskFootprint() const override { return _backingStore.getDiskFootprint(); } size_t getDiskBloat() const override { return _backingStore.getDiskBloat(); } size_t getMaxCompactGain() const override { return _backingStore.getMaxCompactGain(); } - CacheStats getCacheStats() const override; - - /** - * Calculates memory that is used for meta data by this instance. Calling - * flush() does not free this memory. - * @return memory usage (in bytes) - **/ size_t memoryMeta() const override { return _backingStore.memoryMeta(); } - const vespalib::string & getBaseDir() const override { return _backingStore.getBaseDir(); } - - /** - * Visit all documents found in document store. - */ void accept(IDocumentStoreReadVisitor &visitor, IDocumentStoreVisitorProgress &visitorProgress, const document::DocumentTypeRepo &repo) override; - - /** - * Visit all documents found in document store. - */ void accept(IDocumentStoreRewriteVisitor &visitor, IDocumentStoreVisitorProgress &visitorProgress, const document::DocumentTypeRepo &repo) override; - - /** - * Return cost of visiting all documents found in document store. - */ double getVisitCost() const override; - - /* - * Return brief stats for data store. - */ DataStoreStorageStats getStorageStats() const override; - MemoryUsage getMemoryUsage() const override; - - /* - * Return detailed stats about underlying files for data store. - */ std::vector<DataStoreFileChunkStats> getFileChunkStats() const override; /** * Implements common::ICompactableLidSpace */ - virtual void compactLidSpace(uint32_t wantedDocLidLimit) override; - virtual bool canShrinkLidSpace() const override; - virtual size_t getEstimatedShrinkLidSpaceGain() const override; - virtual void shrinkLidSpace() override; + void compactLidSpace(uint32_t wantedDocLidLimit) override; + bool canShrinkLidSpace() const override; + size_t getEstimatedShrinkLidSpaceGain() const override; + void shrinkLidSpace() override; private: bool useCache() const; diff --git a/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp b/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp index 7ba496008c3..a17f376d911 100644 --- a/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/idocumentstore.cpp @@ -19,4 +19,3 @@ void IDocumentStore::visit(const LidVector & lids, const document::DocumentTypeR } } // namespace search - diff --git a/searchlib/src/vespa/searchlib/docstore/idocumentstore.h b/searchlib/src/vespa/searchlib/docstore/idocumentstore.h index 7e8076c81da..62b7b2891fc 100644 --- a/searchlib/src/vespa/searchlib/docstore/idocumentstore.h +++ b/searchlib/src/vespa/searchlib/docstore/idocumentstore.h @@ -6,6 +6,7 @@ #include <vespa/searchlib/common/i_compactable_lid_space.h> #include <vespa/searchlib/docstore/idatastore.h> #include <vespa/searchlib/query/base.h> +#include <future> namespace search { @@ -54,8 +55,9 @@ public: /** * Convenience typedef for a shared pointer to this class. **/ - typedef std::shared_ptr<IDocumentStore> SP; - typedef std::vector<uint32_t> LidVector; + using SP = std::shared_ptr<IDocumentStore>; + using LidVector = std::vector<uint32_t>; + /** * Construct a document store. @@ -80,7 +82,8 @@ public: * @param doc The document to store * @param lid The local ID associated with the document **/ - virtual void write(uint64_t syncToken, const document::Document& doc, DocumentIdT lid) = 0; + virtual void write(uint64_t syncToken, DocumentIdT lid, const document::Document& doc) = 0; + virtual void write(uint64_t synkToken, DocumentIdT lid, const vespalib::nbostream & os) = 0; /** * Mark a document as removed. A later read() will return NULL for the given lid. |