From ec25fafaa3b922c688113bdefac2d12feb9fdca8 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 23 May 2018 13:18:29 +0200 Subject: Ensure conformance tests pass. --- .../attribute/searchcontext/searchcontext.cpp | 37 +++++++++++++++------- .../vespa/searchlib/attribute/elementiterator.cpp | 7 ++-- 2 files changed, 29 insertions(+), 15 deletions(-) (limited to 'searchlib') diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp index cbc86b02ada..70fde827a6b 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -620,21 +621,30 @@ void SearchContextTest::testSearch(const ConfigMap & cfgs) { template class Verifier : public search::test::SearchIteratorVerifier { public: - Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg); + Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, + const Config & cfg, bool withElementId); ~Verifier(); - SearchIterator::UP create(bool strict) const override { - return _sc->createIterator(&_dummy, strict); + SearchIterator::UP + create(bool strict) const override { + auto search = _sc->createIterator(&_dummy, strict); + if (_withElementId) { + search = std::make_unique(std::move(search), *_sc, _dummy); + } + return search; } private: mutable TermFieldMatchData _dummy; - AttributePtr _attribute; + const bool _withElementId; + AttributePtr _attribute; SearchContextPtr _sc; }; template -Verifier::Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg) - :_attribute(AttributeFactory::createAttribute(name + "-initrange", cfg)), - _sc() +Verifier::Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, + const Config & cfg, bool withElementId) + : _withElementId(withElementId), + _attribute(AttributeFactory::createAttribute(name + "-initrange", cfg)), + _sc() { SearchContextTest::addDocs(*_attribute, getDocIdLimit()); for (uint32_t doc : getExpectedDocIds()) { @@ -648,15 +658,18 @@ Verifier::Verifier(T key, const vespalib::string & keyAsString, const vesp } template -Verifier::~Verifier() {} +Verifier::~Verifier() = default; template void SearchContextTest::testSearchIterator(T key, const vespalib::string &keyAsString, const ConfigMap &cfgs) { - for (const auto & cfg : cfgs) { - Verifier verifier(key, keyAsString, cfg.first, cfg.second); - verifier.verify(); + for (bool withElementId : {false, true} ) { + for (const auto & cfg : cfgs) { + Verifier verifier(key, keyAsString, cfg.first, cfg.second, withElementId); + verifier.verify(); + } } + } void SearchContextTest::testSearchIteratorConformance() { @@ -1894,7 +1907,7 @@ SearchContextTest::SearchContextTest() : initStringConfig(); } -SearchContextTest::~SearchContextTest() {} +SearchContextTest::~SearchContextTest() = default; int SearchContextTest::Main() diff --git a/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp b/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp index 30230be6592..68fb178105e 100644 --- a/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp +++ b/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp @@ -11,14 +11,15 @@ namespace search::attribute { void ElementIterator::doSeek(uint32_t docid) { _search->doSeek(docid); + setDocId(_search->getDocId()); } void ElementIterator::doUnpack(uint32_t docid) { - int32_t weight(0); - int32_t id(0); _tfmda.reset(docid); - for (id = _searchContext.find(docid, 0, weight); id >= 0; id = _searchContext.find(docid, 0, weight)) { + _search->doUnpack(docid); + int32_t weight(0); + for (int32_t id = _searchContext.find(docid, 0, weight); id >= 0; id = _searchContext.find(docid, 0, weight)) { _tfmda.appendPosition(TermFieldMatchDataPosition(id, 0, weight, 1)); } } -- cgit v1.2.3