| 1 | /* |
| 2 | Copyright (C) 2009-2018 Brazil |
| 3 | Copyright (C) 2019-2026 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.h" |
| 23 | |
| 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
| 26 | #endif |
| 27 | |
| 28 | #define GRN_SELECT_DEFAULT_LIMIT 10 |
| 29 | #define GRN_SELECT_DEFAULT_OUTPUT_COLUMNS_FOR_NO_KEY "_id, *" |
| 30 | #define GRN_SELECT_DEFAULT_OUTPUT_COLUMNS_FOR_WITH_KEY "_id, _key, *" |
| 31 | |
| 32 | void |
| 33 | grn_proc_init_from_env(void); |
| 34 | void |
| 35 | grn_proc_query_init_from_env(void); |
| 36 | |
| 37 | GRN_VAR const char *grn_document_root; |
| 38 | void |
| 39 | grn_db_init_builtin_commands(grn_ctx *ctx); |
| 40 | |
| 41 | void |
| 42 | grn_proc_init_cast_loose(grn_ctx *ctx); |
| 43 | void |
| 44 | grn_proc_init_clearlock(grn_ctx *ctx); |
| 45 | void |
| 46 | grn_proc_init_column_copy(grn_ctx *ctx); |
| 47 | void |
| 48 | grn_proc_init_column_create(grn_ctx *ctx); |
| 49 | void |
| 50 | grn_proc_init_column_create_similar(grn_ctx *ctx); |
| 51 | void |
| 52 | grn_proc_init_column_list(grn_ctx *ctx); |
| 53 | void |
| 54 | grn_proc_init_column_remove(grn_ctx *ctx); |
| 55 | void |
| 56 | grn_proc_init_column_rename(grn_ctx *ctx); |
| 57 | void |
| 58 | grn_proc_init_command_list(grn_ctx *ctx); |
| 59 | void |
| 60 | grn_proc_init_config_get(grn_ctx *ctx); |
| 61 | void |
| 62 | grn_proc_init_config_set(grn_ctx *ctx); |
| 63 | void |
| 64 | grn_proc_init_config_delete(grn_ctx *ctx); |
| 65 | void |
| 66 | grn_proc_init_define_selector(grn_ctx *ctx); |
| 67 | void |
| 68 | grn_proc_init_distance_cosine(grn_ctx *ctx); |
| 69 | void |
| 70 | grn_proc_init_distance_inner_product(grn_ctx *ctx); |
| 71 | void |
| 72 | grn_proc_init_distance_l1_norm(grn_ctx *ctx); |
| 73 | void |
| 74 | grn_proc_init_distance_l2_norm_squared(grn_ctx *ctx); |
| 75 | void |
| 76 | grn_proc_init_dump(grn_ctx *ctx); |
| 77 | void |
| 78 | grn_proc_init_edit_distance(grn_ctx *ctx); |
| 79 | void |
| 80 | grn_proc_init_escalate(grn_ctx *ctx); |
| 81 | void |
| 82 | grn_proc_init_extract(grn_ctx *ctx); |
| 83 | void |
| 84 | grn_proc_init_fuzzy_search(grn_ctx *ctx); |
| 85 | void |
| 86 | grn_proc_init_highlight(grn_ctx *ctx); |
| 87 | void |
| 88 | grn_proc_init_highlight_full(grn_ctx *ctx); |
| 89 | void |
| 90 | grn_proc_init_highlight_html(grn_ctx *ctx); |
| 91 | void |
| 92 | grn_proc_init_in_records(grn_ctx *ctx); |
| 93 | void |
| 94 | grn_proc_init_index_column_diff(grn_ctx *ctx); |
| 95 | void |
| 96 | grn_proc_init_json_extract(grn_ctx *ctx); |
| 97 | void |
| 98 | grn_proc_init_lock_acquire(grn_ctx *ctx); |
| 99 | void |
| 100 | grn_proc_init_lock_clear(grn_ctx *ctx); |
| 101 | void |
| 102 | grn_proc_init_lock_release(grn_ctx *ctx); |
| 103 | void |
| 104 | grn_proc_init_log_level(grn_ctx *ctx); |
| 105 | void |
| 106 | grn_proc_init_log_put(grn_ctx *ctx); |
| 107 | void |
| 108 | grn_proc_init_log_reopen(grn_ctx *ctx); |
| 109 | void |
| 110 | grn_proc_init_normalize(grn_ctx *ctx); |
| 111 | void |
| 112 | grn_proc_init_object_exist(grn_ctx *ctx); |
| 113 | void |
| 114 | grn_proc_init_object_inspect(grn_ctx *ctx); |
| 115 | void |
| 116 | grn_proc_init_object_list(grn_ctx *ctx); |
| 117 | void |
| 118 | grn_proc_init_object_remove(grn_ctx *ctx); |
| 119 | void |
| 120 | grn_proc_init_object_set_visibility(grn_ctx *ctx); |
| 121 | void |
| 122 | grn_proc_init_object_warm(grn_ctx *ctx); |
| 123 | void |
| 124 | grn_proc_init_query(grn_ctx *ctx); |
| 125 | void |
| 126 | grn_proc_init_query_parallel_or(grn_ctx *ctx); |
| 127 | void |
| 128 | grn_proc_init_query_expand(grn_ctx *ctx); |
| 129 | void |
| 130 | grn_proc_init_query_log_flags_get(grn_ctx *ctx); |
| 131 | void |
| 132 | grn_proc_init_query_log_flags_set(grn_ctx *ctx); |
| 133 | void |
| 134 | grn_proc_init_query_log_flags_add(grn_ctx *ctx); |
| 135 | void |
| 136 | grn_proc_init_query_log_flags_remove(grn_ctx *ctx); |
| 137 | void |
| 138 | grn_proc_init_reference_acquire(grn_ctx *ctx); |
| 139 | void |
| 140 | grn_proc_init_reference_release(grn_ctx *ctx); |
| 141 | void |
| 142 | grn_proc_init_schema(grn_ctx *ctx); |
| 143 | void |
| 144 | grn_proc_init_select(grn_ctx *ctx); |
| 145 | void |
| 146 | grn_proc_init_sleep(grn_ctx *ctx); |
| 147 | void |
| 148 | grn_proc_init_snippet(grn_ctx *ctx); |
| 149 | void |
| 150 | grn_proc_init_snippet_html(grn_ctx *ctx); |
| 151 | void |
| 152 | grn_proc_init_table_copy(grn_ctx *ctx); |
| 153 | void |
| 154 | grn_proc_init_table_create(grn_ctx *ctx); |
| 155 | void |
| 156 | grn_proc_init_table_create_similar(grn_ctx *ctx); |
| 157 | void |
| 158 | grn_proc_init_table_list(grn_ctx *ctx); |
| 159 | void |
| 160 | grn_proc_init_table_remove(grn_ctx *ctx); |
| 161 | void |
| 162 | grn_proc_init_table_rename(grn_ctx *ctx); |
| 163 | void |
| 164 | grn_proc_init_table_tokenize(grn_ctx *ctx); |
| 165 | void |
| 166 | grn_proc_init_thread_dump(grn_ctx *ctx); |
| 167 | void |
| 168 | grn_proc_init_thread_limit(grn_ctx *ctx); |
| 169 | void |
| 170 | grn_proc_init_tokenize(grn_ctx *ctx); |
| 171 | |
| 172 | bool |
| 173 | grn_proc_option_value_bool(grn_ctx *ctx, grn_obj *option, bool default_value); |
| 174 | int32_t |
| 175 | grn_proc_option_value_int32(grn_ctx *ctx, |
| 176 | grn_obj *option, |
| 177 | int32_t default_value); |
| 178 | uint32_t |
| 179 | grn_proc_option_value_uint32(grn_ctx *ctx, |
| 180 | grn_obj *option, |
| 181 | uint32_t default_value); |
| 182 | float |
| 183 | grn_proc_option_value_float(grn_ctx *ctx, grn_obj *option, float default_value); |
| 184 | double |
| 185 | grn_proc_option_value_double(grn_ctx *ctx, |
| 186 | grn_obj *option, |
| 187 | double default_value); |
| 188 | const char * |
| 189 | grn_proc_option_value_string(grn_ctx *ctx, grn_obj *option, size_t *size); |
| 190 | grn_content_type |
| 191 | grn_proc_option_value_content_type(grn_ctx *ctx, |
| 192 | grn_obj *option, |
| 193 | grn_content_type default_value); |
| 194 | grn_log_level |
| 195 | grn_proc_option_value_log_level(grn_ctx *ctx, |
| 196 | grn_obj *option, |
| 197 | grn_log_level default_value); |
| 198 | bool |
| 199 | grn_proc_get_value_bool(grn_ctx *ctx, |
| 200 | grn_obj *value, |
| 201 | bool default_value, |
| 202 | const char *tag); |
| 203 | int32_t |
| 204 | grn_proc_get_value_int32(grn_ctx *ctx, |
| 205 | grn_obj *value, |
| 206 | int32_t default_value_raw, |
| 207 | const char *tag); |
| 208 | uint32_t |
| 209 | grn_proc_get_value_uint32(grn_ctx *ctx, |
| 210 | grn_obj *value, |
| 211 | uint32_t default_value_raw, |
| 212 | const char *tag); |
| 213 | int64_t |
| 214 | grn_proc_get_value_int64(grn_ctx *ctx, |
| 215 | grn_obj *value, |
| 216 | int64_t default_value_raw, |
| 217 | const char *tag); |
| 218 | grn_operator |
| 219 | grn_proc_get_value_mode(grn_ctx *ctx, |
| 220 | grn_obj *value, |
| 221 | grn_operator default_mode, |
| 222 | const char *tag); |
| 223 | grn_operator |
| 224 | grn_proc_get_value_operator(grn_ctx *ctx, |
| 225 | grn_obj *value, |
| 226 | grn_operator default_operator, |
| 227 | const char *tag); |
| 228 | grn_tokenize_mode |
| 229 | grn_proc_get_value_tokenize_mode(grn_ctx *ctx, |
| 230 | grn_obj *value, |
| 231 | grn_tokenize_mode default_mode, |
| 232 | const char *tag); |
| 233 | uint32_t |
| 234 | grn_proc_get_value_token_cursor_flags(grn_ctx *ctx, |
| 235 | grn_obj *value, |
| 236 | uint32_t default_flags, |
| 237 | const char *tag); |
| 238 | double |
| 239 | grn_proc_get_value_double(grn_ctx *ctx, |
| 240 | grn_obj *value, |
| 241 | double default_value_raw, |
| 242 | const char *tag); |
| 243 | grn_obj * |
| 244 | grn_proc_get_value_object(grn_ctx *ctx, grn_obj *value, const char *tag); |
| 245 | grn_obj * |
| 246 | grn_proc_get_value_column(grn_ctx *ctx, |
| 247 | grn_obj *value, |
| 248 | grn_obj *table, |
| 249 | const char *tag); |
| 250 | grn_raw_string |
| 251 | grn_proc_get_value_raw_string(grn_ctx *ctx, |
| 252 | grn_obj *value, |
| 253 | grn_raw_string *default_value, |
| 254 | const char *tag); |
| 255 | |
| 256 | void |
| 257 | grn_proc_output_object_name(grn_ctx *ctx, grn_obj *obj); |
| 258 | void |
| 259 | grn_proc_output_object_id_name(grn_ctx *ctx, grn_id id); |
| 260 | |
| 261 | bool |
| 262 | grn_proc_table_set_token_filters(grn_ctx *ctx, |
| 263 | grn_obj *table, |
| 264 | grn_raw_string *token_filters_raw); |
| 265 | bool |
| 266 | grn_proc_table_set_extractors(grn_ctx *ctx, |
| 267 | grn_obj *table, |
| 268 | grn_raw_string *extractors_raw); |
| 269 | |
| 270 | grn_column_flags |
| 271 | grn_proc_column_parse_flags(grn_ctx *ctx, |
| 272 | const char *error_message_tag, |
| 273 | const char *text, |
| 274 | const char *end); |
| 275 | |
| 276 | bool |
| 277 | grn_proc_select_output_columns_open(grn_ctx *ctx, |
| 278 | grn_obj_format *format, |
| 279 | grn_obj *result_set, |
| 280 | int n_hits, |
| 281 | int offset, |
| 282 | int limit, |
| 283 | const char *columns, |
| 284 | unsigned int columns_len, |
| 285 | grn_obj *condition, |
| 286 | uint32_t n_additional_elements); |
| 287 | bool |
| 288 | grn_proc_select_output_columns_close(grn_ctx *ctx, |
| 289 | grn_obj_format *format, |
| 290 | grn_obj *result_set); |
| 291 | bool |
| 292 | grn_proc_select_output_columns(grn_ctx *ctx, |
| 293 | grn_obj *res, |
| 294 | int n_hits, |
| 295 | int offset, |
| 296 | int limit, |
| 297 | const char *columns, |
| 298 | unsigned int columns_len, |
| 299 | grn_obj *condition); |
| 300 | |
| 301 | grn_rc |
| 302 | grn_proc_syntax_expand_query(grn_ctx *ctx, |
| 303 | const char *query, |
| 304 | unsigned int query_len, |
| 305 | grn_expr_flags flags, |
| 306 | grn_obj *query_expander, |
| 307 | const char *term_column_name, |
| 308 | unsigned int term_column_name_len, |
| 309 | const char *expanded_term_column_name, |
| 310 | unsigned int expanded_term_column_name_len, |
| 311 | grn_obj *expanded_query, |
| 312 | const char *error_message_tag); |
| 313 | |
| 314 | grn_expr_flags |
| 315 | grn_proc_expr_query_flags_parse(grn_ctx *ctx, |
| 316 | grn_obj *query_flags, |
| 317 | const char *error_message_tag); |
| 318 | |
| 319 | grn_obj * |
| 320 | grn_proc_lexicon_open(grn_ctx *ctx, |
| 321 | grn_raw_string *tokenizer_raw, |
| 322 | grn_raw_string *normalizer_raw, |
| 323 | grn_raw_string *token_filters_raw, |
| 324 | grn_raw_string *extractors_raw, |
| 325 | const char *context_tag); |
| 326 | |
| 327 | bool |
| 328 | grn_proc_text_include_special_character(grn_ctx *ctx, |
| 329 | const char *text, |
| 330 | size_t size); |
| 331 | |
| 332 | typedef struct { |
| 333 | grn_obj *found; |
| 334 | grn_obj *table; |
| 335 | grn_obj *records; |
| 336 | } grn_proc_selector_to_function_data; |
| 337 | |
| 338 | bool |
| 339 | grn_proc_selector_to_function_data_init( |
| 340 | grn_ctx *ctx, |
| 341 | grn_proc_selector_to_function_data *data, |
| 342 | grn_user_data *user_data); |
| 343 | void |
| 344 | grn_proc_selector_to_function_data_selected( |
| 345 | grn_ctx *ctx, grn_proc_selector_to_function_data *data); |
| 346 | void |
| 347 | grn_proc_selector_to_function_data_fin( |
| 348 | grn_ctx *ctx, grn_proc_selector_to_function_data *data); |
| 349 | |
| 350 | #ifdef __cplusplus |
| 351 | } |
| 352 | #endif |