Debian Codegraph @

lib/grn_expr.h

raw symbols SCIP
1 /*
2 Copyright (C) 2013-2018 Brazil
3 Copyright (C) 2018-2024 Sutou Kouhei <[email protected]>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #pragma once
21
22 #include "grn_db.h"
23 #include "grn_expr_code.h"
24 #include "grn_expr_executor.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #define GRN_EXPR_CONST_BLK_SIZE GRN_STACK_SIZE
31
32 struct _grn_expr {
33 grn_db_obj obj;
34 grn_obj name_buf;
35 grn_expr_var *vars;
36 uint32_t nvars;
37 /* -- compatible with grn_proc -- */
38
39 uint16_t cacheable;
40 uint16_t taintable;
41 grn_obj **const_blks;
42 grn_obj *values;
43 grn_expr_code *codes;
44 uint32_t nconsts;
45 ptrdiff_t values_curr;
46 ptrdiff_t values_tail;
47 uint32_t values_size;
48 uint32_t codes_curr;
49 uint32_t codes_size;
50
51 grn_obj objs;
52 grn_obj dfi;
53 grn_expr_code *code0;
54
55 struct {
56 grn_expr_code *codes;
57 uint32_t codes_curr;
58 grn_expr_executor executor;
59 } cache;
60
61 grn_obj query_log_tag_prefix;
62 grn_obj *parent;
63 grn_obj *condition;
64 };
65
66 void *
67 grn_expr_parser_open(grn_ctx *ctx);
68 grn_rc
69 grn_expr_parser_close(grn_ctx *ctx, void *parser);
70
71 #define SCAN_ACCESSOR (0x01)
72 #define SCAN_PUSH (0x02)
73 #define SCAN_POP (0x04)
74 #define SCAN_PRE_CONST (0x08)
75
76 typedef enum {
77 SCAN_START = 0,
78 SCAN_VAR,
79 SCAN_COL1,
80 SCAN_COL2,
81 SCAN_CONST
82 } scan_stat;
83
84 typedef struct _grn_scan_info scan_info;
85 typedef bool (*grn_scan_info_each_arg_callback)(grn_ctx *ctx,
86 grn_obj *obj,
87 void *user_data);
88
89 void
90 grn_expr_init_from_env(void);
91
92 grn_obj *
93 grn_expr_get_query_options(grn_ctx *ctx, grn_obj *expr);
94 grn_rc
95 grn_expr_set_query_options(grn_ctx *ctx, grn_obj *expr, grn_obj *query_options);
96
97 scan_info **
98 grn_scan_info_build(
99 grn_ctx *ctx, grn_obj *expr, int *n, grn_operator op, bool record_exist);
100
101 scan_info *
102 grn_scan_info_open(grn_ctx *ctx, int start);
103 void
104 grn_scan_info_close(grn_ctx *ctx, scan_info *si);
105 void
106 grn_scan_info_put_index(grn_ctx *ctx,
107 scan_info *si,
108 grn_obj *index,
109 uint32_t sid,
110 int32_t start_position,
111 float weight,
112 grn_obj *scorer,
113 grn_obj *scorer_args_expr,
114 uint32_t scorer_args_expr_offset);
115 scan_info **
116 grn_scan_info_put_logical_op(grn_ctx *ctx,
117 scan_info **sis,
118 int *ip,
119 grn_operator op,
120 int start,
121 float weight_factor);
122 int
123 grn_scan_info_get_flags(scan_info *si);
124 void
125 grn_scan_info_set_flags(scan_info *si, int flags);
126 grn_operator
127 grn_scan_info_get_logical_op(scan_info *si);
128 void
129 grn_scan_info_set_logical_op(scan_info *si, grn_operator logical_op);
130 grn_operator
131 grn_scan_info_get_op(scan_info *si);
132 void
133 grn_scan_info_set_weight_factor(scan_info *si, float factor);
134 float
135 grn_scan_info_get_weight_factor(scan_info *si);
136 void
137 grn_scan_info_set_op(scan_info *si, grn_operator op);
138 void
139 grn_scan_info_set_end(scan_info *si, uint32_t end);
140 void
141 grn_scan_info_set_query(scan_info *si, grn_obj *query);
142 int
143 grn_scan_info_get_max_interval(scan_info *si);
144 void
145 grn_scan_info_set_max_interval(scan_info *si, int max_interval);
146 int
147 grn_scan_info_get_additional_last_interval(scan_info *si);
148 void
149 grn_scan_info_set_additional_last_interval(scan_info *si,
150 int additional_last_interval);
151 grn_obj *
152 grn_scan_info_get_max_element_intervals(scan_info *si);
153 void
154 grn_scan_info_set_max_element_intervals(grn_ctx *ctx,
155 scan_info *si,
156 grn_obj *max_element_intervals);
157 int
158 grn_scan_info_get_min_interval(scan_info *si);
159 void
160 grn_scan_info_set_min_interval(scan_info *si, int min_interval);
161 int
162 grn_scan_info_get_similarity_threshold(scan_info *si);
163 void
164 grn_scan_info_set_similarity_threshold(scan_info *si, int similarity_threshold);
165 int
166 grn_scan_info_get_quorum_threshold(scan_info *si);
167 void
168 grn_scan_info_set_quorum_threshold(scan_info *si, int quorum_threshold);
169 bool
170 grn_scan_info_push_arg(grn_ctx *ctx, scan_info *si, grn_obj *arg);
171 grn_obj *
172 grn_scan_info_get_arg(grn_ctx *ctx, scan_info *si, int i);
173
174 float
175 grn_expr_code_get_weight(grn_ctx *ctx, grn_expr_code *ec, uint32_t *offset);
176 grn_rc
177 grn_expr_code_inspect_indented(grn_ctx *ctx,
178 grn_obj *buffer,
179 grn_expr_code *code,
180 const char *indent);
181 void
182 grn_p_expr_code(grn_ctx *ctx, grn_expr_code *code);
183
184 grn_obj *
185 grn_expr_alloc_const(grn_ctx *ctx, grn_obj *expr);
186
187 grn_rc
188 grn_ctx_expand_stack(grn_ctx *ctx);
189
190 bool
191 grn_expr_is_simple_function_call(grn_ctx *ctx, grn_obj *expr);
192 grn_obj *
193 grn_expr_simple_function_call_get_function(grn_ctx *ctx, grn_obj *expr);
194 grn_rc
195 grn_expr_simple_function_call_get_arguments(grn_ctx *ctx,
196 grn_obj *expr,
197 grn_obj *arguments);
198
199 bool
200 grn_expr_is_module_list(grn_ctx *ctx, grn_obj *expr);
201 unsigned int
202 grn_expr_module_list_get_n_modules(grn_ctx *ctx, grn_obj *expr);
203 grn_obj *
204 grn_expr_module_list_get_function(grn_ctx *ctx, grn_obj *expr, unsigned int i);
205 grn_rc
206 grn_expr_module_list_get_arguments(grn_ctx *ctx,
207 grn_obj *expr,
208 unsigned int i,
209 grn_obj *arguments);
210
211 grn_rc
212 grn_expr_match_columns_split(grn_ctx *ctx,
213 grn_obj *expr,
214 grn_obj *splitted_match_columns);
215
216 grn_obj *
217 grn_expr_slice(grn_ctx *ctx,
218 grn_obj *expr,
219 uint32_t code_start_offset,
220 uint32_t code_end_offset);
221 grn_rc
222 grn_expr_to_script_syntax(grn_ctx *ctx, grn_obj *expr, grn_obj *buffer);
223 void
224 grn_expr_get_range_info(grn_ctx *ctx,
225 grn_obj *expr,
226 grn_id *range_id,
227 grn_obj_flags *range_flags);
228 uint32_t
229 grn_expr_get_n_logical_ops(grn_ctx *ctx, grn_obj *expr);
230
231 typedef enum {
232 GRN_EXPR_V1_FORMAT_TYPE_OUTPUT_COLUMNS,
233 GRN_EXPR_V1_FORMAT_TYPE_SORT_KEYS,
234 GRN_EXPR_V1_FORMAT_TYPE_GROUP_KEYS,
235 } grn_expr_v1_format_type;
236
237 bool
238 grn_expr_is_v1_format(grn_ctx *ctx,
239 const char *raw_text,
240 ssize_t raw_text_len,
241 grn_expr_v1_format_type type);
242
243 #ifdef __cplusplus
244 }
245 #endif