summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-12-12 13:47:11 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-12-12 13:47:11 +0000
commit81487d4843b65c66f2f14a3346f3b6b51b85e245 (patch)
treef5fd47779d893464b0938eac46a2d12afd9b1daf /searchlib
parent3f54d4088502406eda15288bde29a16f6c810751 (diff)
Unify on using reference where possible.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp27
-rw-r--r--searchlib/src/tests/queryeval/blueprint/mysearch.h12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp3
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/executeinfo.h15
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h3
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/irequestcontext.h2
7 files changed, 34 insertions, 32 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
index 27f2f3bb5d0..7d994ee4cd6 100644
--- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
@@ -39,13 +39,16 @@ struct WeightOrder {
};
struct RememberExecuteInfo : public MyLeaf {
- ExecuteInfo executeInfo;
+ bool is_strict;
+ double hit_rate;
- using MyLeaf::MyLeaf;
+ RememberExecuteInfo() : MyLeaf(), is_strict(false), hit_rate(0.0) {}
+ RememberExecuteInfo(FieldSpecBaseList fields) : MyLeaf(std::move(fields)), is_strict(false), hit_rate(0.0) {}
void fetchPostings(const ExecuteInfo &execInfo) override {
LeafBlueprint::fetchPostings(execInfo);
- executeInfo = execInfo;
+ is_strict = execInfo.is_strict();
+ hit_rate = execInfo.hit_rate();
}
};
@@ -134,11 +137,11 @@ TEST("test And propagates updated histestimate") {
EXPECT_EQUAL(3u, bp->childCnt());
for (uint32_t i = 0; i < bp->childCnt(); i++) {
const auto & child = dynamic_cast<const RememberExecuteInfo &>(bp->getChild(i));
- EXPECT_EQUAL((i == 0), child.executeInfo.is_strict());
+ EXPECT_EQUAL((i == 0), child.is_strict);
}
- EXPECT_EQUAL(1.0, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(0)).executeInfo.hit_rate());
- EXPECT_EQUAL(1.0/250, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(1)).executeInfo.hit_rate());
- EXPECT_EQUAL(1.0/(250*25), dynamic_cast<const RememberExecuteInfo &>(bp->getChild(2)).executeInfo.hit_rate());
+ EXPECT_EQUAL(1.0, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(0)).hit_rate);
+ EXPECT_EQUAL(1.0/250, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(1)).hit_rate);
+ EXPECT_EQUAL(1.0/(250*25), dynamic_cast<const RememberExecuteInfo &>(bp->getChild(2)).hit_rate);
}
TEST("test Or propagates updated histestimate") {
@@ -154,12 +157,12 @@ TEST("test Or propagates updated histestimate") {
EXPECT_EQUAL(4u, bp->childCnt());
for (uint32_t i = 0; i < bp->childCnt(); i++) {
const auto & child = dynamic_cast<const RememberExecuteInfo &>(bp->getChild(i));
- EXPECT_TRUE(child.executeInfo.is_strict());
+ EXPECT_TRUE(child.is_strict);
}
- EXPECT_EQUAL(1.0, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(0)).executeInfo.hit_rate());
- EXPECT_APPROX(0.5, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(1)).executeInfo.hit_rate(), 1e-6);
- EXPECT_APPROX(0.5*3.0/5.0, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(2)).executeInfo.hit_rate(), 1e-6);
- EXPECT_APPROX(0.5*3.0*42.0/(5.0*50.0), dynamic_cast<const RememberExecuteInfo &>(bp->getChild(3)).executeInfo.hit_rate(), 1e-6);
+ EXPECT_EQUAL(1.0, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(0)).hit_rate);
+ EXPECT_APPROX(0.5, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(1)).hit_rate, 1e-6);
+ EXPECT_APPROX(0.5*3.0/5.0, dynamic_cast<const RememberExecuteInfo &>(bp->getChild(2)).hit_rate, 1e-6);
+ EXPECT_APPROX(0.5*3.0*42.0/(5.0*50.0), dynamic_cast<const RememberExecuteInfo &>(bp->getChild(3)).hit_rate, 1e-6);
}
TEST("test And Blueprint") {
diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h
index 6cfc7a04368..db7dd2adae6 100644
--- a/searchlib/src/tests/queryeval/blueprint/mysearch.h
+++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h
@@ -58,10 +58,10 @@ public:
if (!_isLeaf) {
ok &= (_md == &md);
}
- for (size_t i = 0; i < _children.size(); ++i) {
- MySearch *child = dynamic_cast<MySearch *>(_children[i].get());
- ok &= (child != 0);
- if (child != 0) {
+ for (const auto & my_search : _children) {
+ auto *child = dynamic_cast<MySearch *>(my_search.get());
+ ok &= (child != nullptr);
+ if (child != nullptr) {
ok &= child->verifyAndInferImpl(md);
}
}
@@ -80,8 +80,8 @@ public:
}
static bool verifyAndInfer(SearchIterator *search, MatchData &md) {
- MySearch *self = dynamic_cast<MySearch *>(search);
- if (self == 0) {
+ auto *self = dynamic_cast<MySearch *>(search);
+ if (self == nullptr) {
return false;
} else {
return self->verifyAndInferImpl(md);
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
index 117a1dfa7c5..ecdfad433ee 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
@@ -62,8 +62,7 @@ void
PostingListSearchContextT<DataT>::fillArray()
{
for (auto it(_lowerDictItr); it != _upperDictItr; ++it) {
- _merger.addToArray(PostingListTraverser<PostingStore>(_posting_store,
- it.getData().load_acquire()));
+ _merger.addToArray(PostingListTraverser<PostingStore>(_posting_store, it.getData().load_acquire()));
}
_merger.merge();
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp b/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp
index f5794b86486..858cb92331a 100644
--- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/executeinfo.cpp
@@ -4,7 +4,7 @@
namespace search::queryeval {
-const ExecuteInfo ExecuteInfo::TRUE(true, 1.0, nullptr, nullptr, true, true);
-const ExecuteInfo ExecuteInfo::FALSE(false, 1.0, nullptr, nullptr, true, true);
+const ExecuteInfo ExecuteInfo::TRUE(true, 1.0, nullptr, vespalib::ThreadBundle::trivial(), true, true);
+const ExecuteInfo ExecuteInfo::FALSE(false, 1.0, nullptr, vespalib::ThreadBundle::trivial(), true, true);
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
index 3cb6a5654f2..3300a2aea4d 100644
--- a/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
+++ b/searchlib/src/vespa/searchlib/queryeval/executeinfo.h
@@ -13,14 +13,13 @@ namespace search::queryeval {
*/
class ExecuteInfo {
public:
- ExecuteInfo() noexcept : ExecuteInfo(false, 1.0, nullptr, nullptr, true, true) { }
+ ExecuteInfo() noexcept : ExecuteInfo(false, 1.0, nullptr, vespalib::ThreadBundle::trivial(), true, true) { }
bool is_strict() const noexcept { return _strict; }
bool create_postinglist_when_non_strict() const noexcept { return _create_postinglist_when_non_strict; }
bool use_estimate_for_fetch_postings() const noexcept { return _use_estimate_for_fetch_postings; }
double hit_rate() const noexcept { return _hitRate; }
bool soft_doom() const noexcept { return _doom && _doom->soft_doom(); }
- const vespalib::Doom * doom() const noexcept { return _doom; }
- vespalib::ThreadBundle * thread_bundle() const noexcept { return _thread_bundle; }
+ vespalib::ThreadBundle & thread_bundle() const noexcept { return _thread_bundle; }
static const ExecuteInfo TRUE;
static const ExecuteInfo FALSE;
@@ -28,10 +27,10 @@ public:
return create(strict, org._hitRate, org);
}
static ExecuteInfo create(bool strict, double hitRate, const ExecuteInfo & org) noexcept {
- return {strict, hitRate, org.doom(), org.thread_bundle(), org.create_postinglist_when_non_strict(), org.use_estimate_for_fetch_postings()};
+ return {strict, hitRate, org._doom, org.thread_bundle(), org.create_postinglist_when_non_strict(), org.use_estimate_for_fetch_postings()};
}
- static ExecuteInfo create(bool strict, double hitRate, const vespalib::Doom * doom, vespalib::ThreadBundle * thread_bundle_in,
+ static ExecuteInfo create(bool strict, double hitRate, const vespalib::Doom * doom, vespalib::ThreadBundle & thread_bundle_in,
bool postinglist_when_non_strict, bool use_estimate_for_fetch_postings) noexcept
{
return {strict, hitRate, doom, thread_bundle_in, postinglist_when_non_strict, use_estimate_for_fetch_postings};
@@ -43,10 +42,10 @@ public:
return createForTest(strict, hitRate, nullptr);
}
static ExecuteInfo createForTest(bool strict, double hitRate, const vespalib::Doom * doom) noexcept {
- return create(strict, hitRate, doom, nullptr, true, true);
+ return create(strict, hitRate, doom, vespalib::ThreadBundle::trivial(), true, true);
}
private:
- ExecuteInfo(bool strict, double hitRate_in, const vespalib::Doom * doom, vespalib::ThreadBundle * thread_bundle_in,
+ ExecuteInfo(bool strict, double hitRate_in, const vespalib::Doom * doom, vespalib::ThreadBundle & thread_bundle_in,
bool postinglist_when_non_strict, bool use_estimate_for_fetch_postings) noexcept
: _doom(doom),
_thread_bundle(thread_bundle_in),
@@ -56,7 +55,7 @@ private:
_use_estimate_for_fetch_postings(use_estimate_for_fetch_postings)
{ }
const vespalib::Doom * _doom;
- vespalib::ThreadBundle * _thread_bundle;
+ vespalib::ThreadBundle & _thread_bundle;
double _hitRate;
bool _strict;
bool _create_postinglist_when_non_strict;
diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
index 0812f6c403d..0122352656e 100644
--- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
@@ -11,6 +11,7 @@
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/searchlib/attribute/attribute_blueprint_params.h>
#include <vespa/vespalib/util/doom.h>
+#include <vespa/vespalib/util/thread_bundle.h>
#include <limits>
namespace vespalib { class TestClock; }
@@ -25,7 +26,7 @@ public:
vespalib::steady_time hard=vespalib::steady_time::max());
~FakeRequestContext() override;
const vespalib::Doom & getDoom() const override { return _doom; }
- vespalib::ThreadBundle * thread_bundle() const override { return nullptr; }
+ vespalib::ThreadBundle & thread_bundle() const override { return vespalib::ThreadBundle::trivial(); }
const attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override {
return _attributeContext
? _attributeContext->getAttribute(name)
diff --git a/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h b/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
index 768f36ded1e..ad25385be4b 100644
--- a/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/irequestcontext.h
@@ -32,7 +32,7 @@ public:
/**
* Provide an optional thread bundle that can be used for multithreading parts of the query.
*/
- virtual vespalib::ThreadBundle * thread_bundle() const = 0;
+ virtual vespalib::ThreadBundle & thread_bundle() const = 0;
/**
* Provide access to attributevectors