Groonga
Loading...
Searching...
No Matches
pat.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2016 Brazil
3 Copyright (C) 2024-2025 Sutou Kouhei <kou@clear-code.com>
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 "hash.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef struct _grn_pat grn_pat;
29typedef struct _grn_pat_cursor grn_pat_cursor;
31
34 const char *path,
35 unsigned int key_size,
36 unsigned int value_size,
37 unsigned int flags);
38
40grn_pat_open(grn_ctx *ctx, const char *path);
41
44
46grn_pat_remove(grn_ctx *ctx, const char *path);
47
50 grn_pat *pat,
51 const void *key,
52 unsigned int key_size,
53 void **value);
56 grn_pat *pat,
57 const void *key,
58 unsigned int key_size,
59 void **value,
60 int *added);
61
62GRN_API int
64 grn_ctx *ctx, grn_pat *pat, grn_id id, void *keybuf, int bufsize);
65GRN_API int
67GRN_API int
68grn_pat_get_value(grn_ctx *ctx, grn_pat *pat, grn_id id, void *valuebuf);
71 grn_ctx *ctx, grn_pat *pat, grn_id id, const void *value, int flags);
72
75 grn_pat *pat,
76 grn_id id,
80 grn_pat *pat,
81 const void *key,
82 unsigned int key_size,
84GRN_API int
86 grn_pat *pat,
87 grn_id id,
89
90GRN_API int
92 grn_pat *pat,
93 const char *str,
94 unsigned int str_len,
96 unsigned int sh_size,
97 const char **rest);
98
101 grn_pat *pat,
102 const void *key,
103 unsigned int key_size,
104 grn_hash *h);
107 grn_pat *pat,
108 const void *key,
109 unsigned int key_size,
110 grn_hash *h);
113 grn_pat *pat,
114 const void *key,
115 unsigned int key_size);
116
117GRN_API unsigned int
119
122 grn_pat *pat,
123 const void *min,
124 unsigned int min_size,
125 const void *max,
126 unsigned int max_size,
127 int offset,
128 int limit,
129 int flags);
132GRN_API void
134
135GRN_API int
137GRN_API int
139
140GRN_API int
143 void **key,
144 unsigned int *key_size,
145 void **value);
149 const void *value,
150 int flags);
155
156#define GRN_PAT_EACH(ctx, pat, id, key, key_size, value, block) \
157 do { \
158 grn_pat_cursor *_sc = NULL; \
159 if (pat && grn_pat_size(ctx, pat) > 0) { \
160 _sc = grn_pat_cursor_open(ctx, pat, NULL, 0, NULL, 0, 0, -1, 0); \
161 } \
162 if (_sc) { \
163 grn_id id; \
164 while ((id = grn_pat_cursor_next(ctx, _sc))) { \
165 grn_pat_cursor_get_key_value(ctx, \
166 _sc, \
167 (void **)(key), \
168 (key_size), \
169 (void **)(value)); \
170 block \
171 } \
172 grn_pat_cursor_close(ctx, _sc); \
173 } \
174 } while (0)
175
176#define GRN_PAT_EACH_BEGIN(ctx, pat, cursor, id) \
177 do { \
178 if ((pat) && grn_pat_size((ctx), (pat)) > 0) { \
179 grn_pat_cursor *cursor = \
180 grn_pat_cursor_open((ctx), (pat), NULL, 0, NULL, 0, 0, -1, 0); \
181 if (cursor) { \
182 grn_id id; \
183 while ((id = grn_pat_cursor_next((ctx), (cursor))) != GRN_ID_NIL) {
184
185#define GRN_PAT_EACH_END(ctx, cursor) \
186 } \
187 grn_pat_cursor_close((ctx), (cursor)); \
188 } \
189 } \
190 } \
191 while (false)
192
193#ifdef __cplusplus
194}
195#endif
grn_rc
Definition groonga.h:61
uint32_t grn_id
Definition groonga.h:44
#define GRN_API
Definition groonga.h:39
struct _grn_hash grn_hash
Definition hash.h:28
GRN_API grn_rc grn_pat_set_value(grn_ctx *ctx, grn_pat *pat, grn_id id, const void *value, int flags)
GRN_API grn_pat * grn_pat_open(grn_ctx *ctx, const char *path)
GRN_API grn_pat * grn_pat_create(grn_ctx *ctx, const char *path, unsigned int key_size, unsigned int value_size, unsigned int flags)
GRN_API grn_rc grn_pat_delete(grn_ctx *ctx, grn_pat *pat, const void *key, unsigned int key_size, grn_table_delete_optarg *optarg)
GRN_API grn_rc grn_pat_prefix_search(grn_ctx *ctx, grn_pat *pat, const void *key, unsigned int key_size, grn_hash *h)
GRN_API grn_rc grn_pat_cursor_set_value(grn_ctx *ctx, grn_pat_cursor *c, const void *value, int flags)
GRN_API grn_id grn_pat_get(grn_ctx *ctx, grn_pat *pat, const void *key, unsigned int key_size, void **value)
GRN_API unsigned int grn_pat_size(grn_ctx *ctx, grn_pat *pat)
GRN_API int grn_pat_cursor_get_value(grn_ctx *ctx, grn_pat_cursor *c, void **value)
GRN_API int grn_pat_scan(grn_ctx *ctx, grn_pat *pat, const char *str, unsigned int str_len, grn_pat_scan_hit *sh, unsigned int sh_size, const char **rest)
GRN_API grn_id grn_pat_cursor_next(grn_ctx *ctx, grn_pat_cursor *c)
struct _grn_pat_cursor grn_pat_cursor
Definition pat.h:29
GRN_API grn_id grn_pat_add(grn_ctx *ctx, grn_pat *pat, const void *key, unsigned int key_size, void **value, int *added)
GRN_API grn_rc grn_pat_suffix_search(grn_ctx *ctx, grn_pat *pat, const void *key, unsigned int key_size, grn_hash *h)
GRN_API grn_rc grn_pat_cursor_delete(grn_ctx *ctx, grn_pat_cursor *c, grn_table_delete_optarg *optarg)
GRN_API int grn_pat_delete_with_sis(grn_ctx *ctx, grn_pat *pat, grn_id id, grn_table_delete_optarg *optarg)
GRN_API grn_id grn_pat_lcp_search(grn_ctx *ctx, grn_pat *pat, const void *key, unsigned int key_size)
GRN_API int grn_pat_get_value(grn_ctx *ctx, grn_pat *pat, grn_id id, void *valuebuf)
GRN_API int grn_pat_get_key2(grn_ctx *ctx, grn_pat *pat, grn_id id, grn_obj *bulk)
GRN_API int grn_pat_cursor_get_key_value(grn_ctx *ctx, grn_pat_cursor *c, void **key, unsigned int *key_size, void **value)
GRN_API grn_rc grn_pat_close(grn_ctx *ctx, grn_pat *pat)
GRN_API int grn_pat_cursor_get_key(grn_ctx *ctx, grn_pat_cursor *c, void **key)
struct _grn_pat grn_pat
Definition pat.h:28
GRN_API grn_pat_cursor * grn_pat_cursor_open(grn_ctx *ctx, grn_pat *pat, const void *min, unsigned int min_size, const void *max, unsigned int max_size, int offset, int limit, int flags)
GRN_API grn_rc grn_pat_delete_by_id(grn_ctx *ctx, grn_pat *pat, grn_id id, grn_table_delete_optarg *optarg)
GRN_API int grn_pat_get_key(grn_ctx *ctx, grn_pat *pat, grn_id id, void *keybuf, int bufsize)
GRN_API grn_rc grn_pat_remove(grn_ctx *ctx, const char *path)
GRN_API void grn_pat_cursor_close(grn_ctx *ctx, grn_pat_cursor *c)
Definition groonga.h:351
Definition groonga.h:919
Definition groonga.h:3329
Definition groonga.h:3335
unsigned int offset
Definition groonga.h:3337