diff options
3 files changed, 56 insertions, 26 deletions
diff --git a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp index cc8238a50a1..bef4c748034 100644 --- a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp @@ -1,24 +1,18 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".features.rankingexpression"); +#include "rankingexpressionfeature.h" +#include "utils.h" #include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/features/rankingexpression/feature_name_extractor.h> -#include <vespa/vespalib/util/stringfmt.h> -#include <vespa/eval/eval/function.h> #include <vespa/eval/eval/interpreted_function.h> #include <vespa/eval/eval/llvm/compiled_function.h> #include <vespa/eval/eval/llvm/compile_cache.h> -#include <vespa/eval/eval/node_types.h> -#include "rankingexpressionfeature.h" -#include "utils.h" -#include <stdexcept> -#include <vespa/eval/eval/value_type.h> -#include <vespa/searchlib/fef/feature_type.h> #include <vespa/eval/tensor/default_tensor_engine.h> +#include <vespa/log/log.h> +LOG_SETUP(".features.rankingexpression"); + using vespalib::eval::Function; using vespalib::eval::PassParams; using vespalib::eval::CompileCache; diff --git a/searchlib/src/vespa/searchlib/queryeval/dot_product_search.cpp b/searchlib/src/vespa/searchlib/queryeval/dot_product_search.cpp index f23b23f7a6b..b37f49113e7 100644 --- a/searchlib/src/vespa/searchlib/queryeval/dot_product_search.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/dot_product_search.cpp @@ -6,6 +6,7 @@ using search::fef::TermFieldMatchData; +using search::fef::MatchData; using vespalib::ObjectVisitor; namespace search { @@ -26,22 +27,22 @@ private: } }; - fef::TermFieldMatchData &_tmd; - std::vector<int32_t> _weights; - std::vector<uint32_t> _termPos; - CmpDocId _cmpDocId; - std::vector<ref_t> _data_space; - ref_t *_data_begin; - ref_t *_data_stash; - ref_t *_data_end; - IteratorPack _children; + TermFieldMatchData &_tmd; + std::vector<int32_t> _weights; + std::vector<uint32_t> _termPos; + CmpDocId _cmpDocId; + std::vector<ref_t> _data_space; + ref_t *_data_begin; + ref_t *_data_stash; + ref_t *_data_end; + IteratorPack _children; void seek_child(ref_t child, uint32_t docId) { _termPos[child] = _children.seek(child, docId); } public: - DotProductSearchImpl(search::fef::TermFieldMatchData &tmd, + DotProductSearchImpl(TermFieldMatchData &tmd, const std::vector<int32_t> &weights, IteratorPack &&iteratorPack) : _tmd(tmd), @@ -107,19 +108,54 @@ public: void visitMembers(vespalib::ObjectVisitor &) const override {} }; +class SingleQueryDotProductSearch : public SearchIterator { +public: + SingleQueryDotProductSearch(TermFieldMatchData &tmd, SearchIterator::UP child, + const TermFieldMatchData &childTmd, feature_t weight, MatchData::UP md) + : _child(std::move(child)), + _childTmd(childTmd), + _tmd(tmd), + _weight(weight), + _md(std::move(md)) + { } +private: + void doSeek(uint32_t docid) override { + _child->doSeek(docid); + setDocId(_child->getDocId()); + } + + void doUnpack(uint32_t docid) override { + _tmd.setRawScore(docid, _weight*_childTmd.getWeight()); + } + + void initRange(uint32_t beginId, uint32_t endId) override { + SearchIterator::initRange(beginId, endId); + _child->initRange(beginId, endId); + } + SearchIterator::UP _child; + const TermFieldMatchData &_childTmd; + TermFieldMatchData &_tmd; + feature_t _weight; + MatchData::UP _md; +}; + //----------------------------------------------------------------------------- SearchIterator::UP DotProductSearch::create(const std::vector<SearchIterator*> &children, - search::fef::TermFieldMatchData &tmd, - const std::vector<fef::TermFieldMatchData*> &childMatch, + TermFieldMatchData &tmd, + const std::vector<TermFieldMatchData*> &childMatch, const std::vector<int32_t> &weights, - fef::MatchData::UP md) + MatchData::UP md) { typedef DotProductSearchImpl<vespalib::LeftArrayHeap, SearchIteratorPack> ArrayHeapImpl; typedef DotProductSearchImpl<vespalib::LeftHeap, SearchIteratorPack> HeapImpl; + if (childMatch.size() == 1) { + return std::make_unique<SingleQueryDotProductSearch>(tmd, SearchIterator::UP(children[0]), + *childMatch[0], weights[0], std::move(md)); + } if (childMatch.size() < 128) { return SearchIterator::UP(new ArrayHeapImpl(tmd, weights, SearchIteratorPack(children, childMatch, std::move(md)))); } @@ -129,7 +165,7 @@ DotProductSearch::create(const std::vector<SearchIterator*> &children, //----------------------------------------------------------------------------- SearchIterator::UP -DotProductSearch::create(search::fef::TermFieldMatchData &tmd, +DotProductSearch::create(TermFieldMatchData &tmd, const std::vector<int32_t> &weights, std::vector<DocumentWeightIterator> &&iterators) { diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp b/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp index 87a043b3428..a04f136f814 100644 --- a/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp +++ b/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp @@ -59,7 +59,7 @@ T computeDotProduct(const T * af, const T * bf, size_t sz) } template <typename T, size_t VLEN, size_t VectorsPerChunk=4> -VESPA_DLL_LOCAL static T dotProductSelectAlignment(const T * af, const T * bf, size_t sz); +VESPA_DLL_LOCAL T dotProductSelectAlignment(const T * af, const T * bf, size_t sz); template <typename T, size_t VLEN, size_t VectorsPerChunk> T dotProductSelectAlignment(const T * af, const T * bf, size_t sz) |