summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/documentdb
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore/src/tests/proton/documentdb')
-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
6 files changed, 63 insertions, 44 deletions
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;
}