summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2019-09-10 12:43:16 +0000
committerHåvard Pettersen <havardpe@oath.com>2019-09-12 08:16:57 +0000
commit333c328766f65a209aa83bbbfcff28d15805e75e (patch)
treef7ea7d59d2bf87f6bea39a54053c6071c9d2517d /searchcore
parent17a6c5033b0b45becf8a3ef382d51599fe9afd57 (diff)
added empty skeleton for unpacking iterators optimizer
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/CMakeLists.txt3
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.h26
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.cpp19
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.h21
6 files changed, 67 insertions, 15 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/matching/CMakeLists.txt
index d700aeba6b6..b687576a0f0 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/CMakeLists.txt
+++ b/searchcore/src/vespa/searchcore/proton/matching/CMakeLists.txt
@@ -19,6 +19,7 @@ vespa_add_library(searchcore_matching STATIC
match_tools.cpp
matcher.cpp
matching_stats.cpp
+ unpacking_iterators_optimizer.cpp
partial_result.cpp
query.cpp
queryenvironment.cpp
@@ -27,8 +28,8 @@ vespa_add_library(searchcore_matching STATIC
ranking_constants.cpp
requestcontext.cpp
result_processor.cpp
- sameelementmodifier.cpp
same_element_builder.cpp
+ sameelementmodifier.cpp
search_session.cpp
session_manager_explorer.cpp
sessionmanager.cpp
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
index 5d1e2212c83..22912671def 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
@@ -164,12 +164,15 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
_rankSetup(rankSetup),
_featureOverrides(featureOverrides),
_diversityParams(),
- _valid(_query.buildTree(queryStack, location, viewResolver, indexEnv))
+ _valid(false)
{
+ _query.setWhiteListBlueprint(metaStore.createWhiteListBlueprint());
+ _valid = _query.buildTree(queryStack, location, viewResolver, indexEnv,
+ rankSetup.split_unpacking_iterators(),
+ rankSetup.delay_unpacking_iterators());
if (_valid) {
_query.extractTerms(_queryEnv.terms());
_query.extractLocations(_queryEnv.locations());
- _query.setWhiteListBlueprint(metaStore.createWhiteListBlueprint());
_query.reserveHandles(_requestContext, searchContext, _mdl);
_query.optimize();
_query.fetchPostings();
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index 351de63de37..fb9882bf1b1 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -6,6 +6,7 @@
#include "resolveviewvisitor.h"
#include "termdataextractor.h"
#include "sameelementmodifier.h"
+#include "unpacking_iterators_optimizer.h"
#include <vespa/document/datatype/positiondatatype.h>
#include <vespa/searchlib/common/location.h>
#include <vespa/searchlib/parsequery/stackdumpiterator.h>
@@ -118,7 +119,8 @@ Query::~Query() = default;
bool
Query::buildTree(vespalib::stringref stack, const string &location,
- const ViewResolver &resolver, const IIndexEnvironment &indexEnv)
+ const ViewResolver &resolver, const IIndexEnvironment &indexEnv,
+ bool split_unpacking_iterators, bool delay_unpacking_iterators)
{
SimpleQueryStackDumpIterator stack_dump_iterator(stack);
_query_tree = QueryTreeCreator<ProtonNodeTypes>::create(stack_dump_iterator);
@@ -126,6 +128,8 @@ Query::buildTree(vespalib::stringref stack, const string &location,
SameElementModifier prefixSameElementSubIndexes;
_query_tree->accept(prefixSameElementSubIndexes);
addLocationNode(location, _query_tree, _location);
+ _query_tree = UnpackingIteratorsOptimizer::optimize(std::move(_query_tree),
+ bool(_whiteListBlueprint), split_unpacking_iterators, delay_unpacking_iterators);
ResolveViewVisitor resolve_visitor(resolver, indexEnv);
_query_tree->accept(resolve_visitor);
return true;
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.h b/searchcore/src/vespa/searchcore/proton/matching/query.h
index 58d1d249ce6..11aade1c59b 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.h
@@ -28,6 +28,18 @@ public:
Query();
~Query();
/**
+ * Use the given blueprint as white list node in the blueprint
+ * tree. The search iterator created by this blueprint should
+ * return all visible / active documents as hits. These hits will
+ * then be part of the result set for the query executed. Setting
+ * this before building the query will enable additional
+ * optimizations.
+ *
+ * @param whiteListBlueprint the blueprint used for white listing.
+ **/
+ void setWhiteListBlueprint(Blueprint::UP whiteListBlueprint);
+
+ /**
* Build query tree from a stack dump.
*
* @return success(true)/failure(false)
@@ -35,7 +47,9 @@ public:
bool buildTree(vespalib::stringref stack,
const vespalib::string &location,
const ViewResolver &resolver,
- const search::fef::IIndexEnvironment &idxEnv);
+ const search::fef::IIndexEnvironment &idxEnv,
+ bool split_unpacking_iterators = false,
+ bool delay_unpacking_iterators = false);
/**
* Extract query terms from the query tree; to be used to build
@@ -54,16 +68,6 @@ public:
void extractLocations(std::vector<const search::fef::Location *> &locs);
/**
- * Use the given blueprint as white list node in the blueprint tree.
- * The search iterator created by this blueprint should return all
- * visible / active documents as hits. These hits will then be
- * part of the result set for the query executed.
- *
- * @param whiteListBlueprint the blueprint used for white listing.
- **/
- void setWhiteListBlueprint(Blueprint::UP whiteListBlueprint);
-
- /**
* Reserve room for terms in the query in the given match data
* layout. This function also prepares the createSearch function
* for use.
diff --git a/searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.cpp b/searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.cpp
new file mode 100644
index 00000000000..7b053bf8930
--- /dev/null
+++ b/searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.cpp
@@ -0,0 +1,19 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "unpacking_iterators_optimizer.h"
+
+namespace proton::matching {
+
+search::query::Node::UP
+UnpackingIteratorsOptimizer::optimize(search::query::Node::UP root,
+ bool has_white_list,
+ bool split_unpacking_iterators,
+ bool delay_unpacking_iterators)
+{
+ (void) has_white_list;
+ (void) split_unpacking_iterators;
+ (void) delay_unpacking_iterators;
+ return std::move(root); // nop for now
+}
+
+}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.h b/searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.h
new file mode 100644
index 00000000000..8f1c146ae95
--- /dev/null
+++ b/searchcore/src/vespa/searchcore/proton/matching/unpacking_iterators_optimizer.h
@@ -0,0 +1,21 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/searchlib/query/tree/node.h>
+
+namespace proton::matching {
+
+/**
+ * Unpacking iterators are indirectly optimized by augmenting the
+ * query tree and by tagging appropriate query tree nodes as
+ * expensive.
+ **/
+struct UnpackingIteratorsOptimizer {
+ static search::query::Node::UP optimize(search::query::Node::UP root,
+ bool has_white_list,
+ bool split_unpacking_iterators,
+ bool delay_unpacking_iterators);
+};
+
+}