Groonga
Loading...
Searching...
No Matches
dat.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2016 Brazil
3 Copyright (C) 2020-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#ifdef __cplusplus
23extern "C" {
24#endif
25
26typedef struct _grn_dat grn_dat;
27typedef struct _grn_dat_cursor grn_dat_cursor;
29
30GRN_API int
32 grn_dat *dat,
33 const char *str,
34 unsigned int str_size,
35 grn_dat_scan_hit *scan_hits,
36 unsigned int max_num_scan_hits,
37 const char **str_rest);
38
41 grn_dat *dat,
42 const void *key,
43 unsigned int key_size);
44
47 const char *path,
48 unsigned int key_size,
49 unsigned int value_size,
50 unsigned int flags);
51
53grn_dat_open(grn_ctx *ctx, const char *path);
54
57
59grn_dat_remove(grn_ctx *ctx, const char *path);
60
63 grn_dat *dat,
64 const void *key,
65 unsigned int key_size,
66 void **value);
69 grn_dat *dat,
70 const void *key,
71 unsigned int key_size,
72 void **value,
73 int *added);
74
75GRN_API int
77 grn_ctx *ctx, grn_dat *dat, grn_id id, void *keybuf, int bufsize);
78GRN_API int
80
83 grn_dat *dat,
84 grn_id id,
88 grn_dat *dat,
89 const void *key,
90 unsigned int key_size,
92
95 grn_dat *dat,
96 grn_id src_key_id,
97 const void *dest_key,
98 unsigned int dest_key_size);
101 grn_dat *dat,
102 const void *src_key,
103 unsigned int src_key_size,
104 const void *dest_key,
105 unsigned int dest_key_size);
106
107GRN_API unsigned int
109
112 grn_dat *dat,
113 const void *min,
114 unsigned int min_size,
115 const void *max,
116 unsigned int max_size,
117 int offset,
118 int limit,
119 int flags);
122GRN_API void
124
125GRN_API int
131GRN_API size_t
133
134#define GRN_DAT_EACH(ctx, dat, id, key, key_size, block) \
135 do { \
136 grn_dat_cursor *_sc = NULL; \
137 if (dat && grn_dat_size(ctx, dat) > 0) { \
138 _sc = grn_dat_cursor_open(ctx, dat, NULL, 0, NULL, 0, 0, -1, 0); \
139 } \
140 if (_sc) { \
141 grn_id id; \
142 unsigned int *_ks = (key_size); \
143 if (_ks) { \
144 while ((id = grn_dat_cursor_next(ctx, _sc))) { \
145 int _ks_raw = \
146 grn_dat_cursor_get_key(ctx, _sc, (const void **)(key)); \
147 *(_ks) = (unsigned int)_ks_raw; \
148 block \
149 } \
150 } else { \
151 while ((id = grn_dat_cursor_next(ctx, _sc))) { \
152 grn_dat_cursor_get_key(ctx, _sc, (const void **)(key)); \
153 block \
154 } \
155 } \
156 grn_dat_cursor_close(ctx, _sc); \
157 } \
158 } while (0)
159
160#define GRN_DAT_EACH_BEGIN(ctx, dat, cursor, id) \
161 do { \
162 if ((dat) && grn_dat_size((ctx), (dat)) > 0) { \
163 grn_dat_cursor *cursor = \
164 grn_dat_cursor_open((ctx), (dat), NULL, 0, NULL, 0, 0, -1, 0); \
165 if (cursor) { \
166 grn_id id; \
167 while ((id = grn_dat_cursor_next((ctx), (cursor))) != GRN_ID_NIL) {
168
169#define GRN_DAT_EACH_END(ctx, cursor) \
170 } \
171 grn_dat_cursor_close((ctx), (cursor)); \
172 } \
173 } \
174 } \
175 while (false)
176
177#ifdef __cplusplus
178}
179#endif
GRN_API grn_rc grn_dat_close(grn_ctx *ctx, grn_dat *dat)
struct _grn_dat grn_dat
Definition dat.h:26
GRN_API grn_id grn_dat_get(grn_ctx *ctx, grn_dat *dat, const void *key, unsigned int key_size, void **value)
GRN_API int grn_dat_get_key(grn_ctx *ctx, grn_dat *dat, grn_id id, void *keybuf, int bufsize)
GRN_API grn_id grn_dat_add(grn_ctx *ctx, grn_dat *dat, const void *key, unsigned int key_size, void **value, int *added)
GRN_API grn_rc grn_dat_delete(grn_ctx *ctx, grn_dat *dat, const void *key, unsigned int key_size, grn_table_delete_optarg *optarg)
GRN_API grn_rc grn_dat_delete_by_id(grn_ctx *ctx, grn_dat *dat, grn_id id, grn_table_delete_optarg *optarg)
GRN_API int grn_dat_scan(grn_ctx *ctx, grn_dat *dat, const char *str, unsigned int str_size, grn_dat_scan_hit *scan_hits, unsigned int max_num_scan_hits, const char **str_rest)
GRN_API void grn_dat_cursor_close(grn_ctx *ctx, grn_dat_cursor *c)
GRN_API grn_rc grn_dat_remove(grn_ctx *ctx, const char *path)
GRN_API grn_dat * grn_dat_create(grn_ctx *ctx, const char *path, unsigned int key_size, unsigned int value_size, unsigned int flags)
GRN_API grn_rc grn_dat_update(grn_ctx *ctx, grn_dat *dat, const void *src_key, unsigned int src_key_size, const void *dest_key, unsigned int dest_key_size)
GRN_API int grn_dat_get_key2(grn_ctx *ctx, grn_dat *dat, grn_id id, grn_obj *bulk)
GRN_API grn_dat * grn_dat_open(grn_ctx *ctx, const char *path)
GRN_API grn_rc grn_dat_cursor_delete(grn_ctx *ctx, grn_dat_cursor *c, grn_table_delete_optarg *optarg)
GRN_API size_t grn_dat_cursor_get_max_n_records(grn_ctx *ctx, grn_dat_cursor *c)
GRN_API grn_dat_cursor * grn_dat_cursor_open(grn_ctx *ctx, grn_dat *dat, const void *min, unsigned int min_size, const void *max, unsigned int max_size, int offset, int limit, int flags)
GRN_API int grn_dat_cursor_get_key(grn_ctx *ctx, grn_dat_cursor *c, const void **key)
GRN_API grn_rc grn_dat_update_by_id(grn_ctx *ctx, grn_dat *dat, grn_id src_key_id, const void *dest_key, unsigned int dest_key_size)
struct _grn_dat_cursor grn_dat_cursor
Definition dat.h:27
GRN_API grn_id grn_dat_cursor_next(grn_ctx *ctx, grn_dat_cursor *c)
GRN_API unsigned int grn_dat_size(grn_ctx *ctx, grn_dat *dat)
GRN_API grn_id grn_dat_lcp_search(grn_ctx *ctx, grn_dat *dat, const void *key, unsigned int key_size)
grn_rc
Definition groonga.h:61
uint32_t grn_id
Definition groonga.h:44
#define GRN_API
Definition groonga.h:39
Definition groonga.h:351
Definition groonga.h:919
Definition groonga.h:3329
Definition groonga.h:3335
unsigned int offset
Definition groonga.h:3337