summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/select/resultlist.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/document/src/vespa/document/select/resultlist.cpp b/document/src/vespa/document/select/resultlist.cpp
index 60361223a64..cd633004d26 100644
--- a/document/src/vespa/document/select/resultlist.cpp
+++ b/document/src/vespa/document/select/resultlist.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "resultlist.h"
+#include <vespa/vespalib/stllike/hash_set.h>
#include <ostream>
namespace document::select {
@@ -96,39 +97,56 @@ ResultList::combineVariables(
ResultList
ResultList::operator&&(const ResultList& other) const
{
- ResultList result;
+ ResultList results;
// TODO: optimize
+ vespalib::hash_set<uint32_t> resultForNoVariables;
for (const auto & it : _results) {
for (const auto & it2 : other._results) {
fieldvalue::VariableMap vars = it.first;
if (combineVariables(vars, it2.first)) {
- result.add(vars, *it.second && *it2.second);
+ const Result & result = *it.second && *it2.second;
+ if (vars.empty()) {
+ resultForNoVariables.insert(result.toEnum());
+ } else {
+ results.add(vars, result);
+ }
}
}
}
+ for (uint32_t result : resultForNoVariables) {
+ results.add(fieldvalue::VariableMap(), Result::fromEnum(result));
+ }
- return result;
+ return results;
}
ResultList
ResultList::operator||(const ResultList& other) const
{
- ResultList result;
+ ResultList results;
// TODO: optimize
+ vespalib::hash_set<uint32_t> resultForNoVariables;
for (const auto & it : _results) {
for (const auto & it2 : other._results) {
fieldvalue::VariableMap vars = it.first;
-
if (combineVariables(vars, it2.first)) {
- result.add(vars, *it.second || *it2.second);
+ const Result & result = *it.second || *it2.second;
+ if (vars.empty()) {
+ resultForNoVariables.insert(result.toEnum());
+ } else {
+ results.add(vars, result);
+ }
}
}
}
+ for (uint32_t result : resultForNoVariables) {
+ results.add(fieldvalue::VariableMap(), Result::fromEnum(result));
+ }
- return result;
+ return results;
}
ResultList