summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-11-22 16:02:38 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-11-22 16:17:19 +0000
commit10586103aa69d192dea6351375c75522d187bb41 (patch)
treeb621a271606ca4c4f87ff4c61d22d29e56d798ec /searchcore
parent40fca839012e79e792b94f22cb7de5846acd1433 (diff)
Avoid casting by adding asXXX methods to the Blueprint interface.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/rangequerylocator.cpp20
3 files changed, 12 insertions, 14 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp
index 0393bdc2ee8..95e4eac437c 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp
@@ -222,7 +222,7 @@ public:
setEstimate(HitEstimate(_activeLids.size(), false));
}
- bool isWhiteList() const override { return true; }
+ bool isWhiteList() const noexcept final { return true; }
SearchIterator::UP createFilterSearch(bool strict, FilterConstraint) const override {
if (_all_lids_active) {
@@ -231,7 +231,7 @@ public:
return create_search_helper(strict);
}
- ~WhiteListBlueprint() {
+ ~WhiteListBlueprint() override {
for (auto matchData : _matchDataVector) {
delete matchData;
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index 071e914b405..f55ba77cec8 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -143,7 +143,7 @@ void exchange_location_nodes(const string &location_str,
IntermediateBlueprint *
asRankOrAndNot(Blueprint * blueprint) {
return ((blueprint->isAndNot() || blueprint->isRank()))
- ? static_cast<IntermediateBlueprint *>(blueprint)
+ ? blueprint->asIntermediate()
: nullptr;
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/rangequerylocator.cpp b/searchcore/src/vespa/searchcore/proton/matching/rangequerylocator.cpp
index fcae5794e9e..af26a47fba3 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/rangequerylocator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/rangequerylocator.cpp
@@ -25,15 +25,13 @@ namespace {
RangeLimitMetaInfo
locateFirst(uint32_t field_id, const Blueprint & blueprint) {
- if (blueprint.isIntermediate()) {
- const auto & intermediate = static_cast<const IntermediateBlueprint &>(blueprint);
- if (intermediate.isAndNot()) {
- return locateFirst(field_id, intermediate.getChild(0));
- } else if (intermediate.isRank()) {
- return locateFirst(field_id, intermediate.getChild(0));
- } else if (intermediate.isAnd()) {
- for (size_t i(0); i < intermediate.childCnt(); i++) {
- RangeLimitMetaInfo childMeta = locateFirst(field_id, intermediate.getChild(i));
+ const auto * intermediate = blueprint.asIntermediate();
+ if (intermediate) {
+ if (intermediate->isAndNot() || intermediate->isRank()) {
+ return locateFirst(field_id, intermediate->getChild(0));
+ } else if (intermediate->isAnd()) {
+ for (size_t i(0); i < intermediate->childCnt(); i++) {
+ RangeLimitMetaInfo childMeta = locateFirst(field_id, intermediate->getChild(i));
if (childMeta.valid()) {
return childMeta;
}
@@ -42,9 +40,9 @@ locateFirst(uint32_t field_id, const Blueprint & blueprint) {
} else {
const Blueprint::State & state = blueprint.getState();
if (state.isTermLike() && (state.numFields() == 1) && (state.field(0).getFieldId() == field_id)) {
- const LeafBlueprint &leaf = static_cast<const LeafBlueprint &>(blueprint);
+ const LeafBlueprint * leaf = blueprint.asLeaf();
vespalib::string from, too;
- if (leaf.getRange(from, too)) {
+ if (leaf->getRange(from, too)) {
return {from, too, state.estimate().estHits};
}
}