blob: b5444db6d013fea3fa80812fddce89a46d36acef (
plain)
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
|
#include "search/features_filter.hpp"
#include "search/cbv.hpp"
namespace search
{
// FeaturesFilter ----------------------------------------------------------------------------------
FeaturesFilter::FeaturesFilter(CBV const & filter, uint64_t threshold)
: m_filter(filter), m_threshold(threshold)
{
}
bool FeaturesFilter::NeedToFilter(CBV const & cbv) const
{
if (cbv.IsFull())
return true;
return cbv.PopCount() > m_threshold;
}
// LocalityFilter ----------------------------------------------------------------------------------
LocalityFilter::LocalityFilter(CBV const & filter)
: FeaturesFilter(filter, 0 /* threshold */)
{
}
CBV LocalityFilter::Filter(CBV const & cbv) const
{
return m_filter.Intersect(cbv);
}
// ViewportFilter ----------------------------------------------------------------------------------
ViewportFilter::ViewportFilter(CBV const & filter, uint64_t threshold)
: FeaturesFilter(filter, threshold)
{
}
CBV ViewportFilter::Filter(CBV const & cbv) const
{
auto result = m_filter.Intersect(cbv);
if (!result.IsEmpty())
return result;
return cbv.Take(m_threshold);
}
} // namespace search
|