aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/queryeval/blueprint
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-06-02 11:46:16 +0000
committerArne Juul <arnej@verizonmedia.com>2020-06-04 10:19:59 +0000
commit67134e619715227e6cbe91f365213487ff1b1f34 (patch)
treec912b02050ed980ea6715a0b171ad61e47e34a89 /searchlib/src/tests/queryeval/blueprint
parentc42ccbb874b581c7394a31dcb6a5e0e715d46e18 (diff)
use vector of UP as MultiSearch::Children
* add helper class for constructing MultiSearch::Children (mostly for unit tests) * rewrite as needed to adapt
Diffstat (limited to 'searchlib/src/tests/queryeval/blueprint')
-rw-r--r--searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp30
-rw-r--r--searchlib/src/tests/queryeval/blueprint/mysearch.h22
2 files changed, 23 insertions, 29 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
index 6625a4a09ce..0672e51378e 100644
--- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
@@ -39,11 +39,11 @@ public:
return true;
}
- virtual SearchIterator::UP
- createIntermediateSearch(const MultiSearch::Children &subSearches,
+ SearchIterator::UP
+ createIntermediateSearch(MultiSearch::Children subSearches,
bool strict, MatchData &md) const override
{
- return SearchIterator::UP(new MySearch("or", subSearches, &md, strict));
+ return SearchIterator::UP(new MySearch("or", std::move(subSearches), &md, strict));
}
static MyOr& create() { return *(new MyOr()); }
@@ -56,11 +56,11 @@ class OtherOr : public OrBlueprint
{
private:
public:
- virtual SearchIterator::UP
- createIntermediateSearch(const MultiSearch::Children &subSearches,
+ SearchIterator::UP
+ createIntermediateSearch(MultiSearch::Children subSearches,
bool strict, MatchData &md) const override
{
- return SearchIterator::UP(new MySearch("or", subSearches, &md, strict));
+ return SearchIterator::UP(new MySearch("or", std::move(subSearches), &md, strict));
}
static OtherOr& create() { return *(new OtherOr()); }
@@ -86,11 +86,11 @@ public:
return (i == 0);
}
- virtual SearchIterator::UP
- createIntermediateSearch(const MultiSearch::Children &subSearches,
+ SearchIterator::UP
+ createIntermediateSearch(MultiSearch::Children subSearches,
bool strict, MatchData &md) const override
{
- return SearchIterator::UP(new MySearch("and", subSearches, &md, strict));
+ return SearchIterator::UP(new MySearch("and", std::move(subSearches), &md, strict));
}
static MyAnd& create() { return *(new MyAnd()); }
@@ -103,11 +103,11 @@ class OtherAnd : public AndBlueprint
{
private:
public:
- virtual SearchIterator::UP
- createIntermediateSearch(const MultiSearch::Children &subSearches,
+ SearchIterator::UP
+ createIntermediateSearch(MultiSearch::Children subSearches,
bool strict, MatchData &md) const override
{
- return SearchIterator::UP(new MySearch("and", subSearches, &md, strict));
+ return SearchIterator::UP(new MySearch("and", std::move(subSearches), &md, strict));
}
static OtherAnd& create() { return *(new OtherAnd()); }
@@ -118,11 +118,11 @@ public:
class OtherAndNot : public AndNotBlueprint
{
public:
- virtual SearchIterator::UP
- createIntermediateSearch(const MultiSearch::Children &subSearches,
+ SearchIterator::UP
+ createIntermediateSearch(MultiSearch::Children subSearches,
bool strict, MatchData &md) const override
{
- return SearchIterator::UP(new MySearch("andnot", subSearches, &md, strict));
+ return SearchIterator::UP(new MySearch("andnot", std::move(subSearches), &md, strict));
}
static OtherAndNot& create() { return *(new OtherAndNot()); }
diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h
index 1f2057a4a56..012e19f26f5 100644
--- a/searchlib/src/tests/queryeval/blueprint/mysearch.h
+++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h
@@ -9,11 +9,9 @@ namespace search::queryeval {
//-----------------------------------------------------------------------------
-class MySearch : public SearchIterator
+class MySearch : public MultiSearch
{
public:
- typedef MultiSearch::Children Children;
- typedef std::vector<SearchIterator::UP> MyChildren;
typedef search::fef::TermFieldMatchDataArray TFMDA;
typedef search::fef::MatchData MatchData;
@@ -21,7 +19,6 @@ private:
vespalib::string _tag;
bool _isLeaf;
bool _isStrict;
- MyChildren _children;
TFMDA _match;
MatchData *_md;
@@ -33,21 +30,18 @@ protected:
public:
MySearch(const std::string &tag, bool leaf, bool strict)
- : _tag(tag), _isLeaf(leaf), _isStrict(strict), _children(),
+ : _tag(tag), _isLeaf(leaf), _isStrict(strict),
_match(), _md(0) {}
MySearch(const std::string &tag, const TFMDA &tfmda, bool strict)
- : _tag(tag), _isLeaf(true), _isStrict(strict), _children(),
+ : _tag(tag), _isLeaf(true), _isStrict(strict),
_match(tfmda), _md(0) {}
- MySearch(const std::string &tag, const Children &children,
+ MySearch(const std::string &tag, Children children,
MatchData *md, bool strict)
- : _tag(tag), _isLeaf(false), _isStrict(strict), _children(),
- _match(), _md(md) {
- for (size_t i(0); i < children.size(); i++) {
- _children.emplace_back(children[i]);
- }
- }
+ : MultiSearch(std::move(children)),
+ _tag(tag), _isLeaf(false), _isStrict(strict),
+ _match(), _md(md) {}
MySearch &add(SearchIterator *search) {
_children.emplace_back(search);
@@ -98,7 +92,7 @@ public:
visit(visitor, "_tag", _tag);
visit(visitor, "_isLeaf", _isLeaf);
visit(visitor, "_isStrict", _isStrict);
- visit(visitor, "_children", _children);
+ MultiSearch::visitMembers(visitor);
visit(visitor, "_handles", _handles);
}