diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-26 16:22:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 16:22:06 +0100 |
commit | bbde3f07da8ba72fc17a1e9cecd7f11d03c41b62 (patch) | |
tree | 24077881376353c904232800cfdc7eb29a7ca883 /searchlib | |
parent | af3c06a7f151dae8c57b4b3c0e50ef64e3285e05 (diff) | |
parent | a77d301703076d9f3ca81053d2ed017ec50fde23 (diff) |
Merge pull request #17201 from vespa-engine/balder/reduce-inlining-and-template-arguments
Remove template parameter not needed and reduce inlining.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp | 52 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp | 3 |
2 files changed, 31 insertions, 24 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index 5ba38d803c8..0c4c5271763 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -620,17 +620,11 @@ public: void visit(PredicateQuery &n) override { visitPredicate(n); } void visit(RegExpTerm & n) override { visitTerm(n); } - template <typename WS, typename NODE> - void createDirectWeightedSet(WS *bp, NODE &n) { - Blueprint::UP result(bp); - for (size_t i = 0; i < n.getChildren().size(); ++i) { - const query::Node &node = *n.getChildren()[i]; - vespalib::string term = queryeval::termAsString(node); - uint32_t weight = queryeval::getWeightFromNode(node).percent(); - bp->addTerm(term, weight); - } - setResult(std::move(result)); - } + template <typename WS> + void createDirectWeightedSet(WS *bp, search::query::Intermediate &n); + + template <typename WS> + void createShallowWeightedSet(WS *bp, search::query::Intermediate &n, const FieldSpec &fs, bool isInteger); static QueryTermSimple::UP extractTerm(const query::Node &node, bool isInteger) { @@ -641,18 +635,6 @@ public: return std::make_unique<QueryTermUCS4>(term, QueryTermSimple::Type::WORD); } - template <typename WS, typename NODE> - void createShallowWeightedSet(WS *bp, NODE &n, const FieldSpec &fs, bool isInteger) { - Blueprint::UP result(bp); - for (size_t i = 0; i < n.getChildren().size(); ++i) { - const query::Node &node = *n.getChildren()[i]; - uint32_t weight = queryeval::getWeightFromNode(node).percent(); - FieldSpec childfs = bp->getNextChildField(fs); - bp->addTerm(std::make_unique<AttributeFieldBlueprint>(childfs, _attr, extractTerm(node, isInteger)), weight); - } - setResult(std::move(result)); - } - void visit(query::WeightedSetTerm &n) override { bool isSingleValue = !_attr.hasMultiValue(); bool isString = (_attr.isStringType() && _attr.hasEnum()); @@ -741,6 +723,30 @@ public: } }; +template <typename WS> +void +CreateBlueprintVisitor::createDirectWeightedSet(WS *bp, search::query::Intermediate &n) { + Blueprint::UP result(bp); + for (const Node * node : n.getChildren()) { + vespalib::string term = queryeval::termAsString(*node); + uint32_t weight = queryeval::getWeightFromNode(*node).percent(); + bp->addTerm(term, weight); + } + setResult(std::move(result)); +} + +template <typename WS> +void +CreateBlueprintVisitor::createShallowWeightedSet(WS *bp, search::query::Intermediate &n, const FieldSpec &fs, bool isInteger) { + Blueprint::UP result(bp); + for (const Node * node : n.getChildren()) { + uint32_t weight = queryeval::getWeightFromNode(*node).percent(); + FieldSpec childfs = bp->getNextChildField(fs); + bp->addTerm(std::make_unique<AttributeFieldBlueprint>(childfs, _attr, extractTerm(*node, isInteger)), weight); + } + setResult(std::move(result)); +} + } // namespace //----------------------------------------------------------------------------- diff --git a/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp b/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp index bd9de0a1762..344cf90da12 100644 --- a/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp @@ -18,7 +18,8 @@ struct WeightExtractor : public TemplateTermVisitor<WeightExtractor, SimpleQuery WeightExtractor() : weight(0) {} - template <class TermType> void visitTerm(TermType &n) { + template <class TermType> + void visitTerm(TermType &n) { weight = n.getWeight(); } |