diff options
Diffstat (limited to 'searchlib/src/tests/queryeval/blueprint')
-rw-r--r-- | searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp | 43 | ||||
-rw-r--r-- | searchlib/src/tests/queryeval/blueprint/mysearch.h | 12 |
2 files changed, 39 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); |