summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-25 17:00:53 +0100
committerGitHub <noreply@github.com>2021-03-25 17:00:53 +0100
commitb7b15f6ab97d12f675e180a0ea215500086d08ad (patch)
tree5c39615436eeba60990c7201fb000fec1e3ffd4b
parent637a6f880a2ca09ef549b157750a04d679c66b78 (diff)
parent7c4eb18409f536b08a2365db11add6ea1fabcf3d (diff)
Merge pull request #17184 from vespa-engine/revert-17171-balder/avoid-expensive-dynamic_cast
Revert "- Avoid inlining exchange_location_nodes to be able to see its execut…"
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp22
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/querynodes.h5
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/intermediate.h1
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/node.h5
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/termnodes.h1
5 files changed, 13 insertions, 21 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index 39936126a99..994e26081e7 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -36,7 +36,6 @@ using search::queryeval::IntermediateBlueprint;
using search::queryeval::Blueprint;
using search::queryeval::IRequestContext;
using search::queryeval::SearchIterator;
-using search::query::LocationTerm;
using vespalib::string;
using std::vector;
@@ -60,17 +59,16 @@ inject(Node::UP query, Node::UP to_inject) {
return query;
}
-std::vector<LocationTerm *>
+std::vector<ProtonLocationTerm *>
find_location_terms(Node *tree) {
- std::vector<LocationTerm *> retval;
+ std::vector<ProtonLocationTerm *> retval;
std::vector<Node *> nodes;
nodes.push_back(tree);
- for (Node * node : nodes) {
- if (node->isLocationTerm()) {
- retval.push_back(static_cast<LocationTerm *>(node));
+ for (size_t i = 0; i < nodes.size(); ++i) {
+ if (auto loc = dynamic_cast<ProtonLocationTerm *>(nodes[i])) {
+ retval.push_back(loc);
}
- if (node->isIntermediate()) {
- auto parent = static_cast<const search::query::Intermediate *>(node);
+ if (auto parent = dynamic_cast<const search::query::Intermediate *>(nodes[i])) {
for (Node * child : parent->getChildren()) {
nodes.push_back(child);
}
@@ -94,7 +92,7 @@ GeoLocationSpec parse_location_string(string str) {
return empty;
}
-GeoLocationSpec process_location_term(LocationTerm &pterm) {
+GeoLocationSpec process_location_term(ProtonLocationTerm &pterm) {
auto old_view = pterm.getView();
auto new_view = PositionDataType::getZCurveFieldName(old_view);
pterm.setView(new_view);
@@ -103,10 +101,6 @@ GeoLocationSpec process_location_term(LocationTerm &pterm) {
}
void exchange_location_nodes(const string &location_str,
- Node::UP &query_tree,
- std::vector<GeoLocationSpec> &fef_locations) __attribute__((noinline));
-
-void exchange_location_nodes(const string &location_str,
Node::UP &query_tree,
std::vector<GeoLocationSpec> &fef_locations)
{
@@ -116,7 +110,7 @@ void exchange_location_nodes(const string &location_str,
if (parsed.location.valid()) {
locationSpecs.push_back(parsed);
}
- for (LocationTerm * pterm : find_location_terms(query_tree.get())) {
+ for (ProtonLocationTerm * pterm : find_location_terms(query_tree.get())) {
auto spec = process_location_term(*pterm);
if (spec.location.valid()) {
locationSpecs.push_back(spec);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/querynodes.h b/searchcore/src/vespa/searchcore/proton/matching/querynodes.h
index 65a236e4e6e..6cb608c8f8c 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/querynodes.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/querynodes.h
@@ -98,7 +98,7 @@ struct ProtonTermBase : public Base,
};
template <typename Base>
-struct ProtonTerm final : public ProtonTermBase<Base> {
+struct ProtonTerm : public ProtonTermBase<Base> {
using ProtonTermBase<Base>::ProtonTermBase;
~ProtonTerm();
};
@@ -116,7 +116,8 @@ typedef search::query::SimpleWeakAnd ProtonWeakAnd;
typedef search::query::SimpleSameElement ProtonSameElement;
-struct ProtonEquiv final : public ProtonTermBase<search::query::Equiv> {
+struct ProtonEquiv final : public ProtonTermBase<search::query::Equiv>
+{
search::fef::MatchDataLayout children_mdl;
using ProtonTermBase::ProtonTermBase;
};
diff --git a/searchlib/src/vespa/searchlib/query/tree/intermediate.h b/searchlib/src/vespa/searchlib/query/tree/intermediate.h
index 2bdc0104927..2f4323f8e87 100644
--- a/searchlib/src/vespa/searchlib/query/tree/intermediate.h
+++ b/searchlib/src/vespa/searchlib/query/tree/intermediate.h
@@ -17,7 +17,6 @@ class Intermediate : public Node
Intermediate() = default;
virtual ~Intermediate() = 0;
- bool isIntermediate() const override { return true; }
const std::vector<Node *> &getChildren() const { return _children; }
Intermediate &reserve(size_t sz) { _children.reserve(sz); return *this; }
diff --git a/searchlib/src/vespa/searchlib/query/tree/node.h b/searchlib/src/vespa/searchlib/query/tree/node.h
index 2ad6237a1fd..4ef0d3b6fc8 100644
--- a/searchlib/src/vespa/searchlib/query/tree/node.h
+++ b/searchlib/src/vespa/searchlib/query/tree/node.h
@@ -15,10 +15,9 @@ class Node {
public:
typedef std::unique_ptr<Node> UP;
- virtual ~Node() = default;
+ virtual ~Node() {}
+
virtual void accept(QueryVisitor &visitor) = 0;
- virtual bool isIntermediate() const { return false; }
- virtual bool isLocationTerm() const { return false; }
};
}
diff --git a/searchlib/src/vespa/searchlib/query/tree/termnodes.h b/searchlib/src/vespa/searchlib/query/tree/termnodes.h
index 3eda0732470..e112fd6e295 100644
--- a/searchlib/src/vespa/searchlib/query/tree/termnodes.h
+++ b/searchlib/src/vespa/searchlib/query/tree/termnodes.h
@@ -86,7 +86,6 @@ public:
int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight)
{}
- bool isLocationTerm() const override { return true; }
virtual ~LocationTerm() = 0;
};