summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-29 08:00:57 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-01-01 17:12:44 +0000
commit1ba19f37f37d22262b32da29372e94f87f3a97f5 (patch)
tree0a4b642467207c4bb0ecb91fd7160982f36ac318 /searchlib
parent064f0df79bf38da6e9c372096e25a818c2561ae3 (diff)
Add test for AndBlueprint.fetchPostings.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp43
-rw-r--r--searchlib/src/tests/queryeval/blueprint/mysearch.h12
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/executeinfo.h1
3 files changed, 40 insertions, 16 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
index 73e523b3df5..ac0e88386e0 100644
--- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
@@ -1,31 +1,22 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("blueprint_test");
+#include "mysearch.h"
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/searchlib/queryeval/blueprint.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/queryeval/leaf_blueprints.h>
#include <vespa/searchlib/queryeval/equiv_blueprint.h>
-#include <vespa/searchlib/queryeval/searchable.h>
-
-#include "mysearch.h"
-
#include <vespa/searchlib/queryeval/multisearch.h>
#include <vespa/searchlib/queryeval/andnotsearch.h>
-#include <vespa/searchlib/queryeval/andsearch.h>
-#include <vespa/searchlib/queryeval/orsearch.h>
-#include <vespa/searchlib/queryeval/nearsearch.h>
-#include <vespa/searchlib/queryeval/ranksearch.h>
#include <vespa/searchlib/queryeval/wand/weak_and_search.h>
#include <vespa/searchlib/queryeval/fake_requestcontext.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/searchlib/test/diskindex/testdiskindex.h>
#include <vespa/searchlib/query/tree/simplequery.h>
#include <vespa/searchlib/common/bitvectoriterator.h>
-#include <vespa/searchlib/diskindex/zcpostingiterators.h>
-#include <algorithm>
+#include <vespa/log/log.h>
+LOG_SETUP("blueprint_test");
using namespace search::queryeval;
using namespace search::fef;
@@ -37,6 +28,17 @@ struct WeightOrder {
}
};
+struct RememberExecuteInfo : public MyLeaf {
+ ExecuteInfo executeInfo;
+
+ using MyLeaf::MyLeaf;
+
+ void fetchPostings(const ExecuteInfo &execInfo) override {
+ LeafBlueprint::fetchPostings(execInfo);
+ executeInfo = execInfo;
+ }
+};
+
Blueprint::UP ap(Blueprint *b) { return Blueprint::UP(b); }
Blueprint::UP ap(Blueprint &b) { return Blueprint::UP(&b); }
@@ -86,6 +88,23 @@ TEST("test AndNot Blueprint") {
// createSearch tested by iterator unit test
}
+TEST("test And propagates updated histestimate") {
+ AndBlueprint *bp = new AndBlueprint();
+ bp->setSourceId(2);
+ bp->setDocIdLimit(4000);
+ bp->addChild(ap(MyLeafSpec(20).create<RememberExecuteInfo>()->setSourceId(2)));
+ bp->addChild(ap(MyLeafSpec(200).create<RememberExecuteInfo>()->setSourceId(2)));
+ bp->addChild(ap(MyLeafSpec(2000).create<RememberExecuteInfo>()->setSourceId(2)));
+ bp->optimize_self();
+ bp->fetchPostings(ExecuteInfo::create(true));
+ EXPECT_EQUAL(3u, bp->childCnt());
+ for (uint32_t i = 0; i < bp->childCnt(); i++) {
+ const RememberExecuteInfo & child = dynamic_cast<const RememberExecuteInfo &>(bp->getChild(i));
+ EXPECT_EQUAL((i == 0), child.executeInfo.isStrict());
+ EXPECT_EQUAL(1.0, child.executeInfo.hitRate());
+ }
+}
+
TEST("test And Blueprint") {
AndBlueprint b;
{ // combine
diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h
index 520a5d8448f..82ef58147c3 100644
--- a/searchlib/src/tests/queryeval/blueprint/mysearch.h
+++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h
@@ -94,7 +94,7 @@ public:
}
}
- virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override {
+ void visitMembers(vespalib::ObjectVisitor &visitor) const override {
visit(visitor, "_tag", _tag);
visit(visitor, "_isLeaf", _isLeaf);
visit(visitor, "_isStrict", _isStrict);
@@ -102,7 +102,7 @@ public:
visit(visitor, "_handles", _handles);
}
- virtual ~MySearch() {}
+ ~MySearch() override {}
};
//-----------------------------------------------------------------------------
@@ -112,7 +112,7 @@ class MyLeaf : public SimpleLeafBlueprint
typedef search::fef::TermFieldMatchDataArray TFMDA;
public:
- virtual SearchIterator::UP
+ SearchIterator::UP
createLeafSearch(const TFMDA &tfmda, bool strict) const override
{
return SearchIterator::UP(new MySearch("leaf", tfmda, strict));
@@ -156,7 +156,11 @@ public:
return *this;
}
MyLeaf *create() const {
- MyLeaf *leaf = new MyLeaf(_fields);
+ return create<MyLeaf>();
+ }
+ template<typename Leaf>
+ Leaf *create() const {
+ Leaf *leaf = new Leaf(_fields);
leaf->estimate(_estimate.estHits, _estimate.empty);
if (_cost_tier > 0) {
leaf->cost_tier(_cost_tier);
diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
index 4f2b9ecab98..3cd82327429 100644
--- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
+++ b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
@@ -10,6 +10,7 @@ namespace search::queryeval {
*/
class ExecuteInfo {
public:
+ ExecuteInfo() : ExecuteInfo(false, 1.0) { }
ExecuteInfo(bool strict, float hitRate_in)
: _hitRate(hitRate_in),
_strict(strict)