| 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_scanner.h" |
| 24 | |
| 25 | #ifdef __cplusplus |
| 26 | extern "C" { |
| 27 | #endif |
| 28 | |
| 29 | #define GRN_TABLE_SELECTOR_FUZZY_MAX_EXPANSIONS_DEFAULT 10 |
| 30 | |
| 31 | void |
| 32 | grn_table_selector_init_from_env(void); |
| 33 | |
| 34 | typedef struct { |
| 35 | grn_scanner *scanner; |
| 36 | grn_obj *expr; |
| 37 | grn_obj *variable; |
| 38 | int nth_scan_info; |
| 39 | scan_info *scan_info; |
| 40 | grn_obj *initial_result_set; |
| 41 | grn_obj *result_set; |
| 42 | grn_id min_id; |
| 43 | bool is_first_unskipped_scan_info; |
| 44 | bool is_skipped; |
| 45 | grn_search_optarg search_options; |
| 46 | } grn_table_selector_data; |
| 47 | |
| 48 | struct _grn_table_selector { |
| 49 | grn_obj *table; |
| 50 | grn_obj *expr; |
| 51 | grn_operator op; |
| 52 | grn_id min_id; |
| 53 | bool use_sequential_scan; |
| 54 | grn_obj *query_options; |
| 55 | float weight_factor; |
| 56 | double enough_filtered_ratio; |
| 57 | int64_t max_n_enough_filtered_records; |
| 58 | bool ensure_using_select_result; |
| 59 | grn_fuzzy_search_optarg fuzzy_options; |
| 60 | grn_table_selector_data data; |
| 61 | }; |
| 62 | |
| 63 | void |
| 64 | grn_table_selector_init(grn_ctx *ctx, |
| 65 | grn_table_selector *selector, |
| 66 | grn_obj *table, |
| 67 | grn_obj *expr, |
| 68 | grn_operator op); |
| 69 | void |
| 70 | grn_table_selector_fin(grn_ctx *ctx, grn_table_selector *selector); |
| 71 | |
| 72 | #ifdef __cplusplus |
| 73 | } |
| 74 | #endif |