diff options
author | Tor Egge <Tor.Egge@online.no> | 2021-11-03 22:00:25 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2021-11-03 22:00:25 +0100 |
commit | 8e996033594317202d92c5f9bf6141570fe7f6f0 (patch) | |
tree | daee37ed45ad8d2fdc348d0b1b3bddf5e380e01c /searchcore/src/tests/proton/index | |
parent | 9c3f28fbbdbf5b8be36f994b38f4980ebe7c3e8d (diff) |
Add DocumentInverterCollection.
Diffstat (limited to 'searchcore/src/tests/proton/index')
-rw-r--r-- | searchcore/src/tests/proton/index/fusionrunner_test.cpp | 7 | ||||
-rw-r--r-- | searchcore/src/tests/proton/index/indexmanager_test.cpp | 26 |
2 files changed, 21 insertions, 12 deletions
diff --git a/searchcore/src/tests/proton/index/fusionrunner_test.cpp b/searchcore/src/tests/proton/index/fusionrunner_test.cpp index ca10ff01a69..736bc4bae96 100644 --- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp +++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp @@ -14,6 +14,8 @@ #include <vespa/searchlib/memoryindex/memory_index.h> #include <vespa/searchlib/query/tree/simplequery.h> #include <vespa/searchlib/test/index/mock_field_length_inspector.h> +#include <vespa/vespalib/util/gate.h> +#include <vespa/vespalib/util/destructor_callbacks.h> #include <vespa/vespalib/testkit/testapp.h> #include <set> @@ -156,8 +158,10 @@ void addDocument(DocBuilder & doc_builder, MemoryIndex &index, ISourceSelector & uint8_t index_id, uint32_t docid, const string &word) { Document::UP doc = buildDocument(doc_builder, docid, word); index.insertDocument(docid, *doc); - index.commit(std::shared_ptr<vespalib::IDestructorCallback>()); + vespalib::Gate gate; + index.commit(std::make_shared<vespalib::GateCallback>(gate)); selector.setSource(docid, index_id); + gate.await(); } void Test::createIndex(const string &dir, uint32_t id, bool fusion) { @@ -182,7 +186,6 @@ void Test::createIndex(const string &dir, uint32_t id, bool fusion) { addDocument(doc_builder, memory_index, *_selector, id, id + 1, "bar"); addDocument(doc_builder, memory_index, *_selector, id, id + 2, "baz"); addDocument(doc_builder, memory_index, *_selector, id, id + 3, "qux"); - _threadingService.indexFieldWriter().sync_all(); const uint32_t docIdLimit = std::min(memory_index.getDocIdLimit(), _selector->getDocIdLimit()); diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp index 84cf0e3655f..8e41323e461 100644 --- a/searchcore/src/tests/proton/index/indexmanager_test.cpp +++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp @@ -21,6 +21,8 @@ #include <vespa/searchlib/test/index/mock_field_length_inspector.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/io/fileutil.h> +#include <vespa/vespalib/util/destructor_callbacks.h> +#include <vespa/vespalib/util/gate.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/time.h> @@ -96,6 +98,12 @@ Document::UP buildDocument(DocBuilder &doc_builder, int id, return doc_builder.endDocument(); } +void push_documents_and_wait(search::memoryindex::DocumentInverter &inverter) { + vespalib::Gate gate; + inverter.pushDocuments(std::make_shared<vespalib::GateCallback>(gate)); + gate.await(); +} + std::shared_ptr<vespalib::IDestructorCallback> emptyDestructorCallback; struct IndexManagerTest : public ::testing::Test { @@ -142,10 +150,11 @@ struct IndexManagerTest : public ::testing::Test { Document::UP addDocument(uint32_t docid); void resetIndexManager(); void removeDocument(uint32_t docId, SerialNum serialNum) { + vespalib::Gate gate; runAsIndex([&]() { _index_manager->removeDocument(docId, serialNum); - _index_manager->commit(serialNum, emptyDestructorCallback); + _index_manager->commit(serialNum, std::make_shared<vespalib::GateCallback>(gate)); }); - _writeService.indexFieldWriter().sync_all(); + gate.await(); } void removeDocument(uint32_t docId) { SerialNum serialNum = ++_serial_num; @@ -182,10 +191,11 @@ IndexManagerTest::addDocument(uint32_t id) { Document::UP doc = buildDocument(_builder, id, "foo"); SerialNum serialNum = ++_serial_num; + vespalib::Gate gate; runAsIndex([&]() { _index_manager->putDocument(id, *doc, serialNum); _index_manager->commit(serialNum, - emptyDestructorCallback); }); - _writeService.indexFieldWriter().sync_all(); + std::make_shared<vespalib::GateCallback>(gate)); }); + gate.await(); return doc; } @@ -407,9 +417,7 @@ TEST_F(IndexManagerTest, require_that_flush_stats_are_calculated) Document::UP doc = addDocument(docid); inverter.invertDocument(docid, *doc); - invertThreads->sync_all(); - inverter.pushDocuments(std::shared_ptr<vespalib::IDestructorCallback>()); - pushThreads->sync_all(); + push_documents_and_wait(inverter); index_size = fic.getMemoryUsage().allocatedBytes() - fixed_index_size; /// Must account for both docid 0 being reserved and the extra after. @@ -426,9 +434,7 @@ TEST_F(IndexManagerTest, require_that_flush_stats_are_calculated) inverter.invertDocument(docid + 10, *doc); doc = addDocument(docid + 100); inverter.invertDocument(docid + 100, *doc); - invertThreads->sync_all(); - inverter.pushDocuments(std::shared_ptr<vespalib::IDestructorCallback>()); - pushThreads->sync_all(); + push_documents_and_wait(inverter); index_size = fic.getMemoryUsage().allocatedBytes() - fixed_index_size; /// Must account for both docid 0 being reserved and the extra after. selector_size = (docid + 100 + 1) * sizeof(Source); |