diff options
author | Henning Baldersheim <balder@oath.com> | 2018-05-23 11:48:30 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-05-23 23:21:04 +0200 |
commit | f5b42665aae94251816cf2871b36950ceb29f943 (patch) | |
tree | 2b82f3c7f08fa5a0e23659da158e198b9e717bbf | |
parent | 54224af953af3d3a3822bfbcc4f7c0c85bbfcfa9 (diff) |
Implement doUnpack
3 files changed, 21 insertions, 8 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index a786f95163f..6bc9ef20994 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -126,12 +126,14 @@ public: { } - SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { + SearchIterator::UP + createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { assert(tfmda.size() == 1); return _search_context->createIterator(tfmda[0], strict); } - void fetchPostings(bool strict) override { + void + fetchPostings(bool strict) override { _search_context->fetchPostings(strict); } diff --git a/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp b/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp index 57c3265e313..30230be6592 100644 --- a/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp +++ b/searchlib/src/vespa/searchlib/attribute/elementiterator.cpp @@ -2,6 +2,9 @@ #include "elementiterator.h" #include <vespa/searchcommon/attribute/i_search_context.h> +#include <vespa/searchlib/fef/termfieldmatchdata.h> + +using search::fef::TermFieldMatchDataPosition; namespace search::attribute { @@ -12,7 +15,12 @@ ElementIterator::doSeek(uint32_t docid) { void ElementIterator::doUnpack(uint32_t docid) { - (void) 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)) { + _tfmda.appendPosition(TermFieldMatchDataPosition(id, 0, weight, 1)); + } } vespalib::Trinary @@ -26,9 +34,10 @@ ElementIterator::initRange(uint32_t beginid, uint32_t endid) { SearchIterator::initRange(_search->getDocId()+1, _search->getEndId()); } -ElementIterator::ElementIterator(SearchIterator::UP search, ISearchContext & sc) +ElementIterator::ElementIterator(SearchIterator::UP search, ISearchContext & sc, fef::TermFieldMatchData & tfmda) : _search(std::move(search)), - _searchContext(sc) + _searchContext(sc), + _tfmda(tfmda) { } diff --git a/searchlib/src/vespa/searchlib/attribute/elementiterator.h b/searchlib/src/vespa/searchlib/attribute/elementiterator.h index 884d92948fb..0af859eada7 100644 --- a/searchlib/src/vespa/searchlib/attribute/elementiterator.h +++ b/searchlib/src/vespa/searchlib/attribute/elementiterator.h @@ -4,6 +4,7 @@ #include <vespa/searchlib/queryeval/searchiterator.h> +namespace search::fef { class TermFieldMatchData; } namespace search::attribute { class ISearchContext; @@ -11,15 +12,16 @@ class ISearchContext; class ElementIterator : public queryeval::SearchIterator { private: - SearchIterator::UP _search; - ISearchContext & _searchContext; + SearchIterator::UP _search; + ISearchContext & _searchContext; + fef::TermFieldMatchData & _tfmda; void doSeek(uint32_t docid) override; void doUnpack(uint32_t docid) override; Trinary is_strict() const override; void initRange(uint32_t beginid, uint32_t endid) override; public: - ElementIterator(SearchIterator::UP search, ISearchContext & sc); + ElementIterator(SearchIterator::UP search, ISearchContext & sc, fef::TermFieldMatchData & tfmda); ~ElementIterator(); }; |