Groonga
Loading...
Searching...
No Matches
hash.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2016 Brazil
3 Copyright (C) 2024 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
26#define GRN_HASH_TINY (0x01 << 6)
27
28typedef struct _grn_hash grn_hash;
29typedef struct _grn_hash_cursor grn_hash_cursor;
30
33 const char *path,
34 unsigned int key_size,
35 unsigned int value_size,
36 unsigned int flags);
37
39grn_hash_open(grn_ctx *ctx, const char *path);
40
43
46 grn_hash *hash,
47 const void *key,
48 unsigned int key_size,
49 void **value,
50 int *added);
53 grn_hash *hash,
54 const void *key,
55 unsigned int key_size,
56 void **value);
57
58GRN_API int
60 grn_ctx *ctx, grn_hash *hash, grn_id id, void *keybuf, int bufsize);
61GRN_API int
63GRN_API int
64grn_hash_get_value(grn_ctx *ctx, grn_hash *hash, grn_id id, void *valuebuf);
67 grn_ctx *ctx, grn_hash *hash, grn_id id, const void *value, int flags);
68
71 grn_hash *hash,
72 grn_id id,
76 grn_hash *hash,
77 const void *key,
78 unsigned int key_size,
80
81GRN_API uint32_t
83
86 grn_hash *hash,
87 const void *min,
88 unsigned int min_size,
89 const void *max,
90 unsigned int max_size,
91 int offset,
92 int limit,
93 int flags);
96GRN_API void
98
99GRN_API int
101GRN_API int
106 const void *value,
107 int flags);
108
109GRN_API int
112 void **key,
113 unsigned int *key_size,
114 void **value);
115
120
121#define GRN_HASH_EACH(ctx, hash, id, key, key_size, value, block) \
122 do { \
123 grn_hash_cursor *_sc = NULL; \
124 if (hash && grn_hash_size(ctx, hash) > 0) { \
125 _sc = grn_hash_cursor_open(ctx, hash, NULL, 0, NULL, 0, 0, -1, 0); \
126 } \
127 if (_sc) { \
128 grn_id id; \
129 while ((id = grn_hash_cursor_next(ctx, _sc))) { \
130 grn_hash_cursor_get_key_value(ctx, \
131 _sc, \
132 (void **)(key), \
133 (key_size), \
134 (void **)(value)); \
135 block \
136 } \
137 grn_hash_cursor_close(ctx, _sc); \
138 } \
139 } while (0)
140
141#define GRN_HASH_EACH_BEGIN(ctx, hash, cursor, id) \
142 do { \
143 grn_hash_cursor *cursor = NULL; \
144 if (hash && grn_hash_size(ctx, hash) > 0) { \
145 cursor = grn_hash_cursor_open((ctx), \
146 (hash), \
147 NULL, \
148 0, \
149 NULL, \
150 0, \
151 0, \
152 -1, \
153 GRN_CURSOR_BY_ID); \
154 } \
155 if (cursor) { \
156 grn_id id; \
157 while ((id = grn_hash_cursor_next((ctx), cursor)) != GRN_ID_NIL) {
158
159#define GRN_HASH_EACH_END(ctx, cursor) \
160 } \
161 grn_hash_cursor_close((ctx), cursor); \
162 } \
163 } \
164 while (0)
165
166#ifdef __cplusplus
167}
168#endif
grn_rc
Definition groonga.h:61
uint32_t grn_id
Definition groonga.h:44
#define GRN_API
Definition groonga.h:39
GRN_API int grn_hash_cursor_get_key(grn_ctx *ctx, grn_hash_cursor *c, void **key)
GRN_API grn_id grn_hash_get(grn_ctx *ctx, grn_hash *hash, const void *key, unsigned int key_size, void **value)
GRN_API uint32_t grn_hash_size(grn_ctx *ctx, grn_hash *hash)
GRN_API void grn_hash_cursor_close(grn_ctx *ctx, grn_hash_cursor *c)
GRN_API int grn_hash_cursor_get_value(grn_ctx *ctx, grn_hash_cursor *c, void **value)
GRN_API int grn_hash_get_key(grn_ctx *ctx, grn_hash *hash, grn_id id, void *keybuf, int bufsize)
GRN_API grn_hash_cursor * grn_hash_cursor_open(grn_ctx *ctx, grn_hash *hash, 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_hash_cursor_delete(grn_ctx *ctx, grn_hash_cursor *c, grn_table_delete_optarg *optarg)
GRN_API grn_rc grn_hash_set_value(grn_ctx *ctx, grn_hash *hash, grn_id id, const void *value, int flags)
GRN_API int grn_hash_get_key2(grn_ctx *ctx, grn_hash *hash, grn_id id, grn_obj *bulk)
struct _grn_hash_cursor grn_hash_cursor
Definition hash.h:29
GRN_API int grn_hash_cursor_get_key_value(grn_ctx *ctx, grn_hash_cursor *c, void **key, unsigned int *key_size, void **value)
GRN_API grn_rc grn_hash_delete(grn_ctx *ctx, grn_hash *hash, const void *key, unsigned int key_size, grn_table_delete_optarg *optarg)
GRN_API grn_id grn_hash_add(grn_ctx *ctx, grn_hash *hash, const void *key, unsigned int key_size, void **value, int *added)
GRN_API grn_rc grn_hash_close(grn_ctx *ctx, grn_hash *hash)
GRN_API grn_hash * grn_hash_open(grn_ctx *ctx, const char *path)
GRN_API grn_rc grn_hash_delete_by_id(grn_ctx *ctx, grn_hash *hash, grn_id id, grn_table_delete_optarg *optarg)
GRN_API grn_rc grn_hash_cursor_set_value(grn_ctx *ctx, grn_hash_cursor *c, const void *value, int flags)
GRN_API grn_id grn_hash_cursor_next(grn_ctx *ctx, grn_hash_cursor *c)
GRN_API grn_hash * grn_hash_create(grn_ctx *ctx, const char *path, unsigned int key_size, unsigned int value_size, unsigned int flags)
struct _grn_hash grn_hash
Definition hash.h:28
GRN_API int grn_hash_get_value(grn_ctx *ctx, grn_hash *hash, grn_id id, void *valuebuf)
Definition groonga.h:351
Definition groonga.h:919
Definition groonga.h:3329