aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/enumhintsearchcontext.cpp
blob: 7cad3f7d1d38e36a13e5e1cdc6e4d732702eb981 (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
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "enumhintsearchcontext.h"
#include <vespa/searchlib/queryeval/emptysearch.h>

namespace search {

using queryeval::SearchIterator;

namespace attribute {

using btree::BTreeNode;
using fef::TermFieldMatchData;

EnumHintSearchContext::
EnumHintSearchContext(const EnumStoreDictBase &dictionary,
                      uint32_t docIdLimit,
                      uint64_t numValues)
    : _dictionary(dictionary),
      _frozenRootRef(dictionary.getFrozenRootRef()),
      _uniqueValues(0u),
      _docIdLimit(docIdLimit),
      _numValues(numValues)
{
}


EnumHintSearchContext::~EnumHintSearchContext()
{
}


void
EnumHintSearchContext::lookupTerm(const EnumStoreComparator &comp)
{
    _uniqueValues = _dictionary.lookupFrozenTerm(_frozenRootRef, comp);
}


void
EnumHintSearchContext::lookupRange(const EnumStoreComparator &low,
                                   const EnumStoreComparator &high)
{
    _uniqueValues = _dictionary.lookupFrozenRange(_frozenRootRef, low, high);
}

void
EnumHintSearchContext::fetchPostings(bool strict)
{
    (void) strict;
}

SearchIterator::UP
EnumHintSearchContext::createPostingIterator(TermFieldMatchData *matchData,
                                             bool strict)
{
    (void) matchData;
    (void) strict;

    return (_uniqueValues == 0u)
        ? SearchIterator::UP(new queryeval::EmptySearch())
        : SearchIterator::UP();
}


unsigned int
EnumHintSearchContext::approximateHits() const
{
    return (_uniqueValues == 0u)
        ? 0u
        : std::max(uint64_t(_docIdLimit), _numValues);
}

} // namespace attribute

} // namespace search