blob: 1a5d3d3dacd0cb3d804321943af03c2320fbeb0a (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "global_filter.h"
namespace search::queryeval {
namespace {
struct Inactive : GlobalFilter {
bool is_active() const override { return false; }
uint32_t size() const override { abort(); }
uint32_t count() const override { abort(); }
bool check(uint32_t) const override { abort(); }
};
struct BitVectorFilter : public GlobalFilter {
std::unique_ptr<BitVector> vector;
BitVectorFilter(std::unique_ptr<BitVector> vector_in)
: vector(std::move(vector_in)) {}
bool is_active() const override { return true; }
uint32_t size() const override { return vector->size(); }
uint32_t count() const override { return vector->countTrueBits(); }
bool check(uint32_t docid) const override { return vector->testBit(docid); }
};
}
GlobalFilter::GlobalFilter() = default;
GlobalFilter::~GlobalFilter() = default;
std::shared_ptr<GlobalFilter>
GlobalFilter::create() {
return std::make_shared<Inactive>();
}
std::shared_ptr<GlobalFilter>
GlobalFilter::create(std::unique_ptr<BitVector> vector) {
return std::make_shared<BitVectorFilter>(std::move(vector));
}
}
|