blob: 389c346a61b0db01210612b8c059ecdbbb96b8d1 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "predicate_interval.h"
#include <vespa/vespalib/data/memory.h>
#include <climits>
#include <vector>
#include <unordered_map>
namespace vespalib::slime { struct Inspector; }
namespace search::predicate {
struct RangeFeature {
vespalib::Memory label;
int64_t from;
int64_t to;
};
constexpr uint32_t MIN_INTERVAL = 0x0001;
constexpr uint32_t MAX_INTERVAL = 0xffff;
struct PredicateTreeAnnotations {
explicit PredicateTreeAnnotations(uint32_t mf=0, uint16_t ir=MAX_INTERVAL);
~PredicateTreeAnnotations();
uint32_t min_feature;
uint16_t interval_range;
std::unordered_map<uint64_t, std::vector<Interval>> interval_map;
std::unordered_map<uint64_t, std::vector<IntervalWithBounds>> bounds_map;
std::vector<uint64_t> features;
std::vector<RangeFeature> range_features;
};
/**
* Annotates a predicate document, represented by a slime object, with
* intervals used for matching with the interval algorithm.
*/
struct PredicateTreeAnnotator {
static void annotate(const vespalib::slime::Inspector &in,
PredicateTreeAnnotations &result,
int64_t lower_bound=LLONG_MIN,
int64_t upper_bound=LLONG_MAX);
};
} // namespace predicate
|