summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-10-12 14:55:04 +0200
committerTor Egge <Tor.Egge@online.no>2022-10-12 14:55:04 +0200
commite1e90137560795397e77203b4e1a75cd3c61396f (patch)
tree194d83650f4cdd245032351abd1967b3985e3a4a /searchcore
parentf329a9d5e0a323b0485dcae52d90987b675808bc (diff)
Remove search::index::DocBuilder. Add search::index::StringFieldBuilder.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp1
-rw-r--r--searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp64
-rw-r--r--searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp6
-rw-r--r--searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h10
-rw-r--r--searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp8
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp9
-rw-r--r--searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp10
-rw-r--r--searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp20
-rw-r--r--searchcore/src/tests/proton/index/fusionrunner_test.cpp24
-rw-r--r--searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp17
-rw-r--r--searchcore/src/tests/proton/index/indexmanager_test.cpp23
-rw-r--r--searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.h9
14 files changed, 124 insertions, 90 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp b/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp
index c66b2dd15dc..19b8348fb7a 100644
--- a/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchcore/proton/attribute/attribute_populator.h>
+#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/searchcore/proton/attribute/attributemanager.h>
#include <vespa/searchcore/proton/common/hw_info.h>
#include <vespa/searchcore/proton/test/test.h>
diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
index e89d5eef078..4fc38992368 100644
--- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
@@ -3,7 +3,11 @@
#include <vespa/persistence/spi/result.h>
#include <vespa/document/datatype/tensor_data_type.h>
#include <vespa/document/datatype/documenttype.h>
+#include <vespa/document/fieldvalue/document.h>
+#include <vespa/document/fieldvalue/stringfieldvalue.h>
+#include <vespa/document/fieldvalue/tensorfieldvalue.h>
#include <vespa/document/update/assignvalueupdate.h>
+#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/update/documentupdate.h>
#include <vespa/document/update/clearvalueupdate.h>
@@ -29,7 +33,7 @@
#include <vespa/searchcore/proton/server/ireplayconfig.h>
#include <vespa/searchcore/proton/test/dummy_feed_view.h>
#include <vespa/searchcore/proton/test/transport_helper.h>
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/transactionlog/translogserver.h>
#include <vespa/vespalib/testkit/testapp.h>
@@ -271,20 +275,33 @@ MyFeedView::~MyFeedView() = default;
struct SchemaContext {
- Schema::SP schema;
- std::unique_ptr<DocBuilder> builder;
+ Schema::SP schema;
+ EmptyDocBuilder builder;
SchemaContext();
+ SchemaContext(bool has_i2);
~SchemaContext();
DocTypeName getDocType() const {
- return DocTypeName(builder->getDocumentType().getName());
+ return DocTypeName(builder.get_document_type().getName());
}
- const std::shared_ptr<const document::DocumentTypeRepo> &getRepo() const { return builder->getDocumentTypeRepo(); }
+ std::shared_ptr<const document::DocumentTypeRepo> getRepo() const { return builder.get_repo_sp(); }
void addField(vespalib::stringref fieldName);
};
SchemaContext::SchemaContext()
+ : SchemaContext(false)
+{
+}
+
+SchemaContext::SchemaContext(bool has_i2)
: schema(std::make_shared<Schema>()),
- builder()
+ builder([has_i2](auto& header) {
+ header.addTensorField("tensor", "tensor(x{},y{})")
+ .addTensorField("tensor2", "tensor(x{},y{})")
+ .addField("i1", document::DataType::T_STRING);
+ if (has_i2) {
+ header.addField("i2", document::DataType::T_STRING);
+ }
+ })
{
schema->addAttributeField(Schema::AttributeField("tensor", DataType::TENSOR, CollectionType::SINGLE, "tensor(x{},y{})"));
schema->addAttributeField(Schema::AttributeField("tensor2", DataType::TENSOR, CollectionType::SINGLE, "tensor(x{},y{})"));
@@ -298,14 +315,13 @@ void
SchemaContext::addField(vespalib::stringref fieldName)
{
schema->addIndexField(Schema::IndexField(fieldName, DataType::STRING, CollectionType::SINGLE));
- builder = std::make_unique<DocBuilder>(*schema);
}
struct DocumentContext {
Document::SP doc;
BucketId bucketId;
- DocumentContext(const vespalib::string &docId, DocBuilder &builder) :
- doc(builder.startDocument(docId).endDocument().release()),
+ DocumentContext(const vespalib::string &docId, EmptyDocBuilder &builder) :
+ doc(builder.make_document(docId)),
bucketId(BucketFactory::getBucketId(doc->getId()))
{
}
@@ -313,7 +329,7 @@ struct DocumentContext {
struct TwoFieldsSchemaContext : public SchemaContext {
TwoFieldsSchemaContext()
- : SchemaContext()
+ : SchemaContext(true)
{
addField("i2");
}
@@ -324,8 +340,8 @@ TensorDataType tensor1DType(ValueType::from_spec("tensor(x{})"));
struct UpdateContext {
DocumentUpdate::SP update;
BucketId bucketId;
- UpdateContext(const vespalib::string &docId, DocBuilder &builder) :
- update(std::make_shared<DocumentUpdate>(*builder.getDocumentTypeRepo(), builder.getDocumentType(), DocumentId(docId))),
+ UpdateContext(const vespalib::string &docId, EmptyDocBuilder &builder) :
+ update(std::make_shared<DocumentUpdate>(builder.get_repo(), builder.get_document_type(), DocumentId(docId))),
bucketId(BucketFactory::getBucketId(update->getId()))
{
}
@@ -464,7 +480,7 @@ TEST_F("require that heartBeat calls FeedView's heartBeat",
TEST_F("require that outdated remove is ignored", FeedHandlerFixture)
{
- DocumentContext doc_context("id:ns:searchdocument::foo", *f.schema.builder);
+ DocumentContext doc_context("id:ns:searchdocument::foo", f.schema.builder);
auto op = std::make_unique<RemoveOperationWithDocId>(doc_context.bucketId, Timestamp(10), doc_context.doc->getId());
static_cast<DocumentOperation &>(*op).setPrevDbDocumentId(DbDocumentId(4));
static_cast<DocumentOperation &>(*op).setPrevTimestamp(Timestamp(10000));
@@ -476,7 +492,7 @@ TEST_F("require that outdated remove is ignored", FeedHandlerFixture)
TEST_F("require that outdated put is ignored", FeedHandlerFixture)
{
- DocumentContext doc_context("id:ns:searchdocument::foo", *f.schema.builder);
+ DocumentContext doc_context("id:ns:searchdocument::foo", f.schema.builder);
auto op =std::make_unique<PutOperation>(doc_context.bucketId, Timestamp(10), std::move(doc_context.doc));
static_cast<DocumentOperation &>(*op).setPrevTimestamp(Timestamp(10000));
FeedTokenContext token_context;
@@ -496,7 +512,7 @@ addLidToRemove(RemoveDocumentsOperation &op)
TEST_F("require that handleMove calls FeedView", FeedHandlerFixture)
{
- DocumentContext doc_context("id:ns:searchdocument::foo", *f.schema.builder);
+ DocumentContext doc_context("id:ns:searchdocument::foo", f.schema.builder);
MoveOperation op(doc_context.bucketId, Timestamp(2), doc_context.doc, DbDocumentId(0, 2), 1);
op.setDbDocumentId(DbDocumentId(1, 2));
f.runAsMaster([&]() { f.handler.handleMove(op, IDestructorCallback::SP()); });
@@ -556,7 +572,7 @@ TEST_F("require that flush cannot unprune", FeedHandlerFixture)
TEST_F("require that remove of unknown document with known data type stores remove", FeedHandlerFixture)
{
- DocumentContext doc_context("id:test:searchdocument::foo", *f.schema.builder);
+ DocumentContext doc_context("id:test:searchdocument::foo", f.schema.builder);
auto op = std::make_unique<RemoveOperationWithDocId>(doc_context.bucketId, Timestamp(10), doc_context.doc->getId());
FeedTokenContext token_context;
f.handler.performOperation(std::move(token_context.token), std::move(op));
@@ -566,7 +582,7 @@ TEST_F("require that remove of unknown document with known data type stores remo
TEST_F("require that partial update for non-existing document is tagged as such", FeedHandlerFixture)
{
- UpdateContext upCtx("id:test:searchdocument::foo", *f.schema.builder);
+ UpdateContext upCtx("id:test:searchdocument::foo", f.schema.builder);
auto op = std::make_unique<UpdateOperation>(upCtx.bucketId, Timestamp(10), upCtx.update);
FeedTokenContext token_context;
f.handler.performOperation(std::move(token_context.token), std::move(op));
@@ -582,7 +598,7 @@ TEST_F("require that partial update for non-existing document is tagged as such"
TEST_F("require that partial update for non-existing document is created if specified", FeedHandlerFixture)
{
f.handler.setSerialNum(15);
- UpdateContext upCtx("id:test:searchdocument::foo", *f.schema.builder);
+ UpdateContext upCtx("id:test:searchdocument::foo", f.schema.builder);
upCtx.update->setCreateIfNonExistent(true);
f.feedView.metaStore.insert(upCtx.update->getId().getGlobalId(), MyDocumentMetaStore::Entry(5, 5, Timestamp(10)));
auto op = std::make_unique<UpdateOperation>(upCtx.bucketId, Timestamp(10), upCtx.update);
@@ -605,7 +621,7 @@ TEST_F("require that put is rejected if resource limit is reached", FeedHandlerF
f.writeFilter._acceptWriteOperation = false;
f.writeFilter._message = "Attribute resource limit reached";
- DocumentContext docCtx("id:test:searchdocument::foo", *f.schema.builder);
+ DocumentContext docCtx("id:test:searchdocument::foo", f.schema.builder);
auto op = std::make_unique<PutOperation>(docCtx.bucketId, Timestamp(10), std::move(docCtx.doc));
FeedTokenContext token;
f.handler.performOperation(std::move(token.token), std::move(op));
@@ -620,7 +636,7 @@ TEST_F("require that update is rejected if resource limit is reached", FeedHandl
f.writeFilter._acceptWriteOperation = false;
f.writeFilter._message = "Attribute resource limit reached";
- UpdateContext updCtx("id:test:searchdocument::foo", *f.schema.builder);
+ UpdateContext updCtx("id:test:searchdocument::foo", f.schema.builder);
updCtx.addFieldUpdate("tensor");
auto op = std::make_unique<UpdateOperation>(updCtx.bucketId, Timestamp(10), updCtx.update);
FeedTokenContext token;
@@ -637,7 +653,7 @@ TEST_F("require that remove is NOT rejected if resource limit is reached", FeedH
f.writeFilter._acceptWriteOperation = false;
f.writeFilter._message = "Attribute resource limit reached";
- DocumentContext docCtx("id:test:searchdocument::foo", *f.schema.builder);
+ DocumentContext docCtx("id:test:searchdocument::foo", f.schema.builder);
auto op = std::make_unique<RemoveOperationWithDocId>(docCtx.bucketId, Timestamp(10), docCtx.doc->getId());
FeedTokenContext token;
f.handler.performOperation(std::move(token.token), std::move(op));
@@ -651,7 +667,7 @@ checkUpdate(FeedHandlerFixture &f, SchemaContext &schemaContext,
const vespalib::string &fieldName, bool expectReject, bool existing)
{
f.handler.setSerialNum(15);
- UpdateContext updCtx("id:test:searchdocument::foo", *schemaContext.builder);
+ UpdateContext updCtx("id:test:searchdocument::foo", schemaContext.builder);
updCtx.addFieldUpdate(fieldName);
if (existing) {
f.feedView.metaStore.insert(updCtx.update->getId().getGlobalId(), MyDocumentMetaStore::Entry(5, 5, Timestamp(9)));
@@ -733,7 +749,7 @@ TEST_F("require that tensor update with wrong tensor type fails", FeedHandlerFix
TEST_F("require that put with different document type repo is ok", FeedHandlerFixture)
{
TwoFieldsSchemaContext schema;
- DocumentContext doc_context("id:ns:searchdocument::foo", *schema.builder);
+ DocumentContext doc_context("id:ns:searchdocument::foo", schema.builder);
auto op = std::make_unique<PutOperation>(doc_context.bucketId,
Timestamp(10), std::move(doc_context.doc));
FeedTokenContext token_context;
@@ -747,7 +763,7 @@ TEST_F("require that put with different document type repo is ok", FeedHandlerFi
TEST_F("require that feed stats are updated", FeedHandlerFixture)
{
- DocumentContext doc_context("id:ns:searchdocument::foo", *f.schema.builder);
+ DocumentContext doc_context("id:ns:searchdocument::foo", f.schema.builder);
auto op =std::make_unique<PutOperation>(doc_context.bucketId, Timestamp(10), std::move(doc_context.doc));
FeedTokenContext token_context;
f.handler.performOperation(std::move(token_context.token), std::move(op));
diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp
index 9c68d7d5974..b3a2e9cad83 100644
--- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp
+++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.cpp
@@ -127,7 +127,8 @@ MyHandler::handleCompactLidSpace(const CompactLidSpaceOperation &op, std::shared
}
MyHandler::MyHandler(bool storeMoveDoneContexts, bool bucketIdEqualLid)
- : _stats(),
+ : _builder(),
+ _stats(),
_moveFromLid(0),
_moveToLid(0),
_handleMoveCnt(0),
@@ -140,9 +141,8 @@ MyHandler::MyHandler(bool storeMoveDoneContexts, bool bucketIdEqualLid)
_rm_listener(),
_docs()
{
- DocBuilder builder = DocBuilder(Schema());
for (uint32_t i(0); i < 10; i++) {
- auto doc = builder.startDocument(fmt("%s%d", DOC_ID.c_str(), i)).endDocument();
+ auto doc = _builder.make_document(fmt("%s%d", DOC_ID.c_str(), i));
_docs.emplace_back(DocumentMetaData(i, TIMESTAMP_1, createBucketId(i), doc->getId().getGlobalId()), std::move(doc));
}
}
diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h
index b404fc6956a..806729a108c 100644
--- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h
+++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_common.h
@@ -17,11 +17,14 @@
#include <vespa/searchcore/proton/test/test.h>
#include <vespa/searchcore/proton/test/dummy_document_store.h>
#include <vespa/vespalib/util/idestructorcallback.h>
-#include <vespa/searchlib/index/docbuilder.h>
-using namespace document;
+using document::BucketId;
+using document::GlobalId;
+using document::Document;
+using document::DocumentId;
+using document::DocumentTypeRepo;
using namespace proton;
-using namespace search::index;
+using search::index::EmptyDocBuilder;
using namespace search;
using namespace vespalib;
using vespalib::IDestructorCallback;
@@ -60,6 +63,7 @@ struct MyScanIterator : public IDocumentScanIterator {
};
struct MyHandler : public ILidSpaceCompactionHandler {
+ EmptyDocBuilder _builder;
std::vector<LidUsageStats> _stats;
std::vector<LidVector> _lids;
mutable uint32_t _moveFromLid;
diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp
index bc9cd9a93fa..fd38853dca1 100644
--- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_handler_test.cpp
@@ -5,7 +5,7 @@
#include <vespa/vespalib/gtest/gtest.h>
struct HandlerTest : public ::testing::Test {
- DocBuilder _docBuilder;
+ EmptyDocBuilder _docBuilder;
std::shared_ptr<bucketdb::BucketDBOwner> _bucketDB;
MyDocumentStore _docStore;
MySubDb _subDb;
@@ -15,13 +15,13 @@ struct HandlerTest : public ::testing::Test {
};
HandlerTest::HandlerTest()
- : _docBuilder(Schema()),
+ : _docBuilder(),
_bucketDB(std::make_shared<bucketdb::BucketDBOwner>()),
_docStore(),
- _subDb(_bucketDB, _docStore, _docBuilder.getDocumentTypeRepo()),
+ _subDb(_bucketDB, _docStore, _docBuilder.get_repo_sp()),
_handler(_subDb.maintenance_sub_db, "test")
{
- _docStore._readDoc = _docBuilder.startDocument(DOC_ID).endDocument();
+ _docStore._readDoc = _docBuilder.make_document(DOC_ID);
}
HandlerTest::~HandlerTest() = default;
diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
index ea4d556c502..915402122b8 100644
--- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
@@ -35,7 +35,6 @@
#include <vespa/searchcore/proton/test/test.h>
#include <vespa/searchcore/proton/test/transport_helper.h>
#include <vespa/searchlib/common/idocumentmetastore.h>
-#include <vespa/searchlib/index/docbuilder.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
@@ -99,11 +98,11 @@ class MyDocumentSubDB
uint32_t _subDBId;
DocumentMetaStore::SP _metaStoreSP;
DocumentMetaStore & _metaStore;
- const std::shared_ptr<const document::DocumentTypeRepo> &_repo;
+ std::shared_ptr<const document::DocumentTypeRepo> _repo;
const DocTypeName &_docTypeName;
public:
- MyDocumentSubDB(uint32_t subDBId, SubDbType subDbType, const std::shared_ptr<const document::DocumentTypeRepo> &repo,
+ MyDocumentSubDB(uint32_t subDBId, SubDbType subDbType, std::shared_ptr<const document::DocumentTypeRepo> repo,
std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, const DocTypeName &docTypeName);
~MyDocumentSubDB();
@@ -136,7 +135,7 @@ public:
const IDocumentMetaStore &getMetaStore() const { return _metaStore; }
};
-MyDocumentSubDB::MyDocumentSubDB(uint32_t subDBId, SubDbType subDbType, const std::shared_ptr<const document::DocumentTypeRepo> &repo,
+MyDocumentSubDB::MyDocumentSubDB(uint32_t subDBId, SubDbType subDbType, std::shared_ptr<const document::DocumentTypeRepo> repo,
std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, const DocTypeName &docTypeName)
: _docs(),
_subDBId(subDBId),
@@ -144,7 +143,7 @@ MyDocumentSubDB::MyDocumentSubDB(uint32_t subDBId, SubDbType subDbType, const st
std::move(bucketDB), DocumentMetaStore::getFixedName(), search::GrowStrategy(),
subDbType)),
_metaStore(*_metaStoreSP),
- _repo(repo),
+ _repo(std::move(repo)),
_docTypeName(docTypeName)
{
_metaStore.constructFreeList();
diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp
index 00694b6b78f..67342df5613 100644
--- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/document/base/documentid.h>
#include <vespa/document/datatype/datatype.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/searchcommon/common/schema.h>
#include <vespa/searchcore/proton/server/putdonecontext.h>
#include <vespa/searchcore/proton/server/removedonecontext.h>
@@ -13,7 +14,7 @@
#include <vespa/searchcore/proton/test/mock_summary_adapter.h>
#include <vespa/searchcore/proton/test/transport_helper.h>
#include <vespa/searchcore/proton/test/thread_utils.h>
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/testkit/testapp.h>
@@ -32,7 +33,7 @@ using namespace proton;
using search::DocumentIdT;
using vespalib::IDestructorCallback;
using search::SerialNum;
-using search::index::DocBuilder;
+using search::index::EmptyDocBuilder;
using search::index::Schema;
using storage::spi::Timestamp;
using vespalib::make_string;
@@ -59,9 +60,8 @@ public:
};
std::shared_ptr<const DocumentTypeRepo> myGetDocumentTypeRepo() {
- Schema schema;
- DocBuilder builder(schema);
- std::shared_ptr<const DocumentTypeRepo> repo = builder.getDocumentTypeRepo();
+ EmptyDocBuilder builder;
+ std::shared_ptr<const DocumentTypeRepo> repo = builder.get_repo_sp();
ASSERT_TRUE(repo.get());
return repo;
}
diff --git a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp
index ac540ad2e2d..49f13d8c5b5 100644
--- a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp
+++ b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp
@@ -3,6 +3,8 @@
#include <vespa/document/datatype/datatype.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/fieldvalue/fieldvalue.h>
+#include <vespa/document/fieldvalue/stringfieldvalue.h>
+#include <vespa/document/repo/configbuilder.h>
#include <vespa/searchlib/common/documentsummary.h>
#include <vespa/vespalib/util/sequencedtaskexecutor.h>
#include <vespa/searchlib/common/flush_token.h>
@@ -10,8 +12,9 @@
#include <vespa/searchlib/diskindex/fusion.h>
#include <vespa/searchlib/diskindex/indexbuilder.h>
#include <vespa/searchlib/fef/fef.h>
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
+#include <vespa/searchlib/index/string_field_builder.h>
#include <vespa/searchlib/memoryindex/memory_index.h>
#include <vespa/searchlib/test/index/mock_field_length_inspector.h>
#include <vespa/searchlib/query/base.h>
@@ -31,6 +34,7 @@ LOG_SETUP("feed_and_search_test");
using document::DataType;
using document::Document;
using document::FieldValue;
+using document::StringFieldValue;
using search::DocumentIdT;
using search::FlushToken;
using search::TuneFileIndexing;
@@ -44,9 +48,10 @@ using search::fef::MatchData;
using search::fef::MatchDataLayout;
using search::fef::TermFieldHandle;
using search::fef::TermFieldMatchData;
-using search::index::DocBuilder;
+using search::index::EmptyDocBuilder;
using search::index::DummyFileHeaderContext;
using search::index::Schema;
+using search::index::StringFieldBuilder;
using search::index::test::MockFieldLengthInspector;
using search::memoryindex::MemoryIndex;
using search::query::SimpleStringTerm;
@@ -113,14 +118,13 @@ Schema getSchema() {
return schema;
}
-Document::UP buildDocument(DocBuilder & doc_builder, int id,
+Document::UP buildDocument(EmptyDocBuilder & doc_builder, int id,
const string &word) {
ostringstream ost;
ost << "id:ns:searchdocument::" << id;
- doc_builder.startDocument(ost.str());
- doc_builder.startIndexField(field_name)
- .addStr(noise).addStr(word).endField();
- return doc_builder.endDocument();
+ auto doc = doc_builder.make_document(ost.str());
+ doc->setValue(field_name, StringFieldBuilder(doc_builder).word(noise).space().word(word).build());
+ return doc;
}
// Performs a search using a Searchable.
@@ -165,7 +169,7 @@ void Test::requireThatMemoryIndexCanBeDumpedAndSearched() {
auto indexFieldInverter = vespalib::SequencedTaskExecutor::create(invert_executor, 2);
auto indexFieldWriter = vespalib::SequencedTaskExecutor::create(write_executor, 2);
MemoryIndex memory_index(schema, MockFieldLengthInspector(), *indexFieldInverter, *indexFieldWriter);
- DocBuilder doc_builder(schema);
+ EmptyDocBuilder doc_builder([](auto& header) { header.addField(field_name, DataType::T_STRING); });
Document::UP doc = buildDocument(doc_builder, doc_id1, word1);
memory_index.insertDocument(doc_id1, *doc, {});
diff --git a/searchcore/src/tests/proton/index/fusionrunner_test.cpp b/searchcore/src/tests/proton/index/fusionrunner_test.cpp
index 850f8a8f0d1..166d34f366b 100644
--- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp
+++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp
@@ -1,15 +1,19 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/searchcorespi/index/fusionrunner.h>
+#include <vespa/document/fieldvalue/document.h>
+#include <vespa/document/fieldvalue/stringfieldvalue.h>
+#include <vespa/document/repo/configbuilder.h>
#include <vespa/searchcore/proton/index/indexmanager.h>
#include <vespa/searchcore/proton/test/transport_helper.h>
-#include <vespa/searchcorespi/index/fusionrunner.h>
#include <vespa/vespalib/util/isequencedtaskexecutor.h>
#include <vespa/searchlib/common/flush_token.h>
#include <vespa/searchlib/diskindex/diskindex.h>
#include <vespa/searchlib/diskindex/indexbuilder.h>
#include <vespa/searchlib/fef/matchdatalayout.h>
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
+#include <vespa/searchlib/index/string_field_builder.h>
#include <vespa/searchlib/memoryindex/memory_index.h>
#include <vespa/searchlib/query/tree/simplequery.h>
#include <vespa/searchlib/test/index/mock_field_length_inspector.h>
@@ -25,6 +29,7 @@
using document::Document;
using document::FieldValue;
+using document::StringFieldValue;
using proton::ExecutorThreadingService;
using proton::index::IndexManager;
using search::FixedSourceSelector;
@@ -38,9 +43,10 @@ using search::fef::MatchData;
using search::fef::MatchDataLayout;
using search::fef::TermFieldHandle;
using search::fef::TermFieldMatchData;
-using search::index::DocBuilder;
+using search::index::EmptyDocBuilder;
using search::index::DummyFileHeaderContext;
using search::index::Schema;
+using search::index::StringFieldBuilder;
using search::index::schema::DataType;
using search::index::test::MockFieldLengthInspector;
using search::memoryindex::MemoryIndex;
@@ -149,15 +155,15 @@ void Test::tearDown() {
_selector.reset(0);
}
-Document::UP buildDocument(DocBuilder & doc_builder, int id, const string &word) {
+Document::UP buildDocument(EmptyDocBuilder & doc_builder, int id, const string &word) {
vespalib::asciistream ost;
ost << "id:ns:searchdocument::" << id;
- doc_builder.startDocument(ost.str());
- doc_builder.startIndexField(field_name).addStr(word).endField();
- return doc_builder.endDocument();
+ auto doc = doc_builder.make_document(ost.str());
+ doc->setValue(field_name, StringFieldBuilder(doc_builder).word(word).build());
+ return doc;
}
-void addDocument(DocBuilder & doc_builder, MemoryIndex &index, ISourceSelector &selector,
+void addDocument(EmptyDocBuilder & doc_builder, MemoryIndex &index, ISourceSelector &selector,
uint8_t index_id, uint32_t docid, const string &word) {
Document::UP doc = buildDocument(doc_builder, docid, word);
index.insertDocument(docid, *doc, {});
@@ -181,7 +187,7 @@ void Test::createIndex(const string &dir, uint32_t id, bool fusion) {
_selector->setDefaultSource(id - _selector->getBaseId());
Schema schema = getSchema();
- DocBuilder doc_builder(schema);
+ EmptyDocBuilder doc_builder([](auto& header) { header.addField(field_name, document::DataType::T_STRING); });
MemoryIndex memory_index(schema, MockFieldLengthInspector(),
_service.write().indexFieldInverter(),
_service.write().indexFieldWriter());
diff --git a/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp b/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp
index 75e6b01b46f..7202d7f0abe 100644
--- a/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp
+++ b/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp
@@ -1,10 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/testkit/testapp.h>
-
#include <vespa/searchcore/proton/index/index_writer.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/searchcore/proton/test/mock_index_manager.h>
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
+#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/util/stringfmt.h>
+
#include <vespa/log/log.h>
LOG_SETUP("index_writer_test");
@@ -80,21 +82,18 @@ struct Fixture
IIndexManager::SP iim;
MyIndexManager &mim;
IndexWriter iw;
- Schema schema;
- DocBuilder builder;
+ EmptyDocBuilder builder;
Document::UP dummyDoc;
Fixture()
: iim(new MyIndexManager()),
mim(static_cast<MyIndexManager &>(*iim)),
iw(iim),
- schema(),
- builder(schema),
+ builder(),
dummyDoc(createDoc(1234)) // This content of this is not used
{
}
Document::UP createDoc(uint32_t lid) {
- builder.startDocument(vespalib::make_string("id:ns:searchdocument::%u", lid));
- return builder.endDocument();
+ return builder.make_document(vespalib::make_string("id:ns:searchdocument::%u", lid));
}
void put(SerialNum serialNum, const search::DocumentIdT lid) {
iw.put(serialNum, *dummyDoc, lid, {});
diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp
index b427daa4ad1..886978f7465 100644
--- a/searchcore/src/tests/proton/index/indexmanager_test.cpp
+++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp
@@ -1,6 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchcore/proton/index/indexmanager.h>
+#include <vespa/document/fieldvalue/document.h>
+#include <vespa/document/fieldvalue/stringfieldvalue.h>
+#include <vespa/document/repo/configbuilder.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/searchcore/proton/test/transport_helper.h>
#include <vespa/searchcorespi/index/index_manager_stats.h>
#include <vespa/searchcorespi/index/indexcollection.h>
@@ -9,8 +13,9 @@
#include <vespa/vespalib/util/sequencedtaskexecutor.h>
#include <vespa/searchlib/common/flush_token.h>
#include <vespa/searchlib/common/serialnum.h>
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
+#include <vespa/searchlib/index/string_field_builder.h>
#include <vespa/searchlib/memoryindex/compact_words_store.h>
#include <vespa/searchlib/memoryindex/document_inverter.h>
#include <vespa/searchlib/memoryindex/document_inverter_context.h>
@@ -34,6 +39,7 @@ LOG_SETUP("indexmanager_test");
using document::Document;
using document::FieldValue;
+using document::StringFieldValue;
using proton::index::IndexConfig;
using proton::index::IndexManager;
using vespalib::SequencedTaskExecutor;
@@ -42,10 +48,11 @@ using search::TuneFileAttributes;
using search::TuneFileIndexManager;
using search::TuneFileIndexing;
using vespalib::datastore::EntryRef;
-using search::index::DocBuilder;
+using search::index::EmptyDocBuilder;
using search::index::DummyFileHeaderContext;
using search::index::FieldLengthInfo;
using search::index::Schema;
+using search::index::StringFieldBuilder;
using search::index::schema::DataType;
using search::index::test::MockFieldLengthInspector;
using search::memoryindex::CompactWordsStore;
@@ -88,13 +95,13 @@ void removeTestData() {
std::filesystem::remove_all(std::filesystem::path(index_dir));
}
-Document::UP buildDocument(DocBuilder &doc_builder, int id,
+Document::UP buildDocument(EmptyDocBuilder &doc_builder, int id,
const string &word) {
vespalib::asciistream ost;
ost << "id:ns:searchdocument::" << id;
- doc_builder.startDocument(ost.str());
- doc_builder.startIndexField(field_name).addStr(word).endField();
- return doc_builder.endDocument();
+ auto doc = doc_builder.make_document(ost.str());
+ doc->setValue(field_name, StringFieldBuilder(doc_builder).word(word).build());
+ return doc;
}
void push_documents_and_wait(search::memoryindex::DocumentInverter &inverter) {
@@ -110,7 +117,7 @@ struct IndexManagerTest : public ::testing::Test {
TransportAndExecutorService _service;
std::unique_ptr<IndexManager> _index_manager;
Schema _schema;
- DocBuilder _builder;
+ EmptyDocBuilder _builder;
IndexManagerTest()
: _serial_num(0),
@@ -119,7 +126,7 @@ struct IndexManagerTest : public ::testing::Test {
_service(1),
_index_manager(),
_schema(getSchema()),
- _builder(_schema)
+ _builder([](auto& header) { header.addField(field_name, document::DataType::T_STRING); })
{
removeTestData();
std::filesystem::create_directory(std::filesystem::path(index_dir));
diff --git a/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp b/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp
index da645f9a94b..719e762288e 100644
--- a/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp
+++ b/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp
@@ -3,7 +3,7 @@
LOG_SETUP("document_reprocessing_handler_test");
#include <vespa/searchcore/proton/reprocessing/document_reprocessing_handler.h>
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
#include <vespa/vespalib/testkit/testapp.h>
using namespace document;
@@ -32,17 +32,17 @@ const vespalib::string DOC_ID = "id:test:searchdocument::0";
struct FixtureBase
{
DocumentReprocessingHandler _handler;
- DocBuilder _docBuilder;
+ EmptyDocBuilder _docBuilder;
FixtureBase(uint32_t docIdLimit);
~FixtureBase();
std::shared_ptr<Document> createDoc() {
- return _docBuilder.startDocument(DOC_ID).endDocument();
+ return _docBuilder.make_document(DOC_ID);
}
};
FixtureBase::FixtureBase(uint32_t docIdLimit)
: _handler(docIdLimit),
- _docBuilder(Schema())
+ _docBuilder()
{ }
FixtureBase::~FixtureBase() {}
diff --git a/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.cpp b/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.cpp
index 2cdf1c45485..f9f98705144 100644
--- a/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.cpp
+++ b/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.cpp
@@ -5,8 +5,7 @@
namespace proton::test {
UserDocumentsBuilder::UserDocumentsBuilder()
- : _schema(),
- _builder(_schema),
+ : _builder(),
_docs()
{
}
@@ -17,7 +16,7 @@ UserDocumentsBuilder &
UserDocumentsBuilder::createDoc(uint32_t userId, search::DocumentIdT lid)
{
vespalib::string docId = vespalib::make_string("id:test:searchdocument:n=%u:%u", userId, lid);
- document::Document::SP doc(_builder.startDocument(docId).endDocument().release());
+ document::Document::SP doc(_builder.make_document(docId));
_docs.addDoc(userId, Document(doc, lid, storage::spi::Timestamp(lid)));
return *this;
}
diff --git a/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.h b/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.h
index f05b6da11de..9e806c8a0bf 100644
--- a/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.h
+++ b/searchcore/src/vespa/searchcore/proton/test/userdocumentsbuilder.h
@@ -2,7 +2,7 @@
#pragma once
#include "userdocuments.h"
-#include <vespa/searchlib/index/docbuilder.h>
+#include <vespa/searchlib/index/empty_doc_builder.h>
#include <vespa/vespalib/util/stringfmt.h>
namespace proton::test {
@@ -13,14 +13,13 @@ namespace proton::test {
class UserDocumentsBuilder
{
private:
- search::index::Schema _schema;
- search::index::DocBuilder _builder;
+ search::index::EmptyDocBuilder _builder;
UserDocuments _docs;
public:
UserDocumentsBuilder();
~UserDocumentsBuilder();
- const std::shared_ptr<const document::DocumentTypeRepo> &getRepo() const {
- return _builder.getDocumentTypeRepo();
+ std::shared_ptr<const document::DocumentTypeRepo> getRepo() const {
+ return _builder.get_repo_sp();
}
UserDocumentsBuilder &createDoc(uint32_t userId, search::DocumentIdT lid);
UserDocumentsBuilder &createDocs(uint32_t userId, search::DocumentIdT begin,