summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/i_search_context.h8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributeiterators.h12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributeiterators.hpp23
3 files changed, 29 insertions, 14 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
index be6b8d213d8..f75bf8699c8 100644
--- a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
+++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
@@ -52,15 +52,17 @@ public:
int32_t find(DocId docId, int32_t elementId, int32_t &weight) const { return onFind(docId, elementId, weight); }
int32_t find(DocId docId, int32_t elementId) const { return onFind(docId, elementId); }
- bool matches(DocId docId, int32_t &weight) const {
+ template<typename SC>
+ static bool matches(const SC & sc, DocId docId, int32_t &weight) {
weight = 0;
int32_t oneWeight(0);
- int32_t firstId = find(docId, 0, oneWeight);
- for (int32_t id(firstId); id >= 0; id = find(docId, id + 1, oneWeight)) {
+ int32_t firstId = sc.find(docId, 0, oneWeight);
+ for (int32_t id(firstId); id >= 0; id = sc.find(docId, id + 1, oneWeight)) {
weight += oneWeight;
}
return firstId >= 0;
}
+ bool matches(DocId docId, int32_t &weight) const { return matches(*this, docId, weight); }
bool matches(DocId doc) const { return find(doc, 0) >= 0; }
};
diff --git a/searchlib/src/vespa/searchlib/attribute/attributeiterators.h b/searchlib/src/vespa/searchlib/attribute/attributeiterators.h
index 3f85c2a20fe..4d81f46a65c 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributeiterators.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributeiterators.h
@@ -6,11 +6,10 @@
#include "postinglisttraits.h"
#include <vespa/searchlib/queryeval/searchiterator.h>
#include <vespa/searchlib/fef/termfieldmatchdata.h>
+#include <vespa/searchcommon/attribute/i_search_context.h>
namespace search {
-namespace attribute { class ISearchContext; }
-
namespace fef {
class TermFieldMatchData;
class TermFieldMatchDataPosition;
@@ -92,11 +91,15 @@ private:
std::unique_ptr<BitVector> get_hits(uint32_t begin_id) override;
protected:
+ bool matches(uint32_t docId, int32_t &weight) const {
+ return attribute::ISearchContext::matches(_concreteSearchCtx, docId, weight);
+ }
+ bool matches(uint32_t doc) const { return _concreteSearchCtx.find(doc, 0) >= 0; }
const SC &_concreteSearchCtx;
public:
AttributeIteratorT(const SC &concreteSearchCtx, fef::TermFieldMatchData *matchData);
- bool seekFast(uint32_t docId) const { return _concreteSearchCtx.matches(docId); }
+ bool seekFast(uint32_t docId) const { return matches(docId); }
};
template <typename SC>
@@ -110,11 +113,12 @@ private:
std::unique_ptr<BitVector> get_hits(uint32_t begin_id) override;
protected:
+ bool matches(uint32_t doc) const { return _concreteSearchCtx.find(doc, 0) >= 0; }
const SC &_concreteSearchCtx;
public:
FilterAttributeIteratorT(const SC &concreteSearchCtx, fef::TermFieldMatchData *matchData);
- bool seekFast(uint32_t docId) const { return _concreteSearchCtx.matches(docId); }
+ bool seekFast(uint32_t docId) const { return matches(docId); }
};
diff --git a/searchlib/src/vespa/searchlib/attribute/attributeiterators.hpp b/searchlib/src/vespa/searchlib/attribute/attributeiterators.hpp
index caf6c028c4d..131d580c671 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributeiterators.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributeiterators.hpp
@@ -12,17 +12,26 @@
namespace search {
+namespace {
+
+template <typename SC>
+bool matches(const SC & sc, uint32_t doc) {
+ return sc.find(doc, 0) >= 0;
+}
+
+}
+
template <typename SC>
void
AttributeIteratorBase::and_hits_into(const SC & sc, BitVector & result, uint32_t begin_id) const {
- result.foreach_truebit([&](uint32_t key) { if ( ! sc.matches(key)) { result.clearBit(key); }}, begin_id);
+ result.foreach_truebit([&](uint32_t key) { if ( ! matches(sc, key)) { result.clearBit(key); }}, begin_id);
result.invalidateCachedCount();
}
template <typename SC>
void
AttributeIteratorBase::or_hits_into(const SC & sc, BitVector & result, uint32_t begin_id) const {
- result.foreach_falsebit([&](uint32_t key) { if ( sc.matches(key)) { result.setBit(key); }}, begin_id);
+ result.foreach_falsebit([&](uint32_t key) { if ( matches(sc, key)) { result.setBit(key); }}, begin_id);
result.invalidateCachedCount();
}
@@ -32,7 +41,7 @@ std::unique_ptr<BitVector>
AttributeIteratorBase::get_hits(const SC & sc, uint32_t begin_id) const {
BitVector::UP result = BitVector::create(begin_id, getEndId());
for (uint32_t docId(std::max(begin_id, getDocId())); docId < getEndId(); docId++) {
- if (sc.matches(docId)) {
+ if (matches(sc, docId)) {
result->setBit(docId);
}
}
@@ -339,7 +348,7 @@ AttributeIteratorT<SC>::doSeek(uint32_t docId)
{
if (isAtEnd(docId)) {
setAtEnd();
- } else if (_concreteSearchCtx.matches(docId, _weight)) {
+ } else if (matches(docId, _weight)) {
setDocId(docId);
}
}
@@ -350,7 +359,7 @@ FilterAttributeIteratorT<SC>::doSeek(uint32_t docId)
{
if (isAtEnd(docId)) {
setAtEnd();
- } else if (_concreteSearchCtx.matches(docId)) {
+ } else if (matches(docId)) {
setDocId(docId);
}
}
@@ -360,7 +369,7 @@ void
AttributeIteratorStrict<SC>::doSeek(uint32_t docId)
{
for (uint32_t nextId = docId; !isAtEnd(nextId); ++nextId) {
- if (_concreteSearchCtx.matches(nextId, _weight)) {
+ if (this->matches(nextId, _weight)) {
setDocId(nextId);
return;
}
@@ -373,7 +382,7 @@ void
FilterAttributeIteratorStrict<SC>::doSeek(uint32_t docId)
{
for (uint32_t nextId = docId; !isAtEnd(nextId); ++nextId) {
- if (_concreteSearchCtx.matches(nextId)) {
+ if (this->matches(nextId)) {
setDocId(nextId);
return;
}