aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-12-12 16:18:09 +0000
committerGeir Storli <geirst@yahooinc.com>2023-12-12 17:04:29 +0000
commit82efe24f7af8ee3c51195bcd46ce6d407ded4d1f (patch)
treee3c9cc4ef5613017f4c386f488810ba22a4f7c63 /searchlib
parenta8b1990d44bbe5a9fe3f479ece2d890e0eee928e (diff)
Prepare for direct posting store integration for single value attributes.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.h44
-rw-r--r--searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.hpp74
-rw-r--r--searchlib/src/vespa/searchlib/attribute/i_docid_with_weight_posting_store.h4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h24
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp85
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h30
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp87
-rw-r--r--searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.h31
-rw-r--r--searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.hpp58
-rw-r--r--searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.h31
-rw-r--r--searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.hpp58
11 files changed, 318 insertions, 208 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.h b/searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.h
new file mode 100644
index 00000000000..125c265afcf
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.h
@@ -0,0 +1,44 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "i_direct_posting_store.h"
+#include <vespa/vespalib/datastore/entryref.h>
+#include <vector>
+
+namespace search { class IEnumStoreDictionary; }
+
+namespace search::attribute {
+
+/**
+ * Base adapter class used to implement a specific IDirectPostingStore interface for
+ * an attribute vector with underlying posting lists (fast-search).
+ */
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+class DirectPostingStoreAdapter : public ParentType {
+protected:
+ const PostingStoreType& _posting_store;
+ const EnumStoreType& _enum_store;
+ const IEnumStoreDictionary& _dict;
+ bool _attr_is_filter;
+
+public:
+ using IteratorType = typename ParentType::IteratorType;
+
+ DirectPostingStoreAdapter(const PostingStoreType& posting_store,
+ const EnumStoreType& enum_store,
+ bool attr_is_filter);
+
+ vespalib::datastore::EntryRef get_dictionary_snapshot() const override;
+ bool has_weight_iterator(vespalib::datastore::EntryRef posting_idx) const noexcept override;
+ std::unique_ptr<queryeval::SearchIterator> make_bitvector_iterator(vespalib::datastore::EntryRef posting_idx, uint32_t doc_id_limit,
+ fef::TermFieldMatchData& match_data, bool strict) const override;
+ bool has_bitvector(vespalib::datastore::EntryRef posting_idx) const noexcept override;
+ int64_t get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept override;
+
+ void create(vespalib::datastore::EntryRef idx, std::vector<IteratorType>& dst) const override;
+ IteratorType create(vespalib::datastore::EntryRef idx) const override;
+ bool has_always_weight_iterator() const noexcept override { return !_attr_is_filter; }
+};
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.hpp b/searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.hpp
new file mode 100644
index 00000000000..02fc1a84ec6
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/direct_posting_store_adapter.hpp
@@ -0,0 +1,74 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "i_enum_store_dictionary.h"
+#include "direct_posting_store_adapter.h"
+#include <cassert>
+
+namespace search::attribute {
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+DirectPostingStoreAdapter(const PostingStoreType& posting_store,
+ const EnumStoreType& enum_store,
+ bool attr_is_filter)
+ : _posting_store(posting_store),
+ _enum_store(enum_store),
+ _dict(enum_store.get_dictionary()),
+ _attr_is_filter(attr_is_filter)
+{
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+vespalib::datastore::EntryRef
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+get_dictionary_snapshot() const
+{
+ return _dict.get_frozen_root();
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+std::unique_ptr<queryeval::SearchIterator>
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+make_bitvector_iterator(vespalib::datastore::EntryRef posting_idx, uint32_t doc_id_limit,
+ fef::TermFieldMatchData& match_data, bool strict) const
+{
+ return _posting_store.make_bitvector_iterator(posting_idx, doc_id_limit, match_data, strict);
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+bool
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+has_weight_iterator(vespalib::datastore::EntryRef posting_idx) const noexcept
+{
+ return _posting_store.has_btree(posting_idx);
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+bool
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+has_bitvector(vespalib::datastore::EntryRef posting_idx) const noexcept
+{
+ return _posting_store.has_bitvector(posting_idx);
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+void
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+create(vespalib::datastore::EntryRef posting_idx, std::vector<IteratorType>& dst) const
+{
+ assert(posting_idx.valid());
+ _posting_store.beginFrozen(posting_idx, dst);
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::IteratorType
+DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+create(vespalib::datastore::EntryRef posting_idx) const
+{
+ assert(posting_idx.valid());
+ return _posting_store.beginFrozen(posting_idx);
+}
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/i_docid_with_weight_posting_store.h b/searchlib/src/vespa/searchlib/attribute/i_docid_with_weight_posting_store.h
index 1907279b39d..bdb4054b2d7 100644
--- a/searchlib/src/vespa/searchlib/attribute/i_docid_with_weight_posting_store.h
+++ b/searchlib/src/vespa/searchlib/attribute/i_docid_with_weight_posting_store.h
@@ -13,6 +13,8 @@ namespace search {
*/
class IDocidWithWeightPostingStore : public IDirectPostingStore {
public:
+ using IteratorType = DocidWithWeightIterator;
+
virtual void create(vespalib::datastore::EntryRef idx, std::vector<DocidWithWeightIterator> &dst) const = 0;
virtual DocidWithWeightIterator create(vespalib::datastore::EntryRef idx) const = 0;
@@ -24,5 +26,7 @@ public:
virtual bool has_always_weight_iterator() const noexcept = 0;
};
+
+
}
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
index 38cf12ca909..3e7ff01d484 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
@@ -2,6 +2,7 @@
#pragma once
+#include "numeric_direct_posting_store_adapter.h"
#include "multinumericenumattribute.h"
#include "postinglistattribute.h"
#include "i_docid_with_weight_posting_store.h"
@@ -32,25 +33,6 @@ public:
using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
private:
- class DocidWithWeightPostingStoreAdapter final : public IDocidWithWeightPostingStore {
- public:
- const MultiValueNumericPostingAttribute &self;
- bool _is_filter;
- DocidWithWeightPostingStoreAdapter(const MultiValueNumericPostingAttribute &self_in)
- : self(self_in), _is_filter(self_in.getIsFilter()) {}
- vespalib::datastore::EntryRef get_dictionary_snapshot() const override;
- LookupResult lookup(const LookupKey & key, vespalib::datastore::EntryRef dictionary_snapshot) const override;
- void collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback) const override;
- void create(vespalib::datastore::EntryRef posting_idx, std::vector<DocidWithWeightIterator> &dst) const override;
- DocidWithWeightIterator create(vespalib::datastore::EntryRef posting_idx) const override;
- std::unique_ptr<queryeval::SearchIterator> make_bitvector_iterator(vespalib::datastore::EntryRef posting_idx, uint32_t doc_id_limit, fef::TermFieldMatchData &match_data, bool strict) const override;
- bool has_weight_iterator(vespalib::datastore::EntryRef posting_idx) const noexcept override;
- bool has_bitvector(vespalib::datastore::EntryRef posting_idx) const noexcept override;
- int64_t get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept override;
- bool has_always_weight_iterator() const noexcept override { return !_is_filter; }
- };
- DocidWithWeightPostingStoreAdapter _posting_store_adapter;
-
friend class PostingListAttributeTest;
template <typename, typename, typename>
friend class attribute::PostingSearchContext; // getEnumStore()
@@ -73,6 +55,10 @@ private:
using WeightedIndex = typename MultiValueNumericEnumAttribute<B, M>::WeightedIndex;
using generation_t = typename MultiValueNumericEnumAttribute<B, M>::generation_t;
+ using DirectPostingStoreAdapterType = attribute::NumericDirectPostingStoreAdapter<IDocidWithWeightPostingStore,
+ PostingStore, EnumStore>;
+ DirectPostingStoreAdapterType _posting_store_adapter;
+
using PostingParent::_posting_store;
using PostingParent::clearAllPostings;
using PostingParent::handle_load_posting_lists;
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
index e90940f6ca0..ea1058d88fb 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
@@ -4,6 +4,7 @@
#include "multinumericpostattribute.h"
#include "multi_numeric_enum_search_context.h"
+#include "numeric_direct_posting_store_adapter.hpp"
#include <vespa/searchcommon/attribute/config.h>
#include <charconv>
@@ -43,7 +44,7 @@ MultiValueNumericPostingAttribute<B, M>::MultiValueNumericPostingAttribute(const
const AttributeVector::Config & cfg)
: MultiValueNumericEnumAttribute<B, M>(name, cfg),
PostingParent(*this, this->getEnumStore()),
- _posting_store_adapter(*this)
+ _posting_store_adapter(this->get_posting_store(), this->_enumStore, this->getIsFilter())
{
}
@@ -85,88 +86,6 @@ MultiValueNumericPostingAttribute<B, M>::getSearch(QueryTermSimpleUP qTerm,
}
template <typename B, typename M>
-vespalib::datastore::EntryRef
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::get_dictionary_snapshot() const
-{
- const IEnumStoreDictionary& dictionary = self._enumStore.get_dictionary();
- return dictionary.get_frozen_root();
-}
-
-template <typename B, typename M>
-IDirectPostingStore::LookupResult
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::lookup(const LookupKey & key, vespalib::datastore::EntryRef dictionary_snapshot) const
-{
- const IEnumStoreDictionary& dictionary = self._enumStore.get_dictionary();
- int64_t int_term;
- if ( !key.asInteger(int_term)) {
- return LookupResult();
- }
- auto comp = self._enumStore.make_comparator(int_term);
- auto find_result = dictionary.find_posting_list(comp, dictionary_snapshot);
- if (find_result.first.valid()) {
- auto pidx = find_result.second;
- if (pidx.valid()) {
- const auto& store = self.get_posting_store();
- auto minmax = store.getAggregated(pidx);
- return LookupResult(pidx, store.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first);
- }
- }
- return LookupResult();
-}
-
-template <typename B, typename M>
-void
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback)const
-{
- (void) dictionary_snapshot;
- callback(enum_idx);
-}
-
-template <typename B, typename M>
-void
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::create(vespalib::datastore::EntryRef posting_idx, std::vector<DocidWithWeightIterator> &dst) const
-{
- assert(posting_idx.valid());
- self.get_posting_store().beginFrozen(posting_idx, dst);
-}
-
-template <typename B, typename M>
-DocidWithWeightIterator
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::create(vespalib::datastore::EntryRef posting_idx) const
-{
- assert(posting_idx.valid());
- return self.get_posting_store().beginFrozen(posting_idx);
-}
-
-template <typename B, typename M>
-std::unique_ptr<queryeval::SearchIterator>
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::make_bitvector_iterator(vespalib::datastore::EntryRef posting_idx, uint32_t doc_id_limit, fef::TermFieldMatchData &match_data, bool strict) const
-{
- return self.get_posting_store().make_bitvector_iterator(posting_idx, doc_id_limit, match_data, strict);
-}
-
-template <typename B, typename M>
-bool
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::has_weight_iterator(vespalib::datastore::EntryRef posting_idx) const noexcept
-{
- return self.get_posting_store().has_btree(posting_idx);
-}
-
-template <typename B, typename M>
-bool
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::has_bitvector(vespalib::datastore::EntryRef posting_idx) const noexcept
-{
- return self.get_posting_store().has_bitvector(posting_idx);
-}
-
-template <typename B, typename M>
-int64_t
-MultiValueNumericPostingAttribute<B, M>::DocidWithWeightPostingStoreAdapter::get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept
-{
- return self._enumStore.get_value(enum_idx);
-}
-
-template <typename B, typename M>
const IDocidWithWeightPostingStore*
MultiValueNumericPostingAttribute<B, M>::as_docid_with_weight_posting_store() const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
index a8b93a93a34..63a445f0476 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
@@ -2,9 +2,10 @@
#pragma once
+#include "i_docid_with_weight_posting_store.h"
#include "multistringattribute.h"
#include "postinglistattribute.h"
-#include "i_docid_with_weight_posting_store.h"
+#include "string_direct_posting_store_adapter.h"
namespace search {
@@ -30,25 +31,6 @@ public:
using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
private:
- class DocidWithWeightPostingStoreAdapter final : public IDocidWithWeightPostingStore {
- public:
- const MultiValueStringPostingAttributeT &self;
- bool _is_filter;
- DocidWithWeightPostingStoreAdapter(const MultiValueStringPostingAttributeT &self_in)
- : self(self_in), _is_filter(self_in.getIsFilter()) {}
- vespalib::datastore::EntryRef get_dictionary_snapshot() const override;
- LookupResult lookup(const LookupKey & key, vespalib::datastore::EntryRef dictionary_snapshot) const override;
- void collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback) const override;
- void create(vespalib::datastore::EntryRef posting_idx, std::vector<DocidWithWeightIterator> &dst) const override;
- DocidWithWeightIterator create(vespalib::datastore::EntryRef posting_idx) const override;
- std::unique_ptr<queryeval::SearchIterator> make_bitvector_iterator(vespalib::datastore::EntryRef posting_idx, uint32_t doc_id_limit, fef::TermFieldMatchData &match_data, bool strict) const override;
- bool has_weight_iterator(vespalib::datastore::EntryRef posting_idx) const noexcept override;
- bool has_bitvector(vespalib::datastore::EntryRef posting_idx) const noexcept override;
- int64_t get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept override;
- bool has_always_weight_iterator() const noexcept override { return !_is_filter; }
- };
- DocidWithWeightPostingStoreAdapter _posting_store_adapter;
-
using LoadedVector = typename B::LoadedVector;
using PostingParent = PostingListAttributeSubBase<AttributeWeightPosting,
LoadedVector,
@@ -60,11 +42,18 @@ private:
using DocIndices = typename MultiValueStringAttributeT<B, T>::DocIndices;
using Posting = typename PostingParent::Posting;
using PostingMap = typename PostingParent::PostingMap;
+public:
+ using PostingStore = typename PostingParent::PostingStore;
+private:
using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
using SelfType = MultiValueStringPostingAttributeT<B, T>;
using WeightedIndex = typename MultiValueStringAttributeT<B, T>::WeightedIndex;
using generation_t = typename MultiValueStringAttributeT<B, T>::generation_t;
+ using DirectPostingStoreAdapterType = attribute::StringDirectPostingStoreAdapter<IDocidWithWeightPostingStore,
+ PostingStore, EnumStore>;
+ DirectPostingStoreAdapterType _posting_store_adapter;
+
using PostingParent::_posting_store;
using PostingParent::clearAllPostings;
using PostingParent::handle_load_posting_lists;
@@ -78,7 +67,6 @@ private:
public:
using PostingParent::get_posting_store;
using Dictionary = EnumPostingTree;
- using PostingStore = typename PostingParent::PostingStore;
MultiValueStringPostingAttributeT(const vespalib::string & name, const AttributeVector::Config & c);
MultiValueStringPostingAttributeT(const vespalib::string & name);
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
index 2909a6e0ea7..b6e9b69a81d 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
@@ -4,6 +4,7 @@
#include "multistringpostattribute.h"
#include "multi_string_enum_search_context.h"
+#include "string_direct_posting_store_adapter.hpp"
#include <vespa/searchcommon/attribute/config.h>
#include <vespa/searchlib/query/query_term_simple.h>
@@ -13,7 +14,7 @@ template <typename B, typename T>
MultiValueStringPostingAttributeT<B, T>::MultiValueStringPostingAttributeT(const vespalib::string & name, const AttributeVector::Config & c)
: MultiValueStringAttributeT<B, T>(name, c),
PostingParent(*this, this->getEnumStore()),
- _posting_store_adapter(*this)
+ _posting_store_adapter(this->get_posting_store(), this->_enumStore, this->getIsFilter())
{
}
@@ -103,90 +104,6 @@ MultiValueStringPostingAttributeT<B, T>::getSearch(QueryTermSimpleUP qTerm,
return std::make_unique<SC>(std::move(base_sc), params.useBitVector(), *this);
}
-
-template <typename B, typename T>
-vespalib::datastore::EntryRef
-MultiValueStringPostingAttributeT<B, T>::DocidWithWeightPostingStoreAdapter::get_dictionary_snapshot() const
-{
- const IEnumStoreDictionary& dictionary = self._enumStore.get_dictionary();
- return dictionary.get_frozen_root();
-}
-
-template <typename B, typename T>
-IDirectPostingStore::LookupResult
-MultiValueStringPostingAttributeT<B, T>::DocidWithWeightPostingStoreAdapter::lookup(const LookupKey & key, vespalib::datastore::EntryRef dictionary_snapshot) const
-{
- const IEnumStoreDictionary& dictionary = self._enumStore.get_dictionary();
- vespalib::stringref keyAsString = key.asString();
- // Assert the unfortunate assumption of the comparators.
- // Should be lifted once they take the length too.
- assert(keyAsString.data()[keyAsString.size()] == '\0');
- auto comp = self._enumStore.make_folded_comparator(keyAsString.data());
- auto find_result = dictionary.find_posting_list(comp, dictionary_snapshot);
- if (find_result.first.valid()) {
- auto pidx = find_result.second;
- if (pidx.valid()) {
- const auto& store = self.get_posting_store();
- auto minmax = store.getAggregated(pidx);
- return LookupResult(pidx, store.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first);
- }
- }
- return LookupResult();
-}
-
-template <typename B, typename T>
-void
-MultiValueStringPostingAttributeT<B, T>::DocidWithWeightPostingStoreAdapter::collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function<void(vespalib::datastore::EntryRef)>& callback) const
-{
- const IEnumStoreDictionary &dictionary = self._enumStore.get_dictionary();
- dictionary.collect_folded(enum_idx, dictionary_snapshot, callback);
-}
-
-template <typename B, typename T>
-void
-MultiValueStringPostingAttributeT<B, T>::DocidWithWeightPostingStoreAdapter::create(vespalib::datastore::EntryRef posting_idx, std::vector<DocidWithWeightIterator> &dst) const
-{
- assert(posting_idx.valid());
- self.get_posting_store().beginFrozen(posting_idx, dst);
-}
-
-template <typename B, typename M>
-DocidWithWeightIterator
-MultiValueStringPostingAttributeT<B, M>::DocidWithWeightPostingStoreAdapter::create(vespalib::datastore::EntryRef posting_idx) const
-{
- assert(posting_idx.valid());
- return self.get_posting_store().beginFrozen(posting_idx);
-}
-
-template <typename B, typename M>
-bool
-MultiValueStringPostingAttributeT<B, M>::DocidWithWeightPostingStoreAdapter::has_weight_iterator(vespalib::datastore::EntryRef posting_idx) const noexcept
-{
- return self.get_posting_store().has_btree(posting_idx);
-}
-
-template <typename B, typename M>
-bool
-MultiValueStringPostingAttributeT<B, M>::DocidWithWeightPostingStoreAdapter::has_bitvector(vespalib::datastore::EntryRef posting_idx) const noexcept
-{
- return self.get_posting_store().has_bitvector(posting_idx);
-}
-
-template <typename B, typename M>
-int64_t
-MultiValueStringPostingAttributeT<B, M>::DocidWithWeightPostingStoreAdapter::get_integer_value(vespalib::datastore::EntryRef) const noexcept
-{
- // This is not supported for string attributes and is never called.
- abort();
-}
-
-template <typename B, typename M>
-std::unique_ptr<queryeval::SearchIterator>
-MultiValueStringPostingAttributeT<B, M>::DocidWithWeightPostingStoreAdapter::make_bitvector_iterator(vespalib::datastore::EntryRef posting_idx, uint32_t doc_id_limit, fef::TermFieldMatchData &match_data, bool strict) const
-{
- return self.get_posting_store().make_bitvector_iterator(posting_idx, doc_id_limit, match_data, strict);
-}
-
template <typename B, typename T>
const IDocidWithWeightPostingStore*
MultiValueStringPostingAttributeT<B, T>::as_docid_with_weight_posting_store() const
diff --git a/searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.h b/searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.h
new file mode 100644
index 00000000000..16416df61e9
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.h
@@ -0,0 +1,31 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "direct_posting_store_adapter.h"
+#include <vespa/vespalib/datastore/entryref.h>
+
+namespace search::attribute {
+
+/**
+ * Adapter used to implement a specific IDirectPostingStore interface for
+ * a numeric attribute vector with underlying posting lists (fast-search).
+ */
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+class NumericDirectPostingStoreAdapter : public DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType> {
+public:
+ using LookupKey = typename ParentType::LookupKey;
+ using LookupResult = typename ParentType::LookupResult;
+
+ NumericDirectPostingStoreAdapter(const PostingStoreType& posting_store,
+ const EnumStoreType& enum_store,
+ bool attr_is_filter);
+
+ LookupResult lookup(const LookupKey& key,
+ vespalib::datastore::EntryRef dictionary_snapshot) const override;
+ void collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot,
+ const std::function<void(vespalib::datastore::EntryRef)>& callback) const override;
+ int64_t get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept override;
+};
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.hpp b/searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.hpp
new file mode 100644
index 00000000000..b5a1282d09c
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/numeric_direct_posting_store_adapter.hpp
@@ -0,0 +1,58 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "numeric_direct_posting_store_adapter.h"
+#include "direct_posting_store_adapter.hpp"
+
+namespace search::attribute {
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+NumericDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+NumericDirectPostingStoreAdapter(const PostingStoreType& posting_store,
+ const EnumStoreType& enum_store,
+ bool attr_is_filter)
+ : DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>(posting_store, enum_store, attr_is_filter)
+{
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+NumericDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::LookupResult
+NumericDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+lookup(const LookupKey& key, vespalib::datastore::EntryRef dictionary_snapshot) const
+{
+ int64_t int_term;
+ if (!key.asInteger(int_term)) {
+ return LookupResult();
+ }
+ auto comp = this->_enum_store.make_comparator(int_term);
+ auto find_result = this->_dict.find_posting_list(comp, dictionary_snapshot);
+ if (find_result.first.valid()) {
+ auto pidx = find_result.second;
+ if (pidx.valid()) {
+ auto minmax = this->_posting_store.getAggregated(pidx);
+ return LookupResult(pidx, this->_posting_store.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first);
+ }
+ }
+ return LookupResult();
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+void
+NumericDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot,
+ const std::function<void(vespalib::datastore::EntryRef)>& callback) const
+{
+ (void) dictionary_snapshot;
+ callback(enum_idx);
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+int64_t
+NumericDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept
+{
+ return this->_enum_store.get_value(enum_idx);
+}
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.h b/searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.h
new file mode 100644
index 00000000000..ca345c60d64
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.h
@@ -0,0 +1,31 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "direct_posting_store_adapter.h"
+#include <vespa/vespalib/datastore/entryref.h>
+
+namespace search::attribute {
+
+/**
+ * Adapter used to implement a specific IDirectPostingStore interface for
+ * a string attribute vector with underlying posting lists (fast-search).
+ */
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+class StringDirectPostingStoreAdapter : public DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType> {
+public:
+ using LookupKey = typename ParentType::LookupKey;
+ using LookupResult = typename ParentType::LookupResult;
+
+ StringDirectPostingStoreAdapter(const PostingStoreType& posting_store,
+ const EnumStoreType& enum_store,
+ bool attr_is_filter);
+
+ LookupResult lookup(const LookupKey& key,
+ vespalib::datastore::EntryRef dictionary_snapshot) const override;
+ void collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot,
+ const std::function<void(vespalib::datastore::EntryRef)>& callback) const override;
+ int64_t get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept override;
+};
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.hpp b/searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.hpp
new file mode 100644
index 00000000000..9f29fe0ef46
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/string_direct_posting_store_adapter.hpp
@@ -0,0 +1,58 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "string_direct_posting_store_adapter.h"
+#include "direct_posting_store_adapter.hpp"
+
+namespace search::attribute {
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+StringDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+StringDirectPostingStoreAdapter(const PostingStoreType& posting_store,
+ const EnumStoreType& enum_store,
+ bool attr_is_filter)
+ : DirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>(posting_store, enum_store, attr_is_filter)
+{
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+StringDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::LookupResult
+StringDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+lookup(const LookupKey& key, vespalib::datastore::EntryRef dictionary_snapshot) const
+{
+ vespalib::stringref keyAsString = key.asString();
+ // Assert the unfortunate assumption of the comparators.
+ // Should be lifted once they take the length too.
+ assert(keyAsString.data()[keyAsString.size()] == '\0');
+ auto comp = this->_enum_store.make_folded_comparator(keyAsString.data());
+ auto find_result = this->_dict.find_posting_list(comp, dictionary_snapshot);
+ if (find_result.first.valid()) {
+ auto pidx = find_result.second;
+ if (pidx.valid()) {
+ auto minmax = this->_posting_store.getAggregated(pidx);
+ return LookupResult(pidx, this->_posting_store.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first);
+ }
+ }
+ return LookupResult();
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+void
+StringDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot,
+ const std::function<void(vespalib::datastore::EntryRef)>& callback) const
+{
+ this->_dict.collect_folded(enum_idx, dictionary_snapshot, callback);
+}
+
+template <typename ParentType, typename PostingStoreType, typename EnumStoreType>
+int64_t
+StringDirectPostingStoreAdapter<ParentType, PostingStoreType, EnumStoreType>::
+get_integer_value(vespalib::datastore::EntryRef) const noexcept
+{
+ // This is not supported for string attributes and is never called.
+ abort();
+}
+
+}