diff options
author | Henning Baldersheim <balder@oath.com> | 2018-05-23 13:18:29 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-05-23 23:21:04 +0200 |
commit | ec25fafaa3b922c688113bdefac2d12feb9fdca8 (patch) | |
tree | ad71c4f7b718bf558035c8a8b6200b780ba48751 /searchlib | |
parent | f5b42665aae94251816cf2871b36950ceb29f943 (diff) |
Ensure conformance tests pass.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/attribute/searchcontext/searchcontext.cpp | 37 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/elementiterator.cpp | 7 |
2 files changed, 29 insertions, 15 deletions
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 <vespa/searchlib/attribute/singlenumericattribute.h> #include <vespa/searchlib/attribute/singlestringattribute.h> #include <vespa/searchlib/attribute/multistringattribute.h> +#include <vespa/searchlib/attribute/elementiterator.h> #include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/fef/matchdata.h> #include <vespa/searchlib/fef/termfieldmatchdataarray.h> @@ -620,21 +621,30 @@ void SearchContextTest::testSearch(const ConfigMap & cfgs) { template<typename T, typename A> 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<attribute::ElementIterator>(std::move(search), *_sc, _dummy); + } + return search; } private: mutable TermFieldMatchData _dummy; - AttributePtr _attribute; + const bool _withElementId; + AttributePtr _attribute; SearchContextPtr _sc; }; template<typename T, typename A> -Verifier<T, A>::Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg) - :_attribute(AttributeFactory::createAttribute(name + "-initrange", cfg)), - _sc() +Verifier<T, A>::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<T, A>::Verifier(T key, const vespalib::string & keyAsString, const vesp } template<typename T, typename A> -Verifier<T, A>::~Verifier() {} +Verifier<T, A>::~Verifier() = default; template<typename T, typename A> void SearchContextTest::testSearchIterator(T key, const vespalib::string &keyAsString, const ConfigMap &cfgs) { - for (const auto & cfg : cfgs) { - Verifier<T, A> verifier(key, keyAsString, cfg.first, cfg.second); - verifier.verify(); + for (bool withElementId : {false, true} ) { + for (const auto & cfg : cfgs) { + Verifier<T, A> 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)); } } |