aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-05-11 12:26:55 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-05-11 12:26:55 +0000
commit1f84a75a3c5f4b3056d8b263c3bf053db0904709 (patch)
treef70dbf9fa0404fb71a2c6cb08a594d2624cace47
parent579fb87fca4711b98a68aecb8b2efaacbeb2910f (diff)
Move the fieldspec base vector.
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp5
-rw-r--r--searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp191
-rw-r--r--searchlib/src/tests/queryeval/blueprint/mysearch.h4
-rw-r--r--searchlib/src/tests/queryeval/equiv/equiv_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/blueprint.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/blueprint.h12
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h3
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/field_spec.h9
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.h2
11 files changed, 98 insertions, 153 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp b/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp
index 2d3323949d1..eee2b7a7203 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/blueprintbuilder.cpp
@@ -2,7 +2,6 @@
#include "blueprintbuilder.h"
#include "querynodes.h"
-#include "termdatafromnode.h"
#include "same_element_builder.h"
#include <vespa/searchcorespi/index/indexsearchable.h>
#include <vespa/searchlib/query/tree/customtypevisitor.h>
@@ -25,7 +24,7 @@ struct Mixer {
void addAttribute(Blueprint::UP attr) {
if (attributes.get() == 0) {
- attributes.reset(new OrBlueprint());
+ attributes = std::make_unique<OrBlueprint>();
}
attributes->addChild(std::move(attr));
}
@@ -92,7 +91,7 @@ private:
for (size_t i = 0; i < n.numFields(); ++i) {
specs.add(n.field(i).fieldSpec());
}
- EquivBlueprint *eq = new EquivBlueprint(specs, n.children_mdl);
+ EquivBlueprint *eq = new EquivBlueprint(std::move(specs), n.children_mdl);
_result.reset(eq);
for (size_t i = 0; i < n.getChildren().size(); ++i) {
search::query::Node &node = *n.getChildren()[i];
diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
index 6f4ffc31741..fb98d1b2227 100644
--- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
@@ -22,19 +22,19 @@ class MyOr : public IntermediateBlueprint
{
private:
public:
- virtual HitEstimate combine(const std::vector<HitEstimate> &data) const override {
+ HitEstimate combine(const std::vector<HitEstimate> &data) const override {
return max(data);
}
- virtual FieldSpecBaseList exposeFields() const override {
+ FieldSpecBaseList exposeFields() const override {
return mixChildrenFields();
}
- virtual void sort(Children &children) const override {
+ void sort(Children &children) const override {
std::sort(children.begin(), children.end(), TieredGreaterEstimate());
}
- virtual bool inheritStrict(size_t i) const override {
+ bool inheritStrict(size_t i) const override {
(void) i;
return true;
}
@@ -136,10 +136,10 @@ public:
//-----------------------------------------------------------------------------
struct MyTerm : SimpleLeafBlueprint {
- MyTerm(const FieldSpecBaseList &fields, uint32_t hitEstimate) : SimpleLeafBlueprint(fields) {
+ MyTerm(FieldSpecBaseList fields, uint32_t hitEstimate) : SimpleLeafBlueprint(std::move(fields)) {
setEstimate(HitEstimate(hitEstimate, false));
}
- virtual SearchIterator::UP createLeafSearch(const search::fef::TermFieldMatchDataArray &, bool) const override {
+ SearchIterator::UP createLeafSearch(const search::fef::TermFieldMatchDataArray &, bool) const override {
return SearchIterator::UP();
}
SearchIteratorUP createFilterSearch(bool strict, FilterConstraint constraint) const override {
@@ -149,49 +149,29 @@ struct MyTerm : SimpleLeafBlueprint {
//-----------------------------------------------------------------------------
+Blueprint::UP ap(Blueprint *b) { return Blueprint::UP(b); }
+Blueprint::UP ap(Blueprint &b) { return Blueprint::UP(&b); }
+
} // namespace <unnamed>
-class Test : public vespalib::TestApp
+class Fixture
{
private:
MatchData::UP _md;
-
- static Blueprint::UP ap(Blueprint *b) { return Blueprint::UP(b); }
- static Blueprint::UP ap(Blueprint &b) { return Blueprint::UP(&b); }
-
+public:
+ Fixture()
+ : _md(MatchData::makeTestInstance(100, 10))
+ {}
+ ~Fixture() = default;
SearchIterator::UP create(const Blueprint &blueprint);
- bool check_equal(const SearchIterator &a, const SearchIterator &b);
bool check_equal(const Blueprint &a, const Blueprint &b);
- bool check_not_equal(const SearchIterator &a, const SearchIterator &b);
bool check_not_equal(const Blueprint &a, const Blueprint &b);
-
-public:
- Test()
- : vespalib::TestApp(),
- _md(MatchData::makeTestInstance(100, 10))
- {}
- ~Test() {}
- Blueprint::UP buildBlueprint1();
- Blueprint::UP buildBlueprint2();
- void testBlueprintBuilding();
- void testHitEstimateCalculation();
- void testHitEstimatePropagation();
- void testMatchDataPropagation();
- void testChildSorting();
- void testChildAndNotCollapsing();
- void testChildAndCollapsing();
- void testChildOrCollapsing();
- void testSearchCreation();
- void testBlueprintMakeNew();
- void requireThatAsStringWorks();
- void requireThatAsSlimeWorks();
- void requireThatVisitMembersWorks();
- void requireThatDocIdLimitInjectionWorks();
- int Main() override;
+ static bool check_equal(const SearchIterator &a, const SearchIterator &b);
+ bool check_not_equal(const SearchIterator &a, const SearchIterator &b);
};
SearchIterator::UP
-Test::create(const Blueprint &blueprint)
+Fixture::create(const Blueprint &blueprint)
{
const_cast<Blueprint &>(blueprint).fetchPostings(ExecuteInfo::TRUE);
SearchIterator::UP search = blueprint.createSearch(*_md, true);
@@ -200,39 +180,37 @@ Test::create(const Blueprint &blueprint)
}
bool
-Test::check_equal(const SearchIterator &a, const SearchIterator &b)
+Fixture::check_equal(const SearchIterator &a, const SearchIterator &b)
{
return EXPECT_EQUAL(a.asString(), b.asString());
}
bool
-Test::check_equal(const Blueprint &a, const Blueprint &b)
+Fixture::check_not_equal(const SearchIterator &a, const SearchIterator &b)
{
- SearchIterator::UP searchA = create(a);
- SearchIterator::UP searchB = create(b);
- TEST_STATE("check_equal");
- bool ok = check_equal(*searchA, *searchB);
- return ok;
+ return EXPECT_NOT_EQUAL(a.asString(), b.asString());
}
bool
-Test::check_not_equal(const SearchIterator &a, const SearchIterator &b)
+Fixture::check_equal(const Blueprint &a, const Blueprint &b)
{
- return EXPECT_NOT_EQUAL(a.asString(), b.asString());
+ SearchIterator::UP searchA = create(a);
+ SearchIterator::UP searchB = create(b);
+ bool ok = check_equal(*searchA, *searchB);
+ return ok;
}
bool
-Test::check_not_equal(const Blueprint &a, const Blueprint &b)
+Fixture::check_not_equal(const Blueprint &a, const Blueprint &b)
{
SearchIterator::UP searchA = create(a);
SearchIterator::UP searchB = create(b);
- TEST_STATE("check_not_equal");
bool ok = check_not_equal(*searchA, *searchB);
return ok;
}
Blueprint::UP
-Test::buildBlueprint1()
+buildBlueprint1()
{
return ap(MyAnd::create()
.add(MyOr::create()
@@ -248,7 +226,7 @@ Test::buildBlueprint1()
}
Blueprint::UP
-Test::buildBlueprint2()
+buildBlueprint2()
{
return ap(MyAnd::create()
.add(MyOr::create()
@@ -263,19 +241,17 @@ Test::buildBlueprint2()
);
}
-void
-Test::testBlueprintBuilding()
+TEST_F("testBlueprintBuilding", Fixture)
{
Blueprint::UP root1 = buildBlueprint1();
Blueprint::UP root2 = buildBlueprint2();
- SearchIterator::UP search1 = create(*root1);
- SearchIterator::UP search2 = create(*root2);
+ SearchIterator::UP search1 = f.create(*root1);
+ SearchIterator::UP search2 = f.create(*root2);
// fprintf(stderr, "%s\n", search1->asString().c_str());
// fprintf(stderr, "%s\n", search2->asString().c_str());
}
-void
-Test::testHitEstimateCalculation()
+TEST("testHitEstimateCalculation")
{
{
Blueprint::UP leaf = ap(MyLeafSpec(37).create());
@@ -333,8 +309,7 @@ Test::testHitEstimateCalculation()
}
}
-void
-Test::testHitEstimatePropagation()
+TEST("testHitEstimatePropagation")
{
MyLeaf *leaf1 = new MyLeaf(FieldSpecBaseList());
leaf1->estimate(10);
@@ -375,8 +350,7 @@ Test::testHitEstimatePropagation()
EXPECT_EQUAL(25u, root->getState().estimate().estHits);
}
-void
-Test::testMatchDataPropagation()
+TEST("testMatchDataPropagation")
{
{
Blueprint::UP leaf = ap(MyLeafSpec(0, true).create());
@@ -430,8 +404,7 @@ Test::testMatchDataPropagation()
}
}
-void
-Test::testChildAndNotCollapsing()
+TEST_F("testChildAndNotCollapsing", Fixture)
{
Blueprint::UP unsorted = ap(OtherAndNot::create()
.add(OtherAndNot::create()
@@ -464,13 +437,12 @@ Test::testChildAndNotCollapsing()
.add(MyLeafSpec(3).addField(2, 62).create())
)
);
- TEST_DO(check_not_equal(*sorted, *unsorted));
+ TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted = Blueprint::optimize(std::move(unsorted));
- TEST_DO(check_equal(*sorted, *unsorted));
+ TEST_DO(f.check_equal(*sorted, *unsorted));
}
-void
-Test::testChildAndCollapsing()
+TEST_F("testChildAndCollapsing", Fixture)
{
Blueprint::UP unsorted = ap(OtherAnd::create()
.add(OtherAnd::create()
@@ -504,13 +476,12 @@ Test::testChildAndCollapsing()
.add(MyLeafSpec(300).addField(1, 31).create())
);
- TEST_DO(check_not_equal(*sorted, *unsorted));
+ TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted = Blueprint::optimize(std::move(unsorted));
- TEST_DO(check_equal(*sorted, *unsorted));
+ TEST_DO(f.check_equal(*sorted, *unsorted));
}
-void
-Test::testChildOrCollapsing()
+TEST_F("testChildOrCollapsing", Fixture)
{
Blueprint::UP unsorted = ap(OtherOr::create()
.add(OtherOr::create()
@@ -543,13 +514,12 @@ Test::testChildOrCollapsing()
.add(MyLeafSpec(2).addField(2, 52).create())
.add(MyLeafSpec(1).addField(2, 42).create())
);
- TEST_DO(check_not_equal(*sorted, *unsorted));
+ TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted = Blueprint::optimize(std::move(unsorted));
- TEST_DO(check_equal(*sorted, *unsorted));
+ TEST_DO(f.check_equal(*sorted, *unsorted));
}
-void
-Test::testChildSorting()
+TEST_F("testChildSorting", Fixture)
{
Blueprint::UP unsorted = ap(MyAnd::create()
.add(MyOr::create()
@@ -587,33 +557,32 @@ Test::testChildSorting()
)
);
- TEST_DO(check_not_equal(*sorted, *unsorted));
+ TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted = Blueprint::optimize(std::move(unsorted));
- TEST_DO(check_equal(*sorted, *unsorted));
+ TEST_DO(f.check_equal(*sorted, *unsorted));
}
-void
-Test::testSearchCreation()
+TEST_F("testSearchCreation", Fixture)
{
{
Blueprint::UP l = ap(MyLeafSpec(3)
.addField(1, 1)
.addField(2, 2)
.addField(3, 3).create());
- SearchIterator::UP leafsearch = create(*l);
+ SearchIterator::UP leafsearch = f.create(*l);
MySearch *lw = new MySearch("leaf", true, true);
lw->addHandle(1).addHandle(2).addHandle(3);
SearchIterator::UP wantleaf(lw);
- TEST_DO(check_equal(*wantleaf, *leafsearch));
+ TEST_DO(f.check_equal(*wantleaf, *leafsearch));
}
{
Blueprint::UP a = ap(MyAnd::create()
.add(MyLeafSpec(1).addField(1, 1).create())
.add(MyLeafSpec(2).addField(2, 2).create()));
- SearchIterator::UP andsearch = create(*a);
+ SearchIterator::UP andsearch = f.create(*a);
MySearch *l1 = new MySearch("leaf", true, true);
MySearch *l2 = new MySearch("leaf", true, false);
@@ -623,13 +592,13 @@ Test::testSearchCreation()
aw->add(l1);
aw->add(l2);
SearchIterator::UP wanted(aw);
- TEST_DO(check_equal(*wanted, *andsearch));
+ TEST_DO(f.check_equal(*wanted, *andsearch));
}
{
Blueprint::UP o = ap(MyOr::create()
.add(MyLeafSpec(1).addField(1, 11).create())
.add(MyLeafSpec(2).addField(2, 22).create()));
- SearchIterator::UP orsearch = create(*o);
+ SearchIterator::UP orsearch = f.create(*o);
MySearch *l1 = new MySearch("leaf", true, true);
MySearch *l2 = new MySearch("leaf", true, true);
@@ -639,18 +608,11 @@ Test::testSearchCreation()
ow->add(l1);
ow->add(l2);
SearchIterator::UP wanted(ow);
- TEST_DO(check_equal(*wanted, *orsearch));
+ TEST_DO(f.check_equal(*wanted, *orsearch));
}
}
-template<typename T>
-Blueprint::UP makeNew(T *orig)
-{
- return std::make_unique<T>(*orig);
-}
-
-void
-Test::testBlueprintMakeNew()
+TEST("testBlueprintMakeNew")
{
Blueprint::UP orig = ap(MyOr::create()
.add(MyLeafSpec(1).addField(1, 11).create())
@@ -765,19 +727,17 @@ struct BlueprintFixture
{
MyOr _blueprint;
BlueprintFixture() : _blueprint() {
- _blueprint.add(new MyTerm(FieldSpecBaseList().add(FieldSpecBase(5, 7)), 9));
+ _blueprint.add(new MyTerm(FieldSpecBaseList(FieldSpecBase(5, 7)), 9));
}
};
-void
-Test::requireThatAsStringWorks()
+TEST("requireThatAsStringWorks")
{
BlueprintFixture f;
EXPECT_EQUAL(getExpectedBlueprint(), f._blueprint.asString());
}
-void
-Test::requireThatAsSlimeWorks()
+TEST("requireThatAsSlimeWorks")
{
BlueprintFixture f;
vespalib::Slime slime;
@@ -788,8 +748,7 @@ Test::requireThatAsSlimeWorks()
EXPECT_EQUAL(expectedSlime, slime);
}
-void
-Test::requireThatVisitMembersWorks()
+TEST("requireThatVisitMembersWorks")
{
BlueprintFixture f;
vespalib::ObjectDumper dumper;
@@ -797,8 +756,7 @@ Test::requireThatVisitMembersWorks()
EXPECT_EQUAL(getExpectedBlueprint(), dumper.toString());
}
-void
-Test::requireThatDocIdLimitInjectionWorks()
+TEST("requireThatDocIdLimitInjectionWorks")
{
BlueprintFixture f;
ASSERT_GREATER(f._blueprint.childCnt(), 0u);
@@ -808,26 +766,13 @@ Test::requireThatDocIdLimitInjectionWorks()
EXPECT_EQUAL(1000u, term.get_docid_limit());
}
-int
-Test::Main()
-{
- TEST_DEBUG("lhs.out", "rhs.out");
- TEST_INIT("blueprint_test");
- testBlueprintBuilding();
- testHitEstimateCalculation();
- testHitEstimatePropagation();
- testMatchDataPropagation();
- testChildSorting();
- testChildAndNotCollapsing();
- testChildAndCollapsing();
- testChildOrCollapsing();
- testSearchCreation();
- testBlueprintMakeNew();
- requireThatAsStringWorks();
- requireThatAsSlimeWorks();
- requireThatVisitMembersWorks();
- requireThatDocIdLimitInjectionWorks();
- TEST_DONE();
+TEST("Control object sizes") {
+ EXPECT_EQUAL(48u, sizeof(Blueprint::State));
+ EXPECT_EQUAL(32u, sizeof(Blueprint));
+ EXPECT_EQUAL(80u, sizeof(LeafBlueprint));
}
-TEST_APPHOOK(Test);
+TEST_MAIN() {
+ TEST_DEBUG("lhs.out", "rhs.out");
+ TEST_RUN_ALL();
+} \ No newline at end of file
diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h
index 6c91a23e80b..6e8b6fa9adc 100644
--- a/searchlib/src/tests/queryeval/blueprint/mysearch.h
+++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h
@@ -113,8 +113,8 @@ public:
return SearchIterator::UP(new MySearch("leaf", tfmda, strict));
}
- MyLeaf(const FieldSpecBaseList &fields)
- : SimpleLeafBlueprint(fields), _got_global_filter(false)
+ MyLeaf(FieldSpecBaseList fields)
+ : SimpleLeafBlueprint(std::move(fields)), _got_global_filter(false)
{}
MyLeaf &estimate(uint32_t hits, bool empty = false) {
diff --git a/searchlib/src/tests/queryeval/equiv/equiv_test.cpp b/searchlib/src/tests/queryeval/equiv/equiv_test.cpp
index 887128b8d5e..bc927e233db 100644
--- a/searchlib/src/tests/queryeval/equiv/equiv_test.cpp
+++ b/searchlib/src/tests/queryeval/equiv/equiv_test.cpp
@@ -45,7 +45,7 @@ EquivTest::test_equiv(bool strict, bool unpack_normal_features, bool unpack_inte
FieldSpecBaseList fields;
fields.add(FieldSpecBase(1, 1));
fields.add(FieldSpecBase(2, 2));
- auto bp = std::make_unique<EquivBlueprint>(fields, subLayout);
+ auto bp = std::make_unique<EquivBlueprint>(std::move(fields), subLayout);
bp->addTerm(std::make_unique<FakeBlueprint>(FieldSpec("foo", 1, fbh11), a), 1.0);
bp->addTerm(std::make_unique<FakeBlueprint>(FieldSpec("bar", 2, fbh21), b), 1.0);
diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp
index 87f7ab99002..3ed680897e9 100644
--- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp
@@ -2,7 +2,6 @@
#include "blueprint.h"
#include "leaf_blueprints.h"
-#include "intermediate_blueprints.h"
#include "emptysearch.h"
#include "full_search.h"
#include "field_spec.hpp"
@@ -17,7 +16,6 @@
#include <vespa/vespalib/util/classname.h>
#include <vespa/vespalib/util/require.h>
#include <vespa/vespalib/data/slime/inserter.h>
-#include <type_traits>
#include <map>
#include <vespa/log/log.h>
@@ -89,8 +87,8 @@ Blueprint::sat_sum(const std::vector<HitEstimate> &data, uint32_t docid_limit)
return { uint32_t(std::min(sum, uint64_t(limit))), empty };
}
-Blueprint::State::State(const FieldSpecBaseList &fields_in)
- : _fields(fields_in),
+Blueprint::State::State(FieldSpecBaseList fields_in)
+ : _fields(std::move(fields_in)),
_estimate(),
_cost_tier(COST_TIER_NORMAL),
_tree_size(1),
@@ -483,6 +481,7 @@ IntermediateBlueprint::mixChildrenFields() const
}
}
}
+ fieldList.reserve(fieldMap.size());
for (const auto & entry : fieldMap) {
fieldList.add(*entry.second);
}
@@ -684,8 +683,8 @@ IntermediateBlueprint::calculateUnpackInfo(const fef::MatchData & md) const
//-----------------------------------------------------------------------------
-LeafBlueprint::LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwise_eval)
- : _state(fields)
+LeafBlueprint::LeafBlueprint(FieldSpecBaseList fields, bool allow_termwise_eval)
+ : _state(std::move(fields))
{
_state.allow_termwise_eval(allow_termwise_eval);
}
@@ -693,9 +692,8 @@ LeafBlueprint::LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwis
LeafBlueprint::~LeafBlueprint() = default;
void
-LeafBlueprint::fetchPostings(const ExecuteInfo &execInfo)
+LeafBlueprint::fetchPostings(const ExecuteInfo &)
{
- (void) execInfo;
}
void
diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h
index c76f0a22e98..543dcae59d0 100644
--- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h
+++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h
@@ -76,7 +76,7 @@ public:
static constexpr uint32_t COST_TIER_EXPENSIVE = 2;
static constexpr uint32_t COST_TIER_MAX = 999;
- State(const FieldSpecBaseList &fields_in);
+ State(FieldSpecBaseList fields_in);
State(const State &rhs) = delete;
State(State &&rhs) = default;
State &operator=(const State &rhs) = delete;
@@ -357,7 +357,7 @@ protected:
void set_want_global_filter(bool value);
void set_tree_size(uint32_t value);
- LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwise_eval);
+ LeafBlueprint(FieldSpecBaseList fields, bool allow_termwise_eval);
public:
~LeafBlueprint() override;
const State &getState() const final { return _state; }
@@ -372,14 +372,14 @@ public:
// for leaf nodes representing a single term
struct SimpleLeafBlueprint : LeafBlueprint {
- explicit SimpleLeafBlueprint(const FieldSpecBase &field) : LeafBlueprint(FieldSpecBaseList().add(field), true) {}
- explicit SimpleLeafBlueprint(const FieldSpecBaseList &fields) : LeafBlueprint(fields, true) {}
+ explicit SimpleLeafBlueprint(const FieldSpecBase &field) : LeafBlueprint(FieldSpecBaseList(field), true) {}
+ explicit SimpleLeafBlueprint(FieldSpecBaseList fields) : LeafBlueprint(std::move(fields), true) {}
};
// for leaf nodes representing more complex structures like wand/phrase
struct ComplexLeafBlueprint : LeafBlueprint {
- explicit ComplexLeafBlueprint(const FieldSpecBase &field) : LeafBlueprint(FieldSpecBaseList().add(field), false) {}
- explicit ComplexLeafBlueprint(const FieldSpecBaseList &fields) : LeafBlueprint(fields, false) {}
+ explicit ComplexLeafBlueprint(const FieldSpecBase &field) : LeafBlueprint(FieldSpecBaseList(field), false) {}
+ explicit ComplexLeafBlueprint(FieldSpecBaseList fields) : LeafBlueprint(std::move(fields), false) {}
};
//-----------------------------------------------------------------------------
diff --git a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp
index c2f4c53224d..af6b59dd6ca 100644
--- a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.cpp
@@ -40,10 +40,9 @@ public:
};
-EquivBlueprint::EquivBlueprint(const FieldSpecBaseList &fields,
+EquivBlueprint::EquivBlueprint(FieldSpecBaseList fields,
fef::MatchDataLayout subtree_mdl)
- : ComplexLeafBlueprint(fields),
- _fields(fields),
+ : ComplexLeafBlueprint(std::move(fields)),
_estimate(),
_layout(subtree_mdl),
_terms(),
diff --git a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h
index 86bd4f09cd4..140da63afcc 100644
--- a/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h
+++ b/searchlib/src/vespa/searchlib/queryeval/equiv_blueprint.h
@@ -10,14 +10,13 @@ namespace search::queryeval {
class EquivBlueprint : public ComplexLeafBlueprint
{
private:
- FieldSpecBaseList _fields;
HitEstimate _estimate;
fef::MatchDataLayout _layout;
std::vector<Blueprint::UP> _terms;
std::vector<double> _exactness;
public:
- EquivBlueprint(const FieldSpecBaseList &fields, fef::MatchDataLayout subtree_mdl);
+ EquivBlueprint(FieldSpecBaseList fields, fef::MatchDataLayout subtree_mdl);
~EquivBlueprint() override;
// used by create visitor
diff --git a/searchlib/src/vespa/searchlib/queryeval/field_spec.h b/searchlib/src/vespa/searchlib/queryeval/field_spec.h
index f37403471ac..b9aeb148681 100644
--- a/searchlib/src/vespa/searchlib/queryeval/field_spec.h
+++ b/searchlib/src/vespa/searchlib/queryeval/field_spec.h
@@ -60,7 +60,14 @@ private:
List _list;
public:
+ FieldSpecBaseList() = default;
+ FieldSpecBaseList(FieldSpecBase spec) : _list() { _list.push_back(spec); }
+ FieldSpecBaseList(FieldSpecBaseList &&) noexcept = default;
+ FieldSpecBaseList & operator=(FieldSpecBaseList &&) noexcept = default;
+ FieldSpecBaseList(const FieldSpecBaseList &) = default;
+ FieldSpecBaseList & operator=(FieldSpecBaseList &) = delete;
~FieldSpecBaseList();
+ void reserve(size_t sz) { _list.reserve(sz); }
using const_iterator = List::const_iterator;
FieldSpecBaseList &add(const FieldSpecBase &spec) {
_list.push_back(spec);
@@ -71,8 +78,6 @@ public:
const_iterator begin() const { return _list.begin(); }
const_iterator end() const { return _list.end(); }
const FieldSpecBase &operator[](size_t i) const { return _list[i]; }
- void clear() { _list.clear(); }
- void swap(FieldSpecBaseList & rhs) { _list.swap(rhs._list); }
};
/**
diff --git a/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp b/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp
index 86f520c8711..dc9ddcccfe4 100644
--- a/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.cpp
@@ -28,8 +28,8 @@ EmptyBlueprint::EmptyBlueprint(const FieldSpecBase &field)
{
}
-EmptyBlueprint::EmptyBlueprint(const FieldSpecBaseList &fields)
- : SimpleLeafBlueprint(fields)
+EmptyBlueprint::EmptyBlueprint(FieldSpecBaseList fields)
+ : SimpleLeafBlueprint(std::move(fields))
{
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.h b/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.h
index b4d7682cf89..1fb6f9005dd 100644
--- a/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.h
+++ b/searchlib/src/vespa/searchlib/queryeval/leaf_blueprints.h
@@ -16,7 +16,7 @@ class EmptyBlueprint : public SimpleLeafBlueprint
protected:
SearchIterator::UP createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda, bool strict) const override;
public:
- EmptyBlueprint(const FieldSpecBaseList &fields);
+ EmptyBlueprint(FieldSpecBaseList fields);
EmptyBlueprint(const FieldSpecBase &field);
EmptyBlueprint();
SearchIterator::UP createFilterSearch(bool strict, FilterConstraint constraint) const override;