Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
snip.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /* Copyright(C) 2009-2012 Brazil
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 #ifndef GRN_SNIP_H
18 #define GRN_SNIP_H
19 
20 #ifndef GROONGA_IN_H
21 #include "groonga_in.h"
22 #endif /* GROONGA_IN_H */
23 
24 #ifndef GRN_STR_H
25 #include "str.h"
26 #endif /* GRN_STR_H */
27 
28 #include "db.h"
29 
30 #define ASIZE 256U
31 #define MAX_SNIP_TAG_COUNT 512U
32 #define MAX_SNIP_COND_COUNT 32U
33 #define MAX_SNIP_RESULT_COUNT 16U
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 #define SNIPCOND_NONSTOP 0
41 #define SNIPCOND_STOP 1
42 #define SNIPCOND_ACROSS 2
43 
44 #define GRN_QUERY_SCAN_ALLOCCONDS 0x0002
45 
46 typedef struct _snip_cond
47 {
48  /* initial parameters */
49  const char *opentag;
50  const char *closetag;
51  size_t opentag_len;
52  size_t closetag_len;
54 
55  /* Tuned BM pre */
56  size_t bmBc[ASIZE];
57  size_t shift;
58 
59  /* Tuned BM temporal result */
60  size_t found;
61  size_t last_found;
62  size_t last_offset;
63  size_t start_offset;
64  size_t end_offset;
66 
67  /* search result */
68  int count;
69 
70  /* stop flag */
72 } snip_cond;
73 
74 typedef struct
75 {
76  size_t start_offset;
77  size_t end_offset;
80 
81 typedef struct
82 {
83  size_t start_offset;
84  size_t end_offset;
85  unsigned int first_tag_result_idx;
86  unsigned int last_tag_result_idx;
87  unsigned int tag_count;
88 } _snip_result;
89 
90 struct _grn_snip
91 {
94  int flags;
95  size_t width;
96  unsigned int max_results;
97  const char *defaultopentag;
98  const char *defaultclosetag;
101 
103 
105  unsigned int cond_len;
106 
107  unsigned int tag_count;
108  unsigned int snip_count;
109 
110  const char *string;
112 
115 
117 };
118 
120 grn_rc grn_snip_cond_init(grn_ctx *ctx, snip_cond *sc, const char *keyword, unsigned int keyword_len,
121  grn_encoding enc, int flags);
122 void grn_snip_cond_reinit(snip_cond *cond);
124 void grn_bm_tunedbm(grn_ctx *ctx, snip_cond *cond, grn_obj *string, int flags);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* GRN_SNIP_H */