summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-03-29 11:44:44 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-03-29 11:45:52 +0000
commitc78e09977b3b9e076dbe86cf85015e58a25c8b22 (patch)
tree5ba5aa67e2457d203568ca7f413c82ea3b56e913
parent399a5dc9b483ca40690b940ecebb6fea96cdbc7d (diff)
Avoid going via stackdump.
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
index 07689e5ffec..192d498125c 100644
--- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
@@ -83,20 +83,28 @@ private:
ISearchContext::UP _search_context;
AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute,
- const string &query_stack, const attribute::SearchContextParams &params)
+ QueryTermSimple::UP term, const attribute::SearchContextParams &params)
: SimpleLeafBlueprint(field),
- _search_context(attribute.createSearchContext(QueryTermDecoder::decodeTerm(query_stack), params))
+ _search_context(attribute.createSearchContext(std::move(term), params))
{
uint32_t estHits = _search_context->approximateHits();
HitEstimate estimate(estHits, estHits == 0);
setEstimate(estimate);
}
+ AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute,
+ const string &query_stack, const attribute::SearchContextParams &params)
+ : AttributeFieldBlueprint(field, attribute, QueryTermDecoder::decodeTerm(query_stack), params)
+ { }
+
public:
- AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute, const string &query_stack)
- : AttributeFieldBlueprint(field, attribute, query_stack,
+ AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute, QueryTermSimple::UP term)
+ : AttributeFieldBlueprint(field, attribute, std::move(term),
attribute::SearchContextParams().useBitVector(field.isFilter()))
{}
+ AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute, const string &query_stack)
+ : AttributeFieldBlueprint(field, attribute, QueryTermDecoder::decodeTerm(query_stack))
+ {}
AttributeFieldBlueprint(const FieldSpec &field, const IAttributeVector &attribute,
const IAttributeVector &diversity, const string &query_stack,
@@ -512,15 +520,23 @@ public:
setResult(std::move(result));
}
+ static QueryTermSimple::UP
+ extractTerm(const query::Node &node, bool isInteger) {
+ vespalib::string term = queryeval::termAsString(node);
+ if (isInteger) {
+ return std::make_unique<QueryTermSimple>(term, QueryTermSimple::WORD);
+ }
+ return std::make_unique<QueryTermBase>(term, QueryTermSimple::WORD);
+ }
+
template <typename WS, typename NODE>
- void createShallowWeightedSet(WS *bp, NODE &n, const FieldSpec &fs) {
+ 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();
- const string stack = StackDumpCreator::create(node);
FieldSpec childfs = bp->getNextChildField(fs);
- bp->addTerm(std::make_unique<AttributeFieldBlueprint>(childfs, _attr, stack), weight);
+ bp->addTerm(std::make_unique<AttributeFieldBlueprint>(childfs, _attr, extractTerm(node, isInteger)), weight);
}
setResult(std::move(result));
}
@@ -534,14 +550,7 @@ public:
for (size_t i = 0; i < n.getChildren().size(); ++i) {
const query::Node &node = *n.getChildren()[i];
uint32_t weight = queryeval::getWeightFromNode(node).percent();
- vespalib::string term = queryeval::termAsString(node);
- QueryTermSimple::UP qt;
- if (isInteger) {
- qt = std::make_unique<QueryTermSimple>(term, QueryTermSimple::WORD);
- } else {
- qt = std::make_unique<QueryTermBase>(term, QueryTermSimple::WORD);
- }
- ws->addToken(_attr.createSearchContext(std::move(qt), attribute::SearchContextParams()), weight);
+ ws->addToken(_attr.createSearchContext(extractTerm(node, isInteger), attribute::SearchContextParams()), weight);
}
setResult(std::move(ws));
} else {
@@ -550,7 +559,7 @@ public:
createDirectWeightedSet(bp, n);
} else {
auto *bp = new WeightedSetTermBlueprint(_field);
- createShallowWeightedSet(bp, n, _field);
+ createShallowWeightedSet(bp, n, _field, _attr.isIntegerType());
}
}
}
@@ -561,7 +570,7 @@ public:
createDirectWeightedSet(bp, n);
} else {
auto *bp = new DotProductBlueprint(_field);
- createShallowWeightedSet(bp, n, _field);
+ createShallowWeightedSet(bp, n, _field, _attr.isIntegerType());
}
}
@@ -576,7 +585,7 @@ public:
n.getTargetNumHits(),
n.getScoreThreshold(),
n.getThresholdBoostFactor());
- createShallowWeightedSet(bp, n, _field);
+ createShallowWeightedSet(bp, n, _field, _attr.isIntegerType());
}
}
};