blob: 62a845e79c4ef39b5887d702de37255f26fcfd02 (
plain) (
blame)
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
63
64
65
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "enumhintsearchcontext.h"
#include "i_enum_store_dictionary.h"
#include <vespa/searchlib/queryeval/emptysearch.h>
#include <vespa/vespalib/datastore/i_unique_store_dictionary_read_snapshot.h>
namespace search::attribute {
using queryeval::SearchIterator;
using fef::TermFieldMatchData;
EnumHintSearchContext::
EnumHintSearchContext(const IEnumStoreDictionary &dictionary,
uint32_t docIdLimit,
uint64_t numValues)
: _dict_snapshot(dictionary.get_read_snapshot()),
_uniqueValues(0u),
_docIdLimit(docIdLimit),
_numValues(numValues)
{
}
EnumHintSearchContext::~EnumHintSearchContext() = default;
void
EnumHintSearchContext::lookupTerm(const vespalib::datastore::EntryComparator &comp)
{
_uniqueValues = _dict_snapshot->count(comp);
}
void
EnumHintSearchContext::lookupRange(const vespalib::datastore::EntryComparator &low,
const vespalib::datastore::EntryComparator &high)
{
_uniqueValues = _dict_snapshot->count_in_range(low, high);
}
void
EnumHintSearchContext::fetchPostings(const queryeval::ExecuteInfo &, bool)
{
}
SearchIterator::UP
EnumHintSearchContext::createPostingIterator(TermFieldMatchData *, bool )
{
return (_uniqueValues == 0u)
? std::make_unique<queryeval::EmptySearch>()
: SearchIterator::UP();
}
HitEstimate
EnumHintSearchContext::calc_hit_estimate() const
{
return (_uniqueValues == 0u)
? HitEstimate(0u)
: HitEstimate::unknown(std::max(uint64_t(_docIdLimit), _numValues));
}
}
|