1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// 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()) {
if constexpr (PostingStoreType::AggrCalcType::hasAggregated()) {
auto minmax = this->_posting_store.getAggregated(pidx);
return LookupResult(pidx, this->_posting_store.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first);
} else {
return LookupResult(pidx, this->_posting_store.frozenSize(pidx), 1, 1, 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);
}
}
|