1/* -*- c-basic-offset: 2 -*- */
2/*
3 Copyright(C) 2013-2016 Brazil
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 version 2.1 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#pragma once
20
21#include "grn_db.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#define SCAN_ACCESSOR (0x01)
28#define SCAN_PUSH (0x02)
29#define SCAN_POP (0x04)
30#define SCAN_PRE_CONST (0x08)
31
32typedef enum {
33 SCAN_START = 0,
34 SCAN_VAR,
35 SCAN_COL1,
36 SCAN_COL2,
37 SCAN_CONST
38} scan_stat;
39
40typedef struct _grn_scan_info scan_info;
41typedef grn_bool (*grn_scan_info_each_arg_callback)(grn_ctx *ctx, grn_obj *obj, void *user_data);
42
43void grn_expr_init_from_env(void);
44
45scan_info **grn_scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
46 grn_operator op, grn_bool record_exist);
47
48scan_info *grn_scan_info_open(grn_ctx *ctx, int start);
49void grn_scan_info_close(grn_ctx *ctx, scan_info *si);
50void grn_scan_info_put_index(grn_ctx *ctx, scan_info *si, grn_obj *index,
51 uint32_t sid, int32_t weight,
52 grn_obj *scorer,
53 grn_obj *scorer_args_expr,
54 uint32_t scorer_args_expr_offset);
55scan_info **grn_scan_info_put_logical_op(grn_ctx *ctx, scan_info **sis, int *ip,
56 grn_operator op, int start);
57int grn_scan_info_get_flags(scan_info *si);
58void grn_scan_info_set_flags(scan_info *si, int flags);
59grn_operator grn_scan_info_get_logical_op(scan_info *si);
60void grn_scan_info_set_logical_op(scan_info *si, grn_operator logical_op);
61grn_operator grn_scan_info_get_op(scan_info *si);
62void grn_scan_info_set_op(scan_info *si, grn_operator op);
63void grn_scan_info_set_end(scan_info *si, uint32_t end);
64void grn_scan_info_set_query(scan_info *si, grn_obj *query);
65int grn_scan_info_get_max_interval(scan_info *si);
66void grn_scan_info_set_max_interval(scan_info *si, int max_interval);
67int grn_scan_info_get_similarity_threshold(scan_info *si);
68void grn_scan_info_set_similarity_threshold(scan_info *si, int similarity_threshold);
69grn_bool grn_scan_info_push_arg(scan_info *si, grn_obj *arg);
70grn_obj *grn_scan_info_get_arg(grn_ctx *ctx, scan_info *si, int i);
71int grn_scan_info_get_start_position(scan_info *si);
72void grn_scan_info_set_start_position(scan_info *si, int start);
73void grn_scan_info_reset_position(scan_info *si);
74
75int32_t grn_expr_code_get_weight(grn_ctx *ctx, grn_expr_code *ec, uint32_t *offset);
76grn_rc grn_expr_code_inspect_indented(grn_ctx *ctx,
77 grn_obj *buffer,
78 grn_expr_code *code,
79 const char *indent);
80void grn_p_expr_code(grn_ctx *ctx, grn_expr_code *code);
81
82grn_obj *grn_expr_alloc_const(grn_ctx *ctx, grn_obj *expr);
83
84#ifdef __cplusplus
85}
86#endif
87