summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/index
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/src/tests/proton/index
parentf329a9d5e0a323b0485dcae52d90987b675808bc (diff)
Remove search::index::DocBuilder. Add search::index::StringFieldBuilder.
Diffstat (limited to 'searchcore/src/tests/proton/index')
-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
3 files changed, 38 insertions, 26 deletions
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));