summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/i_search_context.h1
-rw-r--r--searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h3
-rw-r--r--searchlib/src/tests/attribute/benchmark/attributesearcher.h7
-rw-r--r--searchlib/src/tests/attribute/bitvector/bitvector_test.cpp3
-rw-r--r--searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp3
-rw-r--r--searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp3
-rw-r--r--searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp1
-rw-r--r--searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp6
-rw-r--r--searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp3
-rw-r--r--searchlib/src/tests/queryeval/queryeval.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/CMakeLists.txt1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.cpp61
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.h56
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attrvector.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attrvector.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/extendableattributes.h16
-rw-r--r--searchlib/src/vespa/searchlib/attribute/flagattribute.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/flagattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericattribute.h7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp6
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringattribute.h9
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/search_context.cpp81
-rw-r--r--searchlib/src/vespa/searchlib/attribute/search_context.h62
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleboolattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringattribute.h3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/stringbase.h3
53 files changed, 251 insertions, 195 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
index f13b79acb4b..ff62c535e7f 100644
--- a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
+++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
@@ -4,6 +4,7 @@
#include <vespa/searchcommon/common/range.h>
#include <vespa/vespalib/stllike/string.h>
+#include <memory>
namespace search::fef { class TermFieldMatchData; }
namespace search::queryeval {
diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
index c96b0825789..0414990d74e 100644
--- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
+++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
@@ -41,6 +41,7 @@ using search::GrowStrategy;
using search::LidUsageStats;
using search::QueryTermSimple;
using search::TuneFileAttributes;
+using search::attribute::SearchContext;
using search::attribute::SearchContextParams;
using search::fef::MatchData;
using search::fef::MatchDataLayout;
@@ -197,7 +198,7 @@ assertSearchResult(const SimpleResult &exp, const DocumentMetaStore &dms,
const vespalib::string &term, const QueryTermSimple::Type &termType,
bool strict, uint32_t docIdLimit = 100)
{
- AttributeVector::SearchContext::UP sc =
+ std::unique_ptr<SearchContext> sc =
dms.getSearch(std::make_unique<QueryTermSimple>(term, termType), SearchContextParams());
TermFieldMatchData tfmd;
SearchIterator::UP sb = sc->createIterator(&tfmd, strict);
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
index 75cb8dfa6b3..e289b71a447 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
@@ -40,6 +40,7 @@ using search::GrowStrategy;
using search::IAttributeSaveTarget;
using search::LidUsageStats;
using search::attribute::LoadUtils;
+using search::attribute::SearchContext;
using search::attribute::SearchContextParams;
using search::fef::TermFieldMatchData;
using search::queryeval::Blueprint;
@@ -798,7 +799,7 @@ DocumentMetaStore::createWhiteListBlueprint() const
return _lidAlloc.createWhiteListBlueprint();
}
-AttributeVector::SearchContext::UP
+std::unique_ptr<SearchContext>
DocumentMetaStore::getSearch(std::unique_ptr<search::QueryTermSimple> qTerm, const SearchContextParams &) const
{
return std::make_unique<documentmetastore::SearchContext>(std::move(qTerm), *this);
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
index 87176721681..b5a95b8cd34 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
@@ -202,7 +202,7 @@ public:
/**
* Implements search::AttributeVector
*/
- SearchContext::UP
+ std::unique_ptr<search::attribute::SearchContext>
getSearch(std::unique_ptr<search::QueryTermSimple> qTerm,
const search::attribute::SearchContextParams &params) const override;
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp
index 34766071af1..ea815d102f7 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.cpp
@@ -115,7 +115,7 @@ SearchContext::onFind(DocId, int32_t ) const
unsigned int
SearchContext::approximateHits() const
{
- return _isWord ? 1 : search::AttributeVector::SearchContext::approximateHits();
+ return _isWord ? 1 : search::attribute::SearchContext::approximateHits();
}
SearchIterator::UP
@@ -135,7 +135,7 @@ SearchContext::getStore() const
}
SearchContext::SearchContext(QueryTermSimple::UP qTerm, const DocumentMetaStore &toBeSearched)
- : search::AttributeVector::SearchContext(toBeSearched),
+ : search::attribute::SearchContext(toBeSearched),
_isWord(qTerm->isWord())
{
}
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h
index 3b26c899cba..a2a265ad519 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/search_context.h
@@ -4,6 +4,7 @@
#include <vespa/document/base/globalid.h>
#include <vespa/searchlib/attribute/attributevector.h>
+#include <vespa/searchlib/attribute/search_context.h>
#include "documentmetastore.h"
namespace proton::documentmetastore {
@@ -11,7 +12,7 @@ namespace proton::documentmetastore {
/**
* Search context used to search the document meta store for all valid documents.
*/
-class SearchContext : public search::AttributeVector::SearchContext
+class SearchContext : public search::attribute::SearchContext
{
private:
using DocId = search::AttributeVector::DocId;
diff --git a/searchlib/src/tests/attribute/benchmark/attributesearcher.h b/searchlib/src/tests/attribute/benchmark/attributesearcher.h
index 3bf3d6e8fa5..43531b48f05 100644
--- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h
+++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h
@@ -5,6 +5,7 @@
#include <vespa/searchlib/util/runnable.h>
#include <vespa/searchlib/attribute/attribute.h>
#include <vespa/searchlib/attribute/attributeguard.h>
+#include <vespa/searchlib/attribute/search_context.h>
#include <vespa/searchlib/queryeval/hitcollector.h>
#include <vespa/searchlib/queryeval/executeinfo.h>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -130,7 +131,7 @@ AttributeFindSearcher<T>::doRun()
this->buildTermQuery(_query, _attrPtr->getName(), ss.str().data());
AttributeGuard guard(_attrPtr);
- std::unique_ptr<AttributeVector::SearchContext> searchContext =
+ std::unique_ptr<attribute::SearchContext> searchContext =
_attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()),
attribute::SearchContextParams());
@@ -208,7 +209,7 @@ AttributeRangeSearcher::doRun()
buildTermQuery(_query, _attrPtr->getName(), ss.str().data());
AttributeGuard guard(_attrPtr);
- std::unique_ptr<AttributeVector::SearchContext> searchContext =
+ std::unique_ptr<attribute::SearchContext> searchContext =
_attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()),
attribute::SearchContextParams());
@@ -247,7 +248,7 @@ AttributePrefixSearcher::doRun()
buildTermQuery(_query, _attrPtr->getName(), _values[i % _values.size()].c_str(), true);
AttributeGuard guard(_attrPtr);
- std::unique_ptr<AttributeVector::SearchContext> searchContext =
+ std::unique_ptr<attribute::SearchContext> searchContext =
_attrPtr->getSearch(vespalib::stringref(&_query[0], _query.size()),
attribute::SearchContextParams());
diff --git a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
index 714a96f91b9..e34c0f52e41 100644
--- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp
@@ -31,11 +31,12 @@ using search::StringAttribute;
using search::attribute::BasicType;
using search::attribute::CollectionType;
using search::attribute::Config;
+using search::attribute::SearchContext;
using search::attribute::SearchContextParams;
using search::fef::TermFieldMatchData;
using search::queryeval::SearchIterator;
-typedef std::unique_ptr<AttributeVector::SearchContext> SearchContextPtr;
+using SearchContextPtr = std::unique_ptr<SearchContext>;
typedef std::unique_ptr<search::queryeval::SearchIterator> SearchBasePtr;
struct BitVectorTest
diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
index e9d928e0910..9a4728edba8 100644
--- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
+++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
@@ -39,10 +39,11 @@ using search::StringAttribute;
using search::attribute::BasicType;
using search::attribute::CollectionType;
using search::attribute::Config;
+using search::attribute::SearchContext;
using search::attribute::SearchContextParams;
using search::fef::TermFieldMatchData;
-typedef std::unique_ptr<AttributeVector::SearchContext> SearchContextPtr;
+using SearchContextPtr = std::unique_ptr<SearchContext>;
typedef std::unique_ptr<search::queryeval::SearchIterator> SearchBasePtr;
diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
index 868f7d5a93b..ad49212fffc 100644
--- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
+++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
@@ -37,10 +37,11 @@ using attribute::BasicType;
using attribute::Config;
using queryeval::PostingInfo;
using queryeval::MinMaxPostingInfo;
+using search::attribute::SearchContext;
using search::fef::TermFieldMatchData;
using search::queryeval::SearchIterator;
-typedef std::unique_ptr<AttributeVector::SearchContext> SearchContextPtr;
+using SearchContextPtr = std::unique_ptr<SearchContext>;
typedef std::unique_ptr<search::queryeval::SearchIterator> SearchBasePtr;
void
diff --git a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
index 1a8eda40f52..5cee31bf909 100644
--- a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
+++ b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/document/base/documentid.h>
#include <vespa/searchlib/attribute/attributeguard.h>
#include <vespa/searchlib/attribute/reference_attribute.h>
+#include <vespa/searchlib/attribute/search_context.h>
#include <vespa/searchlib/common/i_gid_to_lid_mapper.h>
#include <vespa/searchlib/common/i_gid_to_lid_mapper_factory.h>
#include <vespa/searchlib/fef/termfieldmatchdata.h>
diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp
index 65de302ae04..aa64e944baa 100644
--- a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp
+++ b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp
@@ -47,8 +47,8 @@ isUnsignedSmallIntAttribute(const AttributeVector &a)
using AttributePtr = AttributeVector::SP;
using ResultSetPtr = std::unique_ptr<ResultSet>;
using SearchBasePtr = queryeval::SearchIterator::UP;
-using SearchContext = AttributeVector::SearchContext;
-using SearchContextPtr = std::unique_ptr<AttributeVector::SearchContext>;
+using search::attribute::SearchContext;
+using SearchContextPtr = std::unique_ptr<SearchContext>;
using largeint_t = AttributeVector::largeint_t;
using attribute::BasicType;
@@ -1910,7 +1910,7 @@ public:
}
_attr.commit();
}
- search::AttributeVector::SearchContext::UP create_search_context(const std::string& term) const {
+ std::unique_ptr<SearchContext> create_search_context(const std::string& term) const {
return _attr.getSearch(std::make_unique<search::QueryTermSimple>(term, search::TermType::WORD),
SearchContextParams().useBitVector(true));
}
diff --git a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp b/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp
index d8619386892..576a2ddb467 100644
--- a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp
+++ b/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp
@@ -17,6 +17,7 @@ LOG_SETUP("stringattribute_test");
using search::attribute::CollectionType;
using search::attribute::IAttributeVector;
+using search::attribute::SearchContext;
using vespalib::datastore::EntryRef;
using namespace search;
@@ -385,7 +386,7 @@ testSingleValue(Attribute & svsa, Config &cfg)
TEST("testSingleValue")
{
- EXPECT_EQUAL(24u, sizeof(AttributeVector::SearchContext));
+ EXPECT_EQUAL(24u, sizeof(SearchContext));
EXPECT_EQUAL(56u, sizeof(StringSearchHelper));
EXPECT_EQUAL(88u, sizeof(SingleValueStringAttribute::StringSingleImplSearchContext));
{
diff --git a/searchlib/src/tests/queryeval/queryeval.cpp b/searchlib/src/tests/queryeval/queryeval.cpp
index cc9e90bb761..dbf8ddba52c 100644
--- a/searchlib/src/tests/queryeval/queryeval.cpp
+++ b/searchlib/src/tests/queryeval/queryeval.cpp
@@ -361,7 +361,7 @@ public:
}
private:
search::SingleBoolAttribute _a;
- search::AttributeVector::SearchContext::UP _sc;
+ std::unique_ptr<search::attribute::SearchContext> _sc;
mutable TermFieldMatchData _tfmd;
};
diff --git a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt
index 4fff7cf96c1..0bc7345594b 100644
--- a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt
+++ b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt
@@ -90,6 +90,7 @@ vespa_add_library(searchlib_attribute OBJECT
reference_attribute.cpp
reference_attribute_saver.cpp
reference_mappings.cpp
+ search_context.cpp
singleboolattribute.cpp
singleenumattribute.cpp
singleenumattributesaver.cpp
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
index f83bcde817b..1edd5d9fe76 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
@@ -3,14 +3,12 @@
#include "address_space_components.h"
#include "attribute_read_guard.h"
#include "attributefilesavetarget.h"
-#include "attributeiterators.hpp"
#include "attributesaver.h"
#include "attributevector.h"
#include "attributevector.hpp"
#include "floatbase.h"
#include "interlock.h"
#include "ipostinglistattributebase.h"
-#include "ipostinglistsearchcontext.h"
#include "stringbase.h"
#include <vespa/document/update/assignvalueupdate.h>
#include <vespa/document/update/mapvalueupdate.h>
@@ -19,7 +17,6 @@
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/query/query_term_decoder.h>
-#include <vespa/searchlib/queryeval/emptysearch.h>
#include <vespa/searchlib/util/file_settings.h>
#include <vespa/searchlib/util/logutil.h>
#include <vespa/vespalib/util/exceptions.h>
@@ -421,72 +418,18 @@ AttributeVector::findFoldedEnums(const char *) const {
const char * AttributeVector::getStringFromEnum(EnumHandle) const { return nullptr; }
-AttributeVector::SearchContext::SearchContext(const AttributeVector &attr) :
- _attr(attr),
- _plsc(nullptr)
-{ }
-
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
AttributeVector::getSearch(QueryPacketT searchSpec, const SearchContextParams &params) const
{
return getSearch(QueryTermDecoder::decodeTerm(searchSpec), params);
}
-attribute::ISearchContext::UP
+std::unique_ptr<attribute::ISearchContext>
AttributeVector::createSearchContext(QueryTermSimpleUP term, const attribute::SearchContextParams &params) const
{
return getSearch(std::move(term), params);
}
-AttributeVector::SearchContext::~SearchContext() = default;
-
-unsigned int
-AttributeVector::SearchContext::approximateHits() const
-{
- if (_plsc != nullptr) {
- return _plsc->approximateHits();
- }
- return std::max(uint64_t(_attr.getNumDocs()),
- _attr.getStatus().getNumValues());
-}
-
-SearchIterator::UP
-AttributeVector::SearchContext::
-createIterator(fef::TermFieldMatchData *matchData, bool strict)
-{
- if (_plsc != nullptr) {
- SearchIterator::UP res = _plsc->createPostingIterator(matchData, strict);
- if (res) {
- return res;
- }
- }
- return createFilterIterator(matchData, strict);
-}
-
-
-SearchIterator::UP
-AttributeVector::SearchContext::
-createFilterIterator(fef::TermFieldMatchData *matchData, bool strict)
-{
- if (!valid())
- return std::make_unique<queryeval::EmptySearch>();
- if (getIsFilter()) {
- return SearchIterator::UP(strict ?
- new FilterAttributeIteratorStrict<AttributeVector::SearchContext>(*this, matchData) :
- new FilterAttributeIteratorT<AttributeVector::SearchContext>(*this, matchData));
- }
- return SearchIterator::UP(strict ?
- new AttributeIteratorStrict<AttributeVector::SearchContext>(*this, matchData) :
- new AttributeIteratorT<AttributeVector::SearchContext>(*this, matchData));
-}
-
-
-void
-AttributeVector::SearchContext::fetchPostings(const queryeval::ExecuteInfo &execInfo) {
- if (_plsc != nullptr)
- _plsc->fetchPostings(execInfo);
-}
-
bool
AttributeVector::apply(DocId doc, const MapValueUpdate &map) {
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h
index ce65664d7d7..4e3bd259cc6 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h
@@ -59,6 +59,7 @@ namespace search {
class IPostingListAttributeBase;
class Interlock;
class InterlockGuard;
+ class SearchContext;
class MultiValueMappingBase;
}
@@ -499,59 +500,10 @@ public:
const tensor::ITensorAttribute *asTensorAttribute() const override;
const attribute::IMultiValueAttribute* as_multi_value_attribute() const override;
- /**
- - Search for equality
- - Range search
- */
-
- class SearchContext : public attribute::ISearchContext
- {
- template <class SC> friend class AttributeIteratorT;
- template <class SC> friend class FilterAttributeIteratorT;
- template <class PL> friend class AttributePostingListIteratorT;
- template <class PL> friend class FilterAttributePostingListIteratorT;
- protected:
- using QueryTermSimpleUP = std::unique_ptr<QueryTermSimple>;
- public:
- SearchContext(const SearchContext &) = delete;
- SearchContext & operator = (const SearchContext &) = delete;
-
- typedef std::unique_ptr<SearchContext> UP;
- ~SearchContext();
-
- unsigned int approximateHits() const override;
- queryeval::SearchIterator::UP createIterator(fef::TermFieldMatchData *matchData, bool strict) override;
- void fetchPostings(const queryeval::ExecuteInfo &execInfo) override;
- bool valid() const override { return false; }
- Int64Range getAsIntegerTerm() const override { return Int64Range(); }
- const QueryTermUCS4 * queryTerm() const override {
- return static_cast<const QueryTermUCS4 *>(nullptr);
- }
- const vespalib::string &attributeName() const override {
- return _attr.getName();
- }
-
- const AttributeVector & attribute() const { return _attr; }
-
- protected:
- SearchContext(const AttributeVector &attr);
- const AttributeVector & _attr;
-
- attribute::IPostingListSearchContext *_plsc;
-
- /**
- * Creates an attribute search iterator associated with this
- * search context. Postings lists are not used.
- **/
- virtual queryeval::SearchIterator::UP createFilterIterator(fef::TermFieldMatchData *matchData, bool strict);
-
- bool getIsFilter() const { return _attr.getConfig().getIsFilter(); }
- };
-
- SearchContext::UP getSearch(QueryPacketT searchSpec, const attribute::SearchContextParams &params) const;
- attribute::ISearchContext::UP createSearchContext(QueryTermSimpleUP term,
+ std::unique_ptr<attribute::SearchContext> getSearch(QueryPacketT searchSpec, const attribute::SearchContextParams &params) const;
+ std::unique_ptr<attribute::ISearchContext> createSearchContext(QueryTermSimpleUP term,
const attribute::SearchContextParams &params) const override;
- virtual SearchContext::UP getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams &params) const = 0;
+ virtual std::unique_ptr<attribute::SearchContext> getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams &params) const = 0;
virtual const IEnumStore* getEnumStoreBase() const;
virtual IEnumStore* getEnumStoreBase();
virtual const attribute::MultiValueMappingBase *getMultiValueBase() const;
diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp
index 0179841e7fa..c1e49f2ce37 100644
--- a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp
@@ -22,7 +22,7 @@ StringDirectAttribute(const vespalib::string & baseFileName, const Config & c)
StringDirectAttribute::~StringDirectAttribute() = default;
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
StringDirectAttribute::getSearch(QueryTermSimpleUP, const attribute::SearchContextParams &) const {
LOG_ABORT("StringDirectAttribute::getSearch is not implemented and should never be called.");
}
diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.h b/searchlib/src/vespa/searchlib/attribute/attrvector.h
index b6ecc7a4cae..7713c210033 100644
--- a/searchlib/src/vespa/searchlib/attribute/attrvector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attrvector.h
@@ -142,7 +142,7 @@ private:
bool onLoad(vespalib::Executor *executor) override;
const char * getFromEnum(EnumHandle e) const override { return &_buffer[e]; }
const char * getStringFromEnum(EnumHandle e) const override { return &_buffer[e]; }
- SearchContext::UP getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
+ std::unique_ptr<attribute::SearchContext> getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
protected:
StringDirectAttribute(const vespalib::string & baseFileName, const Config & c);
~StringDirectAttribute() override;
diff --git a/searchlib/src/vespa/searchlib/attribute/extendableattributes.h b/searchlib/src/vespa/searchlib/attribute/extendableattributes.h
index bb8197c1908..5a1d005686e 100644
--- a/searchlib/src/vespa/searchlib/attribute/extendableattributes.h
+++ b/searchlib/src/vespa/searchlib/attribute/extendableattributes.h
@@ -39,12 +39,12 @@ class SingleExtAttribute
using BasicType = typename Super::BasicType;
using QueryTermSimpleUP = typename Super::QueryTermSimpleUP;
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override
{
(void) term;
(void) params;
- return AttributeVector::SearchContext::UP();
+ return {};
}
IExtendAttribute * getExtendInterface() override { return this; }
public:
@@ -111,12 +111,12 @@ protected:
: Super(name, Config(BasicType::fromType(T()), ctype))
{ }
private:
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override
{
(void) term;
(void) params;
- return AttributeVector::SearchContext::UP();
+ return {};
}
IExtendAttribute * getExtendInterface() override { return this; }
@@ -203,12 +203,12 @@ protected:
class WeightedSetIntegerExtAttribute
: public WeightedSetExtAttributeBase<MultiIntegerExtAttribute>
{
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override
{
(void) term;
(void) params;
- return AttributeVector::SearchContext::UP();
+ return {};
}
public:
WeightedSetIntegerExtAttribute(const vespalib::string & name);
@@ -220,12 +220,12 @@ public:
class WeightedSetFloatExtAttribute
: public WeightedSetExtAttributeBase<MultiFloatExtAttribute>
{
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override
{
(void) term;
(void) params;
- return AttributeVector::SearchContext::UP();
+ return {};
}
public:
WeightedSetFloatExtAttribute(const vespalib::string & name);
diff --git a/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp b/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp
index 7b2b9db574d..cfa70beeefc 100644
--- a/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp
@@ -53,7 +53,7 @@ FlagAttributeT<B>::FlagAttributeT(const vespalib::string & baseFileName, const A
}
template <typename B>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
FlagAttributeT<B>::getSearch(QueryTermSimple::UP qTerm, const attribute::SearchContextParams &) const
{
return std::make_unique<SearchContext>(std::move(qTerm), *this);
diff --git a/searchlib/src/vespa/searchlib/attribute/flagattribute.h b/searchlib/src/vespa/searchlib/attribute/flagattribute.h
index 05a2ed18e45..cdf1c83e41b 100644
--- a/searchlib/src/vespa/searchlib/attribute/flagattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/flagattribute.h
@@ -31,7 +31,7 @@ private:
};
bool onLoad(vespalib::Executor *executor) override;
bool onLoadEnumerated(ReaderBase &attrReader) override;
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams & params) const override;
void clearOldValues(DocId doc) override;
void setNewValues(DocId doc, const std::vector<typename B::WType> & values) override;
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h
index 0e4ebbcd0f4..6c5abc5f150 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h
@@ -5,6 +5,7 @@
#include "integerbase.h"
#include "floatbase.h"
#include "multivalueattribute.h"
+#include "search_context.h"
#include <limits>
namespace search {
@@ -59,7 +60,7 @@ public:
/*
* Specialization of SearchContext for weighted set type
*/
- class SetSearchContext final : public NumericAttribute::Range<T>, public AttributeVector::SearchContext
+ class SetSearchContext final : public NumericAttribute::Range<T>, public attribute::SearchContext
{
private:
const MultiValueNumericAttribute<B, M> & _toBeSearched;
@@ -107,7 +108,7 @@ public:
/*
* Specialization of SearchContext for array type
*/
- class ArraySearchContext : public NumericAttribute::Range<T>, public AttributeVector::SearchContext
+ class ArraySearchContext : public NumericAttribute::Range<T>, public attribute::SearchContext
{
private:
const MultiValueNumericAttribute<B, M> & _toBeSearched;
@@ -166,7 +167,7 @@ public:
bool onLoad(vespalib::Executor *executor) override;
virtual bool onLoadEnumerated(ReaderBase &attrReader);
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams & params) const override;
virtual void clearOldValues(DocId doc);
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp
index 73d248a21fa..3d6ea3970a9 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp
@@ -165,7 +165,7 @@ MultiValueNumericAttribute<B, M>::onLoad(vespalib::Executor *)
}
template <typename B, typename M>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
MultiValueNumericAttribute<B, M>::getSearch(QueryTermSimple::UP qTerm,
const attribute::SearchContextParams & params) const
{
@@ -193,7 +193,7 @@ bool MultiValueNumericAttribute<B, M>::SetSearchContext::valid() const { return
template <typename B, typename M>
MultiValueNumericAttribute<B, M>::SetSearchContext::SetSearchContext(QueryTermSimple::UP qTerm, const NumericAttribute & toBeSearched) :
NumericAttribute::Range<T>(*qTerm),
- AttributeVector::SearchContext(toBeSearched),
+ attribute::SearchContext(toBeSearched),
_toBeSearched(static_cast<const MultiValueNumericAttribute<B, M> &>(toBeSearched))
{ }
@@ -225,7 +225,7 @@ bool MultiValueNumericAttribute<B, M>::ArraySearchContext::valid() const { retur
template <typename B, typename M>
MultiValueNumericAttribute<B, M>::ArraySearchContext::ArraySearchContext(QueryTermSimple::UP qTerm, const NumericAttribute & toBeSearched) :
NumericAttribute::Range<T>(*qTerm),
- AttributeVector::SearchContext(toBeSearched),
+ attribute::SearchContext(toBeSearched),
_toBeSearched(static_cast<const MultiValueNumericAttribute<B, M> &>(toBeSearched))
{ }
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h
index 1c0124f6a1c..fb0e9c88240 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h
@@ -5,6 +5,7 @@
#include "multienumattribute.h"
#include "numericbase.h"
#include "primitivereader.h"
+#include "search_context.h"
namespace search {
@@ -41,7 +42,7 @@ protected:
/*
* Specialization of SearchContext for weighted set type
*/
- class SetSearchContext : public NumericAttribute::Range<T>, public AttributeVector::SearchContext
+ class SetSearchContext : public NumericAttribute::Range<T>, public attribute::SearchContext
{
protected:
const MultiValueNumericEnumAttribute<B, M> & _toBeSearched;
@@ -94,7 +95,7 @@ protected:
/*
* Specialization of SearchContext for array type
*/
- class ArraySearchContext : public NumericAttribute::Range<T>, public AttributeVector::SearchContext
+ class ArraySearchContext : public NumericAttribute::Range<T>, public attribute::SearchContext
{
protected:
const MultiValueNumericEnumAttribute<B, M> & _toBeSearched;
@@ -155,7 +156,7 @@ public:
bool onLoadEnumerated(ReaderBase &attrReader);
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
//-------------------------------------------------------------------------
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp
index 4322faefe67..80fe352630b 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp
@@ -115,7 +115,7 @@ MultiValueNumericEnumAttribute<B, M>::onLoad(vespalib::Executor *)
}
template <typename B, typename M>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
MultiValueNumericEnumAttribute<B, M>::getSearch(QueryTermSimple::UP qTerm,
const attribute::SearchContextParams & params) const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
index eca6b68455c..26e6ee12439 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
@@ -88,7 +88,7 @@ public:
void removeOldGenerations(generation_t firstUsed) override;
void onGenerationChange(generation_t generation) override;
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
const IDocumentWeightAttribute *asDocumentWeightAttribute() const override;
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
index 051a22bd5e8..7c348f4b910 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
@@ -71,11 +71,11 @@ MultiValueNumericPostingAttribute<B, M>::onGenerationChange(generation_t generat
}
template <typename B, typename M>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
MultiValueNumericPostingAttribute<B, M>::getSearch(QueryTermSimpleUP qTerm,
const attribute::SearchContextParams & params) const
{
- std::unique_ptr<search::AttributeVector::SearchContext> sc;
+ std::unique_ptr<search::attribute::SearchContext> sc;
sc.reset(new typename std::conditional<M::_hasWeight,
SetPostingSearchContext,
ArrayPostingSearchContext>::
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringattribute.h b/searchlib/src/vespa/searchlib/attribute/multistringattribute.h
index 66ca9f5c04c..e832f53777b 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multistringattribute.h
@@ -38,7 +38,6 @@ protected:
using DocId = StringAttribute::DocId;
using EnumHandle = StringAttribute::EnumHandle;
using LoadedVector = StringAttribute::LoadedVector;
- using SearchContext = StringAttribute::SearchContext;
using ValueModifier = StringAttribute::ValueModifier;
using WeightedConstChar = StringAttribute::WeightedConstChar;
using WeightedEnum = StringAttribute::WeightedEnum;
@@ -128,7 +127,7 @@ public:
*/
class StringSetImplSearchContext : public StringImplSearchContext {
public:
- StringSetImplSearchContext(SearchContext::QueryTermSimpleUP qTerm, const StringAttribute & toBeSearched) :
+ StringSetImplSearchContext(attribute::SearchContext::QueryTermSimpleUP qTerm, const StringAttribute & toBeSearched) :
StringImplSearchContext(std::move(qTerm), toBeSearched)
{ }
protected:
@@ -140,7 +139,7 @@ public:
*/
class StringArrayImplSearchContext : public StringImplSearchContext {
public:
- StringArrayImplSearchContext(SearchContext::QueryTermSimpleUP qTerm, const StringAttribute & toBeSearched) :
+ StringArrayImplSearchContext(attribute::SearchContext::QueryTermSimpleUP qTerm, const StringAttribute & toBeSearched) :
StringImplSearchContext(std::move(qTerm), toBeSearched)
{ }
protected:
@@ -154,10 +153,10 @@ public:
using BT::queryTerm;
using AttrType = MultiValueStringAttributeT<B, M>;
public:
- StringTemplSearchContext(SearchContext::QueryTermSimpleUP qTerm, const AttrType & toBeSearched);
+ StringTemplSearchContext(attribute::SearchContext::QueryTermSimpleUP qTerm, const AttrType & toBeSearched);
};
- SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
};
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
index c7e092799d1..454913c3990 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
@@ -37,7 +37,7 @@ MultiValueStringAttributeT<B, M>::freezeEnumDictionary()
template <typename B, typename M>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
MultiValueStringAttributeT<B, M>::getSearch(QueryTermSimpleUP qTerm,
const attribute::SearchContextParams &) const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
index e2993835d83..9f8827028cc 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
@@ -84,7 +84,7 @@ public:
void removeOldGenerations(generation_t firstUsed) override;
void onGenerationChange(generation_t generation) override;
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
const IDocumentWeightAttribute *asDocumentWeightAttribute() const override;
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
index a1f8b42df2f..d9c79bd7b24 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
@@ -85,11 +85,11 @@ MultiValueStringPostingAttributeT<B, T>::onGenerationChange(generation_t generat
template <typename B, typename T>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
MultiValueStringPostingAttributeT<B, T>::getSearch(QueryTermSimpleUP qTerm,
const attribute::SearchContextParams & params) const
{
- std::unique_ptr<search::AttributeVector::SearchContext> sc;
+ std::unique_ptr<search::attribute::SearchContext> sc;
sc.reset(new typename std::conditional<T::_hasWeight,
StringSetPostingSearchContext,
StringArrayPostingSearchContext>::
diff --git a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp
index 521b6f8c825..0602d983513 100644
--- a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp
@@ -1,13 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "not_implemented_attribute.h"
+#include "search_context.h"
#include <vespa/vespalib/util/exceptions.h>
using vespalib::make_string_short::fmt;
namespace search {
using largeint_t = attribute::IAttributeVector::largeint_t;
-using SearchContext = AttributeVector::SearchContext;
+using attribute::SearchContext;
void
NotImplementedAttribute::notImplemented() const {
@@ -141,10 +142,10 @@ NotImplementedAttribute::addDoc(DocId &) {
return false;
}
-SearchContext::UP
+std::unique_ptr<SearchContext>
NotImplementedAttribute::getSearch(QueryTermSimpleUP, const attribute::SearchContextParams &) const {
notImplemented();
- return SearchContext::UP();
+ return {};
}
void NotImplementedAttribute::onAddDocs(DocId ) { }
diff --git a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h
index f3af6cdd1ae..8987681d640 100644
--- a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h
@@ -35,7 +35,7 @@ struct NotImplementedAttribute : AttributeVector {
bool addDoc(DocId &) override;
void onAddDocs(DocId lidLimit) override;
- SearchContext::UP getSearch(QueryTermSimpleUP, const attribute::SearchContextParams &) const override;
+ std::unique_ptr<attribute::SearchContext> getSearch(QueryTermSimpleUP, const attribute::SearchContextParams &) const override;
};
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
index 4464ab02c86..473174de284 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
@@ -5,6 +5,7 @@
#include "readerbase.h"
#include "reference_attribute.h"
#include "reference_attribute_saver.h"
+#include "search_context.h"
#include <vespa/document/base/documentid.h>
#include <vespa/document/base/idstringexception.h>
#include <vespa/searchlib/common/i_gid_to_lid_mapper.h>
@@ -458,14 +459,14 @@ ReferenceAttribute::onShrinkLidSpace()
namespace {
-class ReferenceSearchContext : public AttributeVector::SearchContext {
+class ReferenceSearchContext : public attribute::SearchContext {
private:
const ReferenceAttribute& _ref_attr;
GlobalId _term;
public:
ReferenceSearchContext(const ReferenceAttribute& ref_attr, const GlobalId& term)
- : AttributeVector::SearchContext(ref_attr),
+ : attribute::SearchContext(ref_attr),
_ref_attr(ref_attr),
_term(term)
{
@@ -492,7 +493,7 @@ public:
}
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
ReferenceAttribute::getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams& params) const
{
(void) params;
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
index b445d030b57..c86793036cd 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h
@@ -98,7 +98,7 @@ public:
_referenceMappings.foreach_lid(targetLid, std::forward<FunctionType>(func));
}
- SearchContext::UP getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams& params) const override;
+ std::unique_ptr<SearchContext> getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams& params) const override;
};
}
diff --git a/searchlib/src/vespa/searchlib/attribute/search_context.cpp b/searchlib/src/vespa/searchlib/attribute/search_context.cpp
new file mode 100644
index 00000000000..8e8cca13671
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/search_context.cpp
@@ -0,0 +1,81 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "search_context.h"
+#include "attributevector.h"
+#include "attributeiterators.hpp"
+#include "ipostinglistsearchcontext.h"
+#include <vespa/searchlib/queryeval/emptysearch.h>
+
+using search::queryeval::SearchIterator;
+
+namespace search::attribute {
+
+SearchContext::SearchContext(const AttributeVector &attr)
+ : _attr(attr),
+ _plsc(nullptr)
+{
+}
+
+SearchContext::~SearchContext() = default;
+
+unsigned int
+SearchContext::approximateHits() const
+{
+ if (_plsc != nullptr) {
+ return _plsc->approximateHits();
+ }
+ return std::max(uint64_t(_attr.getNumDocs()), _attr.getStatus().getNumValues());
+}
+
+std::unique_ptr<SearchIterator>
+SearchContext::createIterator(fef::TermFieldMatchData* matchData, bool strict)
+{
+ if (_plsc != nullptr) {
+ std::unique_ptr<SearchIterator> res = _plsc->createPostingIterator(matchData, strict);
+ if (res) {
+ return res;
+ }
+ }
+ return createFilterIterator(matchData, strict);
+}
+
+
+std::unique_ptr<SearchIterator>
+SearchContext::createFilterIterator(fef::TermFieldMatchData* matchData, bool strict)
+{
+ if (!valid()) {
+ return std::make_unique<queryeval::EmptySearch>();
+ }
+ if (getIsFilter()) {
+ return (strict ?
+ std::make_unique<FilterAttributeIteratorStrict<SearchContext>>(*this, matchData) :
+ std::make_unique<FilterAttributeIteratorT<SearchContext>>(*this, matchData));
+ }
+ return (strict ?
+ std::make_unique<AttributeIteratorStrict<SearchContext>>(*this, matchData) :
+ std::make_unique<AttributeIteratorT<SearchContext>>(*this, matchData));
+}
+
+
+void
+SearchContext::fetchPostings(const queryeval::ExecuteInfo& execInfo)
+{
+ if (_plsc != nullptr) {
+ _plsc->fetchPostings(execInfo);
+ }
+}
+
+const vespalib::string&
+SearchContext::attributeName() const
+{
+ return _attr.getName();
+}
+
+bool
+SearchContext::getIsFilter() const
+{
+ return _attr.getConfig().getIsFilter();
+}
+
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/search_context.h b/searchlib/src/vespa/searchlib/attribute/search_context.h
new file mode 100644
index 00000000000..3e9479b57fb
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/search_context.h
@@ -0,0 +1,62 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/searchcommon/attribute/i_search_context.h>
+
+namespace search {
+
+class AttributeVector;
+class QueryTermSimple;
+
+}
+
+namespace search::queryeval { class SearchIterator; }
+
+namespace search::attribute {
+
+class IPostingListSearchContext;
+
+/*
+ * SearchContext handles the creation of search iterators for a query term on an attribute vector.
+ * This is an abstract class.
+ */
+class SearchContext : public ISearchContext
+{
+protected:
+ using QueryTermSimpleUP = std::unique_ptr<QueryTermSimple>;
+public:
+ SearchContext(const SearchContext&) = delete;
+ SearchContext(SearchContext&&) = delete;
+ SearchContext& operator=(const SearchContext&) = delete;
+ SearchContext& operator=(SearchContext&&) = delete;
+ ~SearchContext() override;
+
+ unsigned int approximateHits() const override;
+ std::unique_ptr<queryeval::SearchIterator> createIterator(fef::TermFieldMatchData* matchData, bool strict) override;
+ void fetchPostings(const queryeval::ExecuteInfo& execInfo) override;
+ bool valid() const override { return false; }
+ Int64Range getAsIntegerTerm() const override { return Int64Range(); }
+ const QueryTermUCS4* queryTerm() const override {
+ return static_cast<const QueryTermUCS4*>(nullptr);
+ }
+ const vespalib::string& attributeName() const override;
+
+ const AttributeVector& attribute() const { return _attr; }
+
+protected:
+ SearchContext(const AttributeVector& attr);
+
+ const AttributeVector& _attr;
+ attribute::IPostingListSearchContext* _plsc;
+
+ /**
+ * Creates an attribute search iterator associated with this
+ * search context. Postings lists are not used.
+ **/
+ virtual std::unique_ptr<queryeval::SearchIterator> createFilterIterator(fef::TermFieldMatchData* matchData, bool strict);
+
+ bool getIsFilter() const;
+};
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
index f57f3336627..8db99c115a0 100644
--- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
@@ -1,10 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "singleboolattribute.h"
#include "attributevector.hpp"
#include "iattributesavetarget.h"
#include "ipostinglistsearchcontext.h"
#include "primitivereader.h"
-#include "singleboolattribute.h"
+#include "search_context.h"
#include <vespa/searchlib/common/bitvectoriterator.h>
#include <vespa/searchlib/query/query_term_simple.h>
#include <vespa/searchlib/queryeval/emptysearch.h>
@@ -100,7 +101,7 @@ SingleBoolAttribute::onUpdateStat() {
namespace {
-class BitVectorSearchContext : public AttributeVector::SearchContext, public attribute::IPostingListSearchContext
+class BitVectorSearchContext : public attribute::SearchContext, public attribute::IPostingListSearchContext
{
private:
const BitVector & _bv;
@@ -174,7 +175,7 @@ BitVectorSearchContext::approximateHits() const {
}
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
SingleBoolAttribute::getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams &) const {
return std::make_unique<BitVectorSearchContext>(std::move(term), *this);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h
index 31054f5e80a..f7efe27277e 100644
--- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h
@@ -30,7 +30,7 @@ public:
void onGenerationChange(generation_t generation) override;
uint64_t getEstimatedSaveByteSize() const override;
- SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams & params) const override;
uint32_t getValueCount(DocId doc) const override {
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h
index df03f8811e1..30b205482e8 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h
@@ -4,6 +4,7 @@
#include "integerbase.h"
#include "floatbase.h"
+#include "search_context.h"
#include <vespa/vespalib/util/atomic.h>
#include <vespa/vespalib/util/rcuvector.h>
#include <limits>
@@ -37,7 +38,7 @@ private:
* Specialization of SearchContext
*/
template <typename M>
- class SingleSearchContext final : public M, public AttributeVector::SearchContext
+ class SingleSearchContext final : public M, public attribute::SearchContext
{
private:
const T * _data;
@@ -106,7 +107,7 @@ public:
bool onLoadEnumerated(ReaderBase &attrReader);
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams & params) const override;
void set(DocId doc, T v) {
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp
index 9e8d2cfff7d..03e6cd95ded 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp
@@ -151,7 +151,7 @@ SingleValueNumericAttribute<B>::onLoad(vespalib::Executor *)
}
template <typename B>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
SingleValueNumericAttribute<B>::getSearch(QueryTermSimple::UP qTerm,
const attribute::SearchContextParams & params) const
{
@@ -215,7 +215,7 @@ template <typename M>
SingleValueNumericAttribute<B>::SingleSearchContext<M>::SingleSearchContext(QueryTermSimple::UP qTerm,
const NumericAttribute & toBeSearched) :
M(*qTerm, true),
- AttributeVector::SearchContext(toBeSearched),
+ attribute::SearchContext(toBeSearched),
_data(&static_cast<const SingleValueNumericAttribute<B> &>(toBeSearched)._data.acquire_elem_ref(0))
{ }
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h
index 0198668f4f2..4db14e18194 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h
@@ -4,6 +4,7 @@
#include "singleenumattribute.h"
#include "numericbase.h"
+#include "search_context.h"
#include <map>
namespace search {
@@ -48,7 +49,7 @@ protected:
/*
* Specialization of SearchContext
*/
- class SingleSearchContext : public NumericAttribute::Range<T>, public AttributeVector::SearchContext
+ class SingleSearchContext : public NumericAttribute::Range<T>, public attribute::SearchContext
{
protected:
const SingleValueNumericEnumAttribute<B> & _toBeSearched;
@@ -96,7 +97,7 @@ public:
bool onLoadEnumerated(ReaderBase &attrReader);
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
//-------------------------------------------------------------------------
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
index 845d3704a32..989532be4fd 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
@@ -152,7 +152,7 @@ SingleValueNumericEnumAttribute<B>::onLoad(vespalib::Executor *)
template <typename B>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
SingleValueNumericEnumAttribute<B>::getSearch(QueryTermSimple::UP qTerm,
const attribute::SearchContextParams & params) const
{
@@ -175,7 +175,7 @@ SingleValueNumericEnumAttribute<B>::SingleSearchContext::valid() const
template <typename B>
SingleValueNumericEnumAttribute<B>::SingleSearchContext::SingleSearchContext(QueryTermSimpleUP qTerm, const NumericAttribute & toBeSearched) :
NumericAttribute::Range<T>(*qTerm, true),
- AttributeVector::SearchContext(toBeSearched),
+ attribute::SearchContext(toBeSearched),
_toBeSearched(static_cast<const SingleValueNumericEnumAttribute<B> &>(toBeSearched))
{ }
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h
index e98d9f527c2..b91a14f5c46 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h
@@ -75,7 +75,7 @@ public:
void removeOldGenerations(generation_t firstUsed) override;
void onGenerationChange(generation_t generation) override;
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
bool onAddDoc(DocId doc) override {
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
index b87dadb5429..252677fabcc 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
@@ -143,7 +143,7 @@ SingleValueNumericPostingAttribute<B>::onGenerationChange(generation_t generatio
}
template <typename B>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
SingleValueNumericPostingAttribute<B>::getSearch(QueryTermSimple::UP qTerm,
const attribute::SearchContextParams & params) const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
index 368a081e020..9c6871d8ecb 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "singlesmallnumericattribute.h"
#include "attributeiterators.hpp"
#include "attributevector.hpp"
#include "iattributesavetarget.h"
#include "primitivereader.h"
-#include "singlesmallnumericattribute.h"
#include <vespa/searchlib/query/query_term_simple.h>
#include <vespa/searchlib/queryeval/emptysearch.h>
#include <vespa/searchlib/util/file_settings.h>
@@ -168,7 +168,7 @@ SingleValueSmallNumericAttribute::onSave(IAttributeSaveTarget &saveTarget)
assert(numDocs == getCommittedDocIdLimit());
}
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
SingleValueSmallNumericAttribute::getSearch(std::unique_ptr<QueryTermSimple> qTerm,
const attribute::SearchContextParams &) const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h
index 6c78708593a..0e3d485b1bb 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h
@@ -4,6 +4,7 @@
#include "integerbase.h"
#include "floatbase.h"
+#include "search_context.h"
#include <vespa/vespalib/util/atomic.h>
#include <vespa/vespalib/util/rcuvector.h>
#include <limits>
@@ -13,7 +14,7 @@ namespace search {
class SingleValueSmallNumericAttribute : public IntegerAttributeTemplate<int8_t>
{
private:
-// friend class AttributeVector::SearchContext;
+// friend class attribute::SearchContext;
typedef IntegerAttributeTemplate<int8_t> B;
typedef B::BaseType T;
typedef B::DocId DocId;
@@ -59,7 +60,7 @@ public:
/*
* Specialization of SearchContext
*/
- class SingleSearchContext : public NumericAttribute::Range<T>, public SearchContext
+ class SingleSearchContext : public NumericAttribute::Range<T>, public attribute::SearchContext
{
private:
const Word *_wordData;
@@ -124,7 +125,7 @@ public:
bool onLoad(vespalib::Executor *executor) override;
void onSave(IAttributeSaveTarget &saveTarget) override;
- SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams & params) const override;
T getFast(DocId doc) const {
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.h b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.h
index 8c4bffe237e..75ddfc99564 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.h
@@ -26,7 +26,6 @@ protected:
using EnumStore = typename SingleValueEnumAttribute<B>::EnumStore;
using LoadedVector = StringAttribute::LoadedVector;
using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
- using SearchContext = StringAttribute::SearchContext;
using ValueModifier = StringAttribute::ValueModifier;
using WeightedConstChar = StringAttribute::WeightedConstChar;
using WeightedEnum = StringAttribute::WeightedEnum;
@@ -78,7 +77,7 @@ public:
return 1;
}
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
class StringSingleImplSearchContext : public StringAttribute::StringSearchContext {
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
index 7c8815af30b..6c99db68bd4 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
@@ -36,7 +36,7 @@ SingleValueStringAttributeT<B>::freezeEnumDictionary()
template <typename B>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
SingleValueStringAttributeT<B>::getSearch(QueryTermSimpleUP qTerm,
const attribute::SearchContextParams &) const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h
index a209dd4bfad..f75926e5a60 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h
@@ -78,7 +78,7 @@ public:
void removeOldGenerations(generation_t firstUsed) override;
void onGenerationChange(generation_t generation) override;
- AttributeVector::SearchContext::UP
+ std::unique_ptr<attribute::SearchContext>
getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override;
bool onAddDoc(DocId doc) override {
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
index 58c62e60efe..1f52bbe3b47 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
@@ -135,7 +135,7 @@ SingleValueStringPostingAttributeT<B>::onGenerationChange(generation_t generatio
}
template <typename B>
-AttributeVector::SearchContext::UP
+std::unique_ptr<attribute::SearchContext>
SingleValueStringPostingAttributeT<B>::getSearch(QueryTermSimpleUP qTerm,
const attribute::SearchContextParams & params) const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/stringbase.h b/searchlib/src/vespa/searchlib/attribute/stringbase.h
index 6ba4c801590..f2adc863234 100644
--- a/searchlib/src/vespa/searchlib/attribute/stringbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/stringbase.h
@@ -7,6 +7,7 @@
#include "changevector.h"
#include "i_enum_store.h"
#include "loadedenumvalue.h"
+#include "search_context.h"
#include <vespa/vespalib/regex/regex.h>
#include <vespa/vespalib/text/lowercase.h>
#include <vespa/vespalib/text/utf8.h>
@@ -120,7 +121,7 @@ private:
long onSerializeForDescendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const override;
protected:
- class StringSearchContext : public SearchContext {
+ class StringSearchContext : public attribute::SearchContext {
public:
StringSearchContext(QueryTermSimpleUP qTerm, const StringAttribute & toBeSearched);
~StringSearchContext() override;