summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2018-04-18 16:49:19 +0200
committerGitHub <noreply@github.com>2018-04-18 16:49:19 +0200
commitd80776df733171824ece2a7f5e725cf15a6261eb (patch)
tree88c33de2442850f74a68f1d38b15c11b975e6da6
parentc52811ac33ce9577f83094d59c14e4143a131fab (diff)
parent6c663456f150aaaab0c1795d628ae89f839d2fb1 (diff)
Merge pull request #5623 from vespa-engine/geirst/use-more-generic-api-in-imported-search-context
Use ISearchContext instead of AttributeVector::SearchContext in Impor…
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/i_search_context.h10
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.h10
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/imported_search_context.h7
4 files changed, 22 insertions, 17 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
index 7dff0bf1c4d..4be1f00dcbc 100644
--- a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
+++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
@@ -21,6 +21,13 @@ namespace attribute {
class ISearchContext {
public:
using UP = std::unique_ptr<ISearchContext>;
+ using DocId = uint32_t;
+
+private:
+ virtual bool onCmp(DocId docId, int32_t &weight) const = 0;
+ virtual bool onCmp(DocId docId) const = 0;
+
+public:
virtual ~ISearchContext() {}
virtual unsigned int approximateHits() const = 0;
@@ -50,6 +57,9 @@ public:
virtual const QueryTermBase &queryTerm() const = 0;
virtual const vespalib::string &attributeName() const = 0;
+ bool cmp(DocId docId, int32_t &weight) const { return onCmp(docId, weight); }
+ bool cmp(DocId docId) const { return onCmp(docId); }
+
};
}
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h
index b514a5830ba..bdb5e5c02db 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h
@@ -545,20 +545,12 @@ public:
return _attr.getName();
}
-
-
- bool cmp(DocId docId, int32_t &weight) const { return onCmp(docId, weight); }
- bool cmp(DocId docId) const { return onCmp(docId); }
const AttributeVector & attribute() const { return _attr; }
protected:
SearchContext(const AttributeVector &attr);
- private:
- virtual bool onCmp(DocId docId, int32_t &weight) const = 0;
- virtual bool onCmp(DocId docId) const = 0;
-
const AttributeVector & _attr;
- protected:
+
attribute::IPostingListSearchContext *_plsc;
/**
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
index a21ecacccdb..cfac9f66062 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.cpp
@@ -10,12 +10,12 @@
using search::datastore::EntryRef;
using search::queryeval::EmptySearch;
using search::queryeval::SearchIterator;
+using search::attribute::ISearchContext;
using search::attribute::ReferenceAttribute;
using search::AttributeVector;
using ReverseMappingRefs = ReferenceAttribute::ReverseMappingRefs;
using ReverseMapping = ReferenceAttribute::ReverseMapping;
-using SearchContext = AttributeVector::SearchContext;
namespace search::attribute {
@@ -33,7 +33,7 @@ ImportedSearchContext::ImportedSearchContext(
std::unique_ptr<IDocumentMetaStoreContext::IReadGuard>()),
_reference_attribute(*_imported_attribute.getReferenceAttribute()),
_target_attribute(*_imported_attribute.getTargetAttribute()),
- _target_search_context(_target_attribute.getSearch(std::move(term), params)),
+ _target_search_context(_target_attribute.createSearchContext(std::move(term), params)),
_referencedLids(_reference_attribute.getReferencedLids()),
_merger(_reference_attribute.getCommittedDocIdLimit()),
_fetchPostingsDone(false)
@@ -97,7 +97,7 @@ struct TargetWeightedResult {
{}
static TargetWeightedResult
getResult(ReverseMappingRefs reverseMappingRefs, const ReverseMapping &reverseMapping,
- SearchContext &target_search_context, uint32_t committedDocIdLimit) __attribute__((noinline));
+ ISearchContext &target_search_context, uint32_t committedDocIdLimit) __attribute__((noinline));
};
class ReverseMappingBitVector
@@ -120,13 +120,13 @@ public:
struct TargetResult {
static void
getResult(ReverseMappingRefs reverseMappingRefs, const ReverseMapping &reverseMapping,
- SearchContext &target_search_context, uint32_t committedDocIdLimit,
+ ISearchContext &target_search_context, uint32_t committedDocIdLimit,
PostingListMerger<int32_t> & merger) __attribute__((noinline));
};
TargetWeightedResult
TargetWeightedResult::getResult(ReverseMappingRefs reverseMappingRefs, const ReverseMapping &reverseMapping,
- SearchContext &target_search_context, uint32_t committedDocIdLimit)
+ ISearchContext &target_search_context, uint32_t committedDocIdLimit)
{
TargetWeightedResult targetResult;
fef::TermFieldMatchData matchData;
@@ -151,7 +151,7 @@ TargetWeightedResult::getResult(ReverseMappingRefs reverseMappingRefs, const Rev
void
TargetResult::getResult(ReverseMappingRefs reverseMappingRefs, const ReverseMapping &reverseMapping,
- SearchContext &target_search_context, uint32_t committedDocIdLimit,
+ ISearchContext &target_search_context, uint32_t committedDocIdLimit,
PostingListMerger<int32_t> & merger)
{
fef::TermFieldMatchData matchData;
diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
index 0ddca8c9fe5..32bca66cc1b 100644
--- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
+++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h
@@ -34,7 +34,7 @@ class ImportedSearchContext : public ISearchContext {
IDocumentMetaStoreContext::IReadGuard::UP _dmsReadGuard;
const ReferenceAttribute& _reference_attribute;
const AttributeVector& _target_attribute;
- std::unique_ptr<AttributeVector::SearchContext> _target_search_context;
+ std::unique_ptr<ISearchContext> _target_search_context;
ReferencedLids _referencedLids;
PostingListMerger<int32_t> _merger;
bool _fetchPostingsDone;
@@ -71,9 +71,12 @@ public:
return _target_search_context->cmp(getReferencedLid(docId));
}
+ bool onCmp(uint32_t docId, int32_t &weight) const override { return cmp(docId, weight); }
+ bool onCmp(uint32_t docId) const override { return cmp(docId); }
+
const ReferenceAttribute& attribute() const noexcept { return _reference_attribute; }
- const AttributeVector::SearchContext& target_search_context() const noexcept {
+ const ISearchContext &target_search_context() const noexcept {
return *_target_search_context;
}
};