1 | /* |
2 | * predexp.h |
3 | * |
4 | * Copyright (C) 2016 Aerospike, Inc. |
5 | * |
6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
7 | * license agreements. |
8 | * |
9 | * This program is free software: you can redistribute it and/or modify it under |
10 | * the terms of the GNU Affero General Public License as published by the Free |
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
12 | * later version. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
17 | * details. |
18 | * |
19 | * You should have received a copy of the GNU Affero General Public License |
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
21 | */ |
22 | |
23 | /* |
24 | * predicate expression declarations |
25 | * |
26 | */ |
27 | |
28 | #pragma once |
29 | |
30 | #include "base/datamodel.h" |
31 | #include "base/index.h" |
32 | |
33 | // A "compiled" predicate expression |
34 | typedef struct predexp_eval_base_s predexp_eval_t; |
35 | |
36 | // A named variable |
37 | typedef struct predexp_var_s as_predexp_var_t; |
38 | |
39 | // Arguments to predicate expressions |
40 | typedef struct predexp_args_s { |
41 | as_namespace* ns; // always present |
42 | as_record* md; // always present |
43 | as_predexp_var_t* vl; // always present |
44 | as_storage_rd* rd; // NULL during metadata phase |
45 | } predexp_args_t; |
46 | |
47 | typedef enum { |
48 | PREDEXP_FALSE = 0, // matching nodes only |
49 | PREDEXP_TRUE = 1, // matching nodes only |
50 | PREDEXP_UNKNOWN = 2, // matching nodes only |
51 | |
52 | // Private - never returned by pulbic API. |
53 | PREDEXP_VALUE = 3, // value nodes only |
54 | PREDEXP_NOVALUE = 4 // value nodes only |
55 | } predexp_retval_t; |
56 | |
57 | predexp_eval_t* predexp_build(as_msg_field* pfp); |
58 | |
59 | // Called with NULL rd |
60 | predexp_retval_t predexp_matches_metadata(predexp_eval_t* eval, predexp_args_t* argsp); |
61 | |
62 | // Called with both ndx and rd. |
63 | bool predexp_matches_record(predexp_eval_t* eval, predexp_args_t* argsp); |
64 | |
65 | void predexp_destroy(predexp_eval_t* eval); |
66 | |