Debian Codegraph @

lib/ctx.cpp

raw symbols SCIP
1 /*
2 Copyright (C) 2009-2018 Brazil
3 Copyright (C) 2019-2025 Sutou Kouhei <[email protected]>
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 #include "grn.h"cxx . . $ `<file>/lib/grn.h`/
21 #include "grn_arrow.h"cxx . . $ `<file>/lib/grn_arrow.h`/
22 #include "grn_request_canceler.h"cxx . . $ `<file>/lib/grn_request_canceler.h`/
23 #include "grn_request_timer.h"cxx . . $ `<file>/lib/grn_request_timer.h`/
24 #include "grn_tokenizers.h"cxx . . $ `<file>/lib/grn_tokenizers.h`/
25 #include "grn_ctx_impl.h"cxx . . $ `<file>/lib/grn_ctx_impl.h`/
26 #include "grn_distance.h"cxx . . $ `<file>/lib/grn_distance.h`/
27 #include "grn_encoding.h"cxx . . $ `<file>/lib/grn_encoding.h`/
28 #include "grn_hash.h"cxx . . $ `<file>/lib/grn_hash.h`/
29 #include "grn_ii.h"cxx . . $ `<file>/lib/grn_ii.h`/
30 #include "grn_language_model.hpp"cxx . . $ `<file>/lib/grn_language_model.hpp`/
31 #include "grn_pat.h"cxx . . $ `<file>/lib/grn_pat.h`/
32 #include "grn_index_column.h"cxx . . $ `<file>/lib/grn_index_column.h`/
33 #include "grn_proc.h"cxx . . $ `<file>/lib/grn_proc.h`/
34 #include "grn_plugin.h"cxx . . $ `<file>/lib/grn_plugin.h`/
35 #include "grn_snip.h"cxx . . $ `<file>/lib/grn_snip.h`/
36 #include "grn_output.h"cxx . . $ `<file>/lib/grn_output.h`/
37 #include "grn_normalizer.h"cxx . . $ `<file>/lib/grn_normalizer.h`/
38 #include "grn_mrb.h"cxx . . $ `<file>/lib/grn_mrb.h`/
39 #include "grn_ctx_impl_mrb.h"cxx . . $ `<file>/lib/grn_ctx_impl_mrb.h`/
40 #include "grn_ctx_impl_lua.h"cxx . . $ `<file>/lib/grn_ctx_impl_lua.h`/
41 #include "grn_logger.h"cxx . . $ `<file>/lib/grn_logger.h`/
42 #include "grn_cache.h"cxx . . $ `<file>/lib/grn_cache.h`/
43 #include "grn_expr.h"cxx . . $ `<file>/lib/grn_expr.h`/
44 #include "grn_table_selector.h"cxx . . $ `<file>/lib/grn_table_selector.h`/
45 #include "grn_task_executor.hpp"cxx . . $ `<file>/lib/grn_task_executor.hpp`/
46 #include "grn_token_column.h"cxx . . $ `<file>/lib/grn_token_column.h`/
47 #include "grn_window_function_executor.h"cxx . . $ `<file>/lib/grn_window_function_executor.h`/
48 #include "grn_windows.h"cxx . . $ `<file>/lib/grn_windows.h`/
49 #include "grn_group.h"cxx . . $ `<file>/lib/grn_group.h`/
50 #include "grn_slow_log.h"cxx . . $ `<file>/lib/grn_slow_log.h`/
51
52 #include <stdarg.h>
53 #include <stdio.h>
54 #include <string.h>
55 #include <time.h>
56
57 #ifdef GRN_SUPPORT_REGEXPcxx . . $ `lib/grn.h:734:11`!
58 # include <onigmo.h>cxx . . $ `<file>/vendor/onigmo-source/onigmo.h`/
59 #endif /* GRN_SUPPORT_REGEXP */
60
61 #ifdef GRN_WITH_BLOSC
62 # include <blosc2.h>
63 #endif
64
65 #ifdef WIN32
66 # include <share.h>
67 # ifndef MAXUSHORT
68 # define MAXUSHORT 0xffff
69 # endif
70 #else /* WIN32 */
71 # include <netinet/in.h>
72 # ifdef HAVE_EXECINFO_Hcxx . . $ `build/config.h:128:9`!
73 # include <execinfo.h>
74 # endif /* HAVE_EXECINFO_H */
75 #endif /* WIN32 */
76
77 /* TODO: Is there configuration for this style? */
78 /* clang-format off */
79 #define GRN_CTX_INITIALIZERcxx . . $ `lib/ctx.cpp:79:9`!(enc) \
80 { \
81 /* rc */ GRN_SUCCESS, \
82 /* flags */ 0, \
83 /* encoding */ enc, \
84 /* ntrace */ 0, \
85 /* errlvl */ GRN_LOG_NOTICE, \
86 /* stat */ GRN_CTX_FINcxx . . $ `include/groonga/groonga.h:335:9`!, \
87 /* seqno */ 0, \
88 /* subno */ 0, \
89 /* seqno2 */ 0, \
90 /* errline */ 0, \
91 /* user_data */ {0}, \
92 /* prev */ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, \
93 /* next */ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, \
94 /* errfile */ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, \
95 /* errfunc */ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, \
96 /* impl */ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, \
97 /* trace */ {0}, \
98 /* errbuf */ {0} \
99 }
100 /* clang-format on */
101
102 #define GRN_CTX_CLOSEDcxx . . $ `lib/ctx.cpp:102:9`!(ctx) ((ctx)->stat == GRN_CTX_FIN)
103
104 extern "C" {
105 grn_ctx grn_gctx = GRN_CTX_INITIALIZERcxx . . $ `lib/ctx.cpp:79:9`!(GRN_ENC_DEFAULT);
106 int grn_pagesize;
107 grn_critical_sectioncxx . . $ grn_critical_section# grn_glock;
108 uint32_tcxx . . $ uint32_t# grn_gtick;
109 int grn_lock_timeout = GRN_LOCK_TIMEOUTcxx . . $ `build/config.h:31:9`!;
110
111 #ifdef USE_UYIELD
112 int grn_uyield_count = 0;
113 #endif
114
115 static bool grn_ctx_per_db = false;
116 static bool grn_back_trace_enable = true;
117 static int32_t grn_n_workers_default = 0;
118
119 static void
120 grn_init_from_env(void)
121 {
122 {
123 char grn_ctx_per_db_env[GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!];
124 grn_getenvcxx . . $ `include/groonga/portability.h:58:11`!("GRN_CTX_PER_DB", grn_ctx_per_db_env, GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!);
125 if (grn_ctx_per_db_env[0] && strcmp(grn_ctx_per_db_env, "yes") == 0) {
126 grn_ctx_per_db = true;
127 }
128 }
129
130 {
131 char grn_back_trace_enable_env[GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!];
132 grn_getenvcxx . . $ `include/groonga/portability.h:58:11`!("GRN_BACK_TRACE_ENABLE",
133 grn_back_trace_enable_env,
134 GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!);
135 if (grn_back_trace_enable_env[0] &&
136 strcmp(grn_back_trace_enable_env, "no") == 0) {
137 grn_back_trace_enable = false;
138 }
139 }
140
141 /* For backward compatibility. */
142 {
143 char env[GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!];
144 grn_getenvcxx . . $ `include/groonga/portability.h:58:11`!("GRN_SELECT_N_WORKERS_DEFAULT", env, GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!);
145 if (env[0]) {
146 grn_n_workers_default = atoicxx . . $ atoi(f5ecf3191ed0cd93).(env);
147 }
148 }
149 {
150 char env[GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!];
151 grn_getenvcxx . . $ `include/groonga/portability.h:58:11`!("GRN_N_WORKERS_DEFAULT", env, GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!);
152 if (env[0]) {
153 grn_n_workers_default = atoicxx . . $ atoi(f5ecf3191ed0cd93).(env);
154 }
155 }
156
157 grn_error_init_from_env();
158
159 grn_alloc_init_from_env();
160 grn_mrb_init_from_env();
161 grn_ctx_impl_mrb_init_from_env();
162 grn_distance_init_from_env();
163 grn_hash_init_from_env();
164 grn_io_init_from_env();
165 grn_ii_init_from_env();
166 grn_ja_init_from_env();
167 grncxx . . $ grn/::language_modelcxx . . $ grn/language_model/::init_from_envcxx . . $ grn/language_model/init_from_env(49f6e7a06ebc5aa8).();
168 grn_db_init_from_env();
169 grn_expr_init_from_env();
170 grn_index_column_init_from_env();
171 grn_output_init_from_env();
172 grn_proc_init_from_env();
173 grn_proc_query_init_from_env();
174 grn_plugin_init_from_env();
175 grn_token_column_init_from_env();
176 grn_group_init_from_env();
177 grn_window_function_executor_init_from_env();
178 grn_table_selector_init_from_env();
179 grn_slow_log_init_from_env();
180 }
181
182 static void
183 grn_init_external_libraries(void)
184 {
185 #ifdef GRN_SUPPORT_REGEXPcxx . . $ `lib/grn.h:734:11`!
186 onig_init();
187 #endif /* GRN_SUPPORT_REGEXP */
188 #ifdef GRN_WITH_BLOSC
189 blosc2_init();
190 #endif
191 grn_arrow_init_external_libraries();
192 grn_distance_init_external_libraries();
193 }
194
195 static void
196 grn_fin_external_libraries(void)
197 {
198 #ifdef GRN_SUPPORT_REGEXPcxx . . $ `lib/grn.h:734:11`!
199 onig_end();
200 #endif /* GRN_SUPPORT_REGEXP */
201 #ifdef GRN_WITH_BLOSC
202 blosc2_destroy();
203 #endif
204 grncxx . . $ grn/::language_modelcxx . . $ grn/language_model/::fin_external_librariescxx . . $ grn/language_model/fin_external_libraries(49f6e7a06ebc5aa8).();
205 }
206
207 void
208 grn_sleep(uint32_tcxx . . $ uint32_t# seconds)
209 {
210 #ifdef WIN32
211 Sleep(seconds * 1000);
212 #else // WIN32
213 sleep(seconds);
214 #endif // WIN32
215 }
216
217 void
218 grn_nanosleep(uint64_tcxx . . $ uint64_t# nanoseconds)
219 {
220 #ifdef WIN32
221 Sleep((DWORD)(nanoseconds / 1000000));
222 #else // WIN32
223 struct timespec interval;
224 interval.tv_sec = (time_t)(nanoseconds / 1000000000);
225 interval.tv_nsec = (long)(nanoseconds % 1000000000);
226 nanosleep(&interval, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
227 #endif // WIN32
228 }
229
230 const char *
231 grn_get_global_error_message(void)
232 {
233 return grn_gctx.errbufcxx . . $ _grn_ctx#errbuf.;
234 }
235
236 static void
237 grn_loader_init(grn_loader *loader)
238 {
239 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&loader->values, 0);
240 GRN_UINT32_INITcxx . . $ `include/groonga/groonga.h:2854:9`!(&loader->level, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
241 loader->columns = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
242 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&loader->ranges, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
243 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&loader->indexes, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
244 GRN_UINT32_INITcxx . . $ `include/groonga/groonga.h:2854:9`!(&loader->ids, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
245 GRN_INT32_INITcxx . . $ `include/groonga/groonga.h:2852:9`!(&loader->return_codes, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
246 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&loader->error_messages, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
247 loader->id_offset = -1;
248 loader->key_offset = -1;
249 loader->last = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
250 loader->table = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
251 loader->ifexists = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
252 loader->each = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
253 loader->values_size = 0;
254 loader->n_records = 0;
255 loader->n_record_errors = 0;
256 loader->n_column_errors = 0;
257 loader->stat = GRN_LOADER_BEGIN;
258 loader->columns_status = GRN_LOADER_COLUMNS_UNSET;
259 loader->error.rc = GRN_SUCCESS;
260 loader->error.buffer[0] = '\0';
261 loader->error.line = 0;
262 loader->error.file = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
263 loader->error.func = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
264 loader->output_ids = false;
265 loader->output_errors = false;
266 }
267
268 void
269 grn_ctx_loader_clear(grn_ctx *ctx)
270 {
271 grn_loader *loader = &ctx->implcxx . . $ _grn_ctx#impl.->loadercxx . . $ _grn_ctx_impl#loader.;
272 grn_obj *v = (grn_obj *)(GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(&loader->values));
273 grn_obj *ve = (grn_obj *)(GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&loader->values));
274 if (ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.) {
275 size_t i;
276 size_t n_ranges = GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(loader->ranges));
277 for (i = 0; i < n_ranges; i++) {
278 grn_obj_unlink(ctx, GRN_PTR_VALUE_ATcxx . . $ `include/groonga/groonga.h:3150:9`!(&(loader->ranges), i));
279 }
280 size_t n_indexes = GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(loader->indexes));
281 for (i = 0; i < n_indexes; i++) {
282 grn_obj_unlink(ctx, GRN_PTR_VALUE_ATcxx . . $ `include/groonga/groonga.h:3150:9`!(&(loader->indexes), i));
283 }
284 if (loader->columns) {
285 GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, loader->columns, cursor, id)
286 {
287 void *value;
288 grn_hash_cursor_get_value(ctx, cursor, &value);
289 if (value) {
290 grn_obj *column = *((grn_obj **)value);
291 grn_obj_unlink(ctx, column);
292 }
293 }
294 GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor);
295 }
296 if (loader->table) {
297 grn_obj_unlink(ctx, loader->table);
298 }
299 }
300 if (loader->ifexists) {
301 grn_obj_unlink(ctx, loader->ifexists);
302 }
303 if (loader->each) {
304 grn_obj_unlink(ctx, loader->each);
305 }
306 while (v < ve) {
307 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, v++);
308 }
309 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &loader->values);
310 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &loader->level);
311 if (loader->columns) {
312 grn_hash_close(ctx, loader->columns);
313 }
314 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &loader->ranges);
315 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &loader->indexes);
316 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &loader->ids);
317 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &loader->return_codes);
318 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &loader->error_messages);
319 #ifdef GRN_WITH_APACHE_ARROW
320 if (ctx->impl->arrow_stream_loader) {
321 grn_arrow_stream_loader_close(ctx, ctx->impl->arrow_stream_loader);
322 ctx->impl->arrow_stream_loader = NULL;
323 }
324 #endif
325 grn_loader_init(loader);
326 }
327
328 #define IMPL_SIZEcxx . . $ `lib/ctx.cpp:328:9`! \
329 (size_t)((((int)sizeof(struct _grn_ctx_impl)) + (grn_pagesize - 1)) & \
330 ~(grn_pagesize - 1))
331
332 #ifdef GRN_WITH_MESSAGE_PACKcxx . . $ `build/config.h:108:9`!
333 static int
334 grn_msgpack_buffer_write(void *data, const char *buf, msgpack_size_tcxx . . $ msgpack_size_t# len)
335 {
336 grn_ctx *ctx = (grn_ctx *)data;
337 return grn_bulk_write(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., buf, len);
338 }
339 #endif
340
341 typedef struct {
342 void *data;
343 grn_close_func close_func;
344 } grn_ctx_local_variable;
345
346 static grn_rc
347 grn_ctx_impl_init(grn_ctx *ctx)
348 {
349 grn_io_mapinfo mi;
350 if (!(ctx->implcxx . . $ _grn_ctx#impl. =
351 static_cast<_grn_ctx_implcxx . . $ _grn_ctx_impl# *>(grn_io_anon_map(ctx, &mi, IMPL_SIZEcxx . . $ `lib/ctx.cpp:328:9`!)))) {
352 return ctx->rccxx . . $ _grn_ctx#rc.;
353 }
354 grn_alloc_init_ctx_impl(ctx);
355 ctx->implcxx . . $ _grn_ctx#impl.->encodingcxx . . $ _grn_ctx_impl#encoding. = ctx->encodingcxx . . $ _grn_ctx#encoding.;
356 ctx->implcxx . . $ _grn_ctx#impl.->lifosegcxx . . $ _grn_ctx_impl#lifoseg. = -1;
357 ctx->implcxx . . $ _grn_ctx#impl.->currsegcxx . . $ _grn_ctx_impl#currseg. = -1;
358
359 ctx->implcxx . . $ _grn_ctx#impl.->valuescxx . . $ _grn_ctx_impl#values. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
360 ctx->implcxx . . $ _grn_ctx#impl.->temporary_columnscxx . . $ _grn_ctx_impl#temporary_columns. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
361 ctx->implcxx . . $ _grn_ctx#impl.->temporary_optionscxx . . $ _grn_ctx_impl#temporary_options. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
362 ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
363 ctx->implcxx . . $ _grn_ctx#impl.->ioscxx . . $ _grn_ctx_impl#ios. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
364 ctx->implcxx . . $ _grn_ctx#impl.->expr_varscxx . . $ _grn_ctx_impl#expr_vars. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
365 ctx->implcxx . . $ _grn_ctx#impl.->stackcxx . . $ _grn_ctx_impl#stack. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
366 ctx->implcxx . . $ _grn_ctx#impl.->current_selector_datacxx . . $ _grn_ctx_impl#current_selector_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
367
368 CRITICAL_SECTION_INITcxx . . $ `lib/grn.h:226:11`!(ctx->impl->lock);
369 CRITICAL_SECTION_INITcxx . . $ `lib/grn.h:226:11`!(ctx->impl->columns_cache_lock);
370 if (!(ctx->implcxx . . $ _grn_ctx#impl.->valuescxx . . $ _grn_ctx_impl#values. =
371 grn_array_create(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, sizeof(grn_db_obj *), GRN_ARRAY_TINYcxx . . $ `lib/grn_hash.h:153:9`!))) {
372 goto exit;
373 }
374 if (!(ctx->implcxx . . $ _grn_ctx#impl.->temporary_columnscxx . . $ _grn_ctx_impl#temporary_columns. = grn_pat_create(ctx,
375 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!,
376 GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!,
377 sizeof(grn_obj *),
378 0))) {
379 goto exit;
380 }
381 ctx->implcxx . . $ _grn_ctx#impl.->temporary_optionscxx . . $ _grn_ctx_impl#temporary_options. =
382 grn_options_create(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, "[ctx][impl][create]");
383 if (!ctx->implcxx . . $ _grn_ctx#impl.->temporary_optionscxx . . $ _grn_ctx_impl#temporary_options.) {
384 goto exit;
385 }
386 if (!(ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache. =
387 grn_hash_create(ctx,
388 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!,
389 sizeof(grn_id),
390 sizeof(grn_hash *),
391 GRN_OBJ_TABLE_HASH_KEYcxx . . $ `include/groonga/groonga.h:688:9`! | GRN_HASH_TINYcxx . . $ `include/groonga/hash.h:26:9`!))) {
392 goto exit;
393 }
394 if (!(ctx->implcxx . . $ _grn_ctx#impl.->ioscxx . . $ _grn_ctx_impl#ios. =
395 grn_hash_create(ctx,
396 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!,
397 GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!,
398 sizeof(grn_io *),
399 GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`! | GRN_HASH_TINYcxx . . $ `include/groonga/hash.h:26:9`!))) {
400 goto exit;
401 }
402 ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
403
404 if (!(ctx->implcxx . . $ _grn_ctx#impl.->expr_varscxx . . $ _grn_ctx_impl#expr_vars. =
405 grn_hash_create(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, sizeof(grn_id), sizeof(grn_obj *), 0))) {
406 goto exit;
407 }
408 if (!(ctx->implcxx . . $ _grn_ctx#impl.->stackcxx . . $ _grn_ctx_impl#stack. = GRN_MALLOCNcxx . . $ `lib/grn_alloc.h:50:9`!(grn_obj *, GRN_STACK_SIZEcxx . . $ `build/config.h:29:9`!))) {
409 goto exit;
410 }
411 ctx->implcxx . . $ _grn_ctx#impl.->stack_currcxx . . $ _grn_ctx_impl#stack_curr. = 0;
412 ctx->implcxx . . $ _grn_ctx#impl.->stack_sizecxx . . $ _grn_ctx_impl#stack_size. = GRN_STACK_SIZEcxx . . $ `build/config.h:29:9`!;
413 ctx->implcxx . . $ _grn_ctx#impl.->curr_exprcxx . . $ _grn_ctx_impl#curr_expr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
414 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&ctx->impl->current_request_id, 0);
415 ctx->implcxx . . $ _grn_ctx#impl.->current_request_timer_idcxx . . $ _grn_ctx_impl#current_request_timer_id. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
416 /* grn_obj * isn't void * but sizeof(grn_obj *) and sizeof(void *)
417 * is same. So we reuse GRN_PVECTOR here. */
418 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&(ctx->impl->expr_parsers), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
419
420 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&ctx->impl->output.names, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
421 GRN_UINT32_INITcxx . . $ `include/groonga/groonga.h:2854:9`!(&ctx->impl->output.levels, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
422
423 ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers. = grn_n_workers_default;
424 ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..task_executorcxx . . $ _grn_ctx_impl#$anonymous_type_2#task_executor. = nullptr;
425
426 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..flagscxx . . $ _grn_ctx_impl#$anonymous_type_3#flags. = 0;
427 if (ctx == &grn_gctx) {
428 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version. = GRN_COMMAND_VERSION_STABLEcxx . . $ `include/groonga/groonga.h:189:9`!;
429 } else {
430 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version. = grn_get_default_command_version();
431 }
432 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..commandcxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#command. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
433 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#version. = ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version.;
434 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#n_workers. = ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers.;
435
436 if (ctx == &grn_gctx) {
437 ctx->implcxx . . $ _grn_ctx#impl.->match_escalation_thresholdcxx . . $ _grn_ctx_impl#match_escalation_threshold. =
438 GRN_DEFAULT_MATCH_ESCALATION_THRESHOLDcxx . . $ `build/config.h:22:9`!;
439 } else {
440 ctx->implcxx . . $ _grn_ctx#impl.->match_escalation_thresholdcxx . . $ _grn_ctx_impl#match_escalation_threshold. =
441 grn_get_default_match_escalation_threshold();
442 }
443 ctx->implcxx . . $ _grn_ctx#impl.->force_match_escalationcxx . . $ _grn_ctx_impl#force_match_escalation. = false;
444
445 ctx->implcxx . . $ _grn_ctx#impl.->finalizercxx . . $ _grn_ctx_impl#finalizer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
446
447 ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
448 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf. = grn_obj_open(ctx, GRN_BULKcxx . . $ `include/groonga/groonga.h:868:9`!, 0, GRN_DB_TEXT);
449 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..funccxx . . $ _grn_ctx_impl#$anonymous_type_0#func. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
450 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..datacxx . . $ _grn_ctx_impl#$anonymous_type_0#data..ptrcxx . . $ _grn_ctx_impl#$anonymous_type_0#$anonymous_type_1#ptr. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
451 #ifdef GRN_WITH_MESSAGE_PACKcxx . . $ `build/config.h:108:9`!
452 msgpack_packer_init(&ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..msgpackercxx . . $ _grn_ctx_impl#$anonymous_type_0#msgpacker.,
453 ctx,
454 grn_msgpack_buffer_write);
455 #endif
456 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..arrow_stream_writercxx . . $ _grn_ctx_impl#$anonymous_type_0#arrow_stream_writer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
457 grn_timeval_now(ctx, &ctx->implcxx . . $ _grn_ctx#impl.->tvcxx . . $ _grn_ctx_impl#tv.);
458 #ifdef GRN_WITH_APACHE_ARROW
459 ctx->impl->arrow_stream_loader = NULL;
460 #endif
461 grn_loader_init(&ctx->implcxx . . $ _grn_ctx#impl.->loadercxx . . $ _grn_ctx_impl#loader.);
462 ctx->implcxx . . $ _grn_ctx#impl.->plugin_pathcxx . . $ _grn_ctx_impl#plugin_path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
463
464 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&ctx->impl->query_log_buf, 0);
465
466 ctx->implcxx . . $ _grn_ctx#impl.->previous_errbufcxx . . $ _grn_ctx_impl#previous_errbuf.[0] = '\0';
467 ctx->implcxx . . $ _grn_ctx#impl.->n_same_error_messagescxx . . $ _grn_ctx_impl#n_same_error_messages. = 0;
468
469 GRN_INT64_INITcxx . . $ `include/groonga/groonga.h:2856:9`!(&(ctx->impl->slow_log.start_times), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
470
471 grn_ctx_impl_mrb_init(ctx);
472 grn_ctx_impl_lua_init(ctx);
473
474 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(ctx->impl->temporary_open_spaces.stack), 0);
475 ctx->implcxx . . $ _grn_ctx#impl.->temporary_open_spacescxx . . $ _grn_ctx_impl#temporary_open_spaces..currentcxx . . $ _grn_ctx_impl#$anonymous_type_6#current. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
476
477 ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables. = grn_hash_create(ctx,
478 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!,
479 GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!,
480 sizeof(grn_ctx_local_variable),
481 GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`! | GRN_HASH_TINYcxx . . $ `include/groonga/hash.h:26:9`!);
482 if (!ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables.) {
483 goto exit;
484 }
485
486 ctx->implcxx . . $ _grn_ctx#impl.->walcxx . . $ _grn_ctx_impl#wal..rolecxx . . $ _grn_ctx_impl#$anonymous_type_7#role. = GRN_WAL_ROLE_NONE;
487
488 CRITICAL_SECTION_INITcxx . . $ `lib/grn.h:226:11`!(ctx->impl->children.lock);
489 /* grn_obj * isn't grn_ctx * but sizeof(grn_obj *) and
490 * sizeof(grn_ctx *) is same. So we reuse GRN_PVECTOR here. */
491 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&(ctx->impl->children.pool), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
492 ctx->implcxx . . $ _grn_ctx#impl.->parentcxx . . $ _grn_ctx_impl#parent. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
493 CRITICAL_SECTION_INITcxx . . $ `lib/grn.h:226:11`!(ctx->impl->temporary_objects_lock);
494
495 ctx->implcxx . . $ _grn_ctx#impl.->progresscxx . . $ _grn_ctx_impl#progress..callbackcxx . . $ _grn_ctx_impl#$anonymous_type_9#callback. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
496 ctx->implcxx . . $ _grn_ctx#impl.->progresscxx . . $ _grn_ctx_impl#progress..user_datacxx . . $ _grn_ctx_impl#$anonymous_type_9#user_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
497
498 ctx->implcxx . . $ _grn_ctx#impl.->trace_logcxx . . $ _grn_ctx_impl#trace_log..start_timecxx . . $ _grn_ctx_impl#$anonymous_type_10#start_time. = 0;
499 GRN_UINT16_INITcxx . . $ `include/groonga/groonga.h:2850:9`!(&(ctx->impl->trace_log.depths), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
500 GRN_UINT16_INITcxx . . $ `include/groonga/groonga.h:2850:9`!(&(ctx->impl->trace_log.sequence_stack), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
501 GRN_UINT16_INITcxx . . $ `include/groonga/groonga.h:2850:9`!(&(ctx->impl->trace_log.sequences), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
502 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(ctx->impl->trace_log.names), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
503 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(ctx->impl->trace_log.values), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
504 GRN_UINT64_INITcxx . . $ `include/groonga/groonga.h:2858:9`!(&(ctx->impl->trace_log.elapsed_times), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
505
506 exit:
507 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) {
508 if (ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables.) {
509 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables.);
510 }
511 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->temporary_open_spaces.stack));
512 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->query_log_buf);
513 grn_obj_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.);
514 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->output.levels);
515 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->output.names);
516 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->current_request_id);
517 if (ctx->implcxx . . $ _grn_ctx#impl.->stackcxx . . $ _grn_ctx_impl#stack.) {
518 GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(ctx->impl->stack);
519 }
520 if (ctx->implcxx . . $ _grn_ctx#impl.->expr_varscxx . . $ _grn_ctx_impl#expr_vars.) {
521 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->expr_varscxx . . $ _grn_ctx_impl#expr_vars.);
522 }
523 if (ctx->implcxx . . $ _grn_ctx#impl.->ioscxx . . $ _grn_ctx_impl#ios.) {
524 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->ioscxx . . $ _grn_ctx_impl#ios.);
525 }
526 if (ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache.) {
527 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache.);
528 }
529 if (ctx->implcxx . . $ _grn_ctx#impl.->temporary_optionscxx . . $ _grn_ctx_impl#temporary_options.) {
530 grn_options_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->temporary_optionscxx . . $ _grn_ctx_impl#temporary_options.);
531 }
532 if (ctx->implcxx . . $ _grn_ctx#impl.->temporary_columnscxx . . $ _grn_ctx_impl#temporary_columns.) {
533 grn_pat_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->temporary_columnscxx . . $ _grn_ctx_impl#temporary_columns.);
534 }
535 if (ctx->implcxx . . $ _grn_ctx#impl.->valuescxx . . $ _grn_ctx_impl#values.) {
536 grn_array_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->valuescxx . . $ _grn_ctx_impl#values.);
537 }
538 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(ctx->impl->columns_cache_lock);
539 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(ctx->impl->lock);
540 grn_io_anon_unmap(ctx, &mi, IMPL_SIZEcxx . . $ `lib/ctx.cpp:328:9`!);
541 ctx->implcxx . . $ _grn_ctx#impl. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
542 }
543
544 return ctx->rccxx . . $ _grn_ctx#rc.;
545 }
546
547 void
548 grn_ctx_set_keep_command(grn_ctx *ctx, grn_obj *command)
549 {
550 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..commandcxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#command. = command;
551 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#version. = ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version.;
552 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#n_workers. = ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers.;
553 }
554
555 grn_ctx *
556 grn_ctx_pull_child(grn_ctx *ctx)
557 {
558 grn_ctx *child_ctx = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
559 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(ctx->impl->children.lock);
560 if (GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(ctx->impl->children.pool)) == 0) {
561 child_ctx = grn_ctx_open(0);
562 } else {
563 grn_obj *value;
564 GRN_PTR_POPcxx . . $ `include/groonga/groonga.h:3248:9`!(&(ctx->impl->children.pool), value);
565 child_ctx = (grn_ctx *)value;
566 }
567 grn_ctx_use(child_ctx, grn_ctx_db(ctx));
568 child_ctx->implcxx . . $ _grn_ctx#impl.->parentcxx . . $ _grn_ctx_impl#parent. = ctx;
569 child_ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version. = ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version.;
570 child_ctx->implcxx . . $ _grn_ctx#impl.->match_escalation_thresholdcxx . . $ _grn_ctx_impl#match_escalation_threshold. =
571 ctx->implcxx . . $ _grn_ctx#impl.->match_escalation_thresholdcxx . . $ _grn_ctx_impl#match_escalation_threshold.;
572 child_ctx->implcxx . . $ _grn_ctx#impl.->force_match_escalationcxx . . $ _grn_ctx_impl#force_match_escalation. = ctx->implcxx . . $ _grn_ctx#impl.->force_match_escalationcxx . . $ _grn_ctx_impl#force_match_escalation.;
573 child_ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers. = ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers.;
574 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(ctx->impl->children.lock);
575 return child_ctx;
576 }
577
578 grn_rc
579 grn_ctx_release_child(grn_ctx *ctx, grn_ctx *child_ctx)
580 {
581 if (child_ctx->implcxx . . $ _grn_ctx#impl.->parentcxx . . $ _grn_ctx_impl#parent. != ctx) {
582 return GRN_INVALID_ARGUMENT;
583 }
584
585 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(ctx->impl->children.lock);
586 if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS && child_ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) {
587 ctx->rccxx . . $ _grn_ctx#rc. = child_ctx->rccxx . . $ _grn_ctx#rc.;
588 ctx->errlvlcxx . . $ _grn_ctx#errlvl. = child_ctx->errlvlcxx . . $ _grn_ctx#errlvl.;
589 ctx->errfilecxx . . $ _grn_ctx#errfile. = child_ctx->errfilecxx . . $ _grn_ctx#errfile.;
590 ctx->errlinecxx . . $ _grn_ctx#errline. = child_ctx->errlinecxx . . $ _grn_ctx#errline.;
591 ctx->errfunccxx . . $ _grn_ctx#errfunc. = child_ctx->errfunccxx . . $ _grn_ctx#errfunc.;
592 grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(ctx->errbuf, GRN_CTX_MSGSIZE, child_ctx->errbuf);
593 }
594 ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(child_ctx);
595 child_ctx->implcxx . . $ _grn_ctx#impl.->parentcxx . . $ _grn_ctx_impl#parent. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
596 grn_ctx_use(child_ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
597 GRN_PTR_PUTcxx . . $ `include/groonga/groonga.h:3218:9`!(ctx, &(ctx->impl->children.pool), child_ctx);
598 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(ctx->impl->children.lock);
599 return ctx->rccxx . . $ _grn_ctx#rc.;
600 }
601
602 void *
603 grn_ctx_expr_parser_pull(grn_ctx *ctx)
604 {
605 void *parser = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
606 if (GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(ctx->impl->expr_parsers)) == 0) {
607 parser = grn_expr_parser_open(ctx);
608 } else {
609 grn_obj *value;
610 GRN_PTR_POPcxx . . $ `include/groonga/groonga.h:3248:9`!(&(ctx->impl->expr_parsers), value);
611 parser = reinterpret_cast<void *>(value);
612 }
613 return parser;
614 }
615
616 grn_rc
617 grn_ctx_expr_parser_release(grn_ctx *ctx, void *parser)
618 {
619 GRN_PTR_PUTcxx . . $ `include/groonga/groonga.h:3218:9`!(ctx, &(ctx->impl->expr_parsers), parser);
620 return ctx->rccxx . . $ _grn_ctx#rc.;
621 }
622
623 grn_rc
624 grn_ctx_expr_parsers_clear(grn_ctx *ctx)
625 {
626 while (GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(ctx->impl->expr_parsers)) > 0) {
627 grn_obj *value;
628 GRN_PTR_POPcxx . . $ `include/groonga/groonga.h:3248:9`!(&(ctx->impl->expr_parsers), value);
629 auto expr_parser = reinterpret_cast<void *>(value);
630 grn_expr_parser_close(ctx, expr_parser);
631 }
632 return ctx->rccxx . . $ _grn_ctx#rc.;
633 }
634
635 grn_rc
636 grn_ctx_set_progress_callback(grn_ctx *ctx,
637 grn_progress_callback_func func,
638 void *user_data)
639 {
640 if (!ctx) {
641 return GRN_INVALID_ARGUMENT;
642 }
643 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
644 return GRN_INVALID_ARGUMENT;
645 }
646
647 ctx->implcxx . . $ _grn_ctx#impl.->progresscxx . . $ _grn_ctx_impl#progress..callbackcxx . . $ _grn_ctx_impl#$anonymous_type_9#callback. = func;
648 ctx->implcxx . . $ _grn_ctx#impl.->progresscxx . . $ _grn_ctx_impl#progress..user_datacxx . . $ _grn_ctx_impl#$anonymous_type_9#user_data. = user_data;
649
650 return GRN_SUCCESS;
651 }
652
653 grn_progress_callback_func
654 grn_ctx_get_progress_callback(grn_ctx *ctx)
655 {
656 if (!ctx) {
657 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
658 }
659 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
660 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
661 }
662 return ctx->implcxx . . $ _grn_ctx#impl.->progresscxx . . $ _grn_ctx_impl#progress..callbackcxx . . $ _grn_ctx_impl#$anonymous_type_9#callback.;
663 }
664
665 void
666 grn_ctx_call_progress_callback(grn_ctx *ctx, grn_progress *progress)
667 {
668 if (!ctx) {
669 return;
670 }
671 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
672 return;
673 }
674 ctx->implcxx . . $ _grn_ctx#impl.->progresscxx . . $ _grn_ctx_impl#progress..callbackcxx . . $ _grn_ctx_impl#$anonymous_type_9#callback.(ctx, progress, ctx->implcxx . . $ _grn_ctx#impl.->progresscxx . . $ _grn_ctx_impl#progress..user_datacxx . . $ _grn_ctx_impl#$anonymous_type_9#user_data.);
675 }
676
677 static void
678 grn_ctx_impl_clear_n_same_error_messagges(grn_ctx *ctx)
679 {
680 if (ctx->implcxx . . $ _grn_ctx#impl.->n_same_error_messagescxx . . $ _grn_ctx_impl#n_same_error_messages. == 0) {
681 return;
682 }
683
684 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
685 GRN_LOG_NOTICE,
686 "(%u same messages are truncated)",
687 ctx->impl->n_same_error_messages);
688 ctx->implcxx . . $ _grn_ctx#impl.->n_same_error_messagescxx . . $ _grn_ctx_impl#n_same_error_messages. = 0;
689 }
690
691 bool
692 grn_ctx_impl_should_log(grn_ctx *ctx)
693 {
694 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
695 return true;
696 }
697
698 if (strcmp(ctx->errbufcxx . . $ _grn_ctx#errbuf., ctx->implcxx . . $ _grn_ctx#impl.->previous_errbufcxx . . $ _grn_ctx_impl#previous_errbuf.) == 0) {
699 ctx->implcxx . . $ _grn_ctx#impl.->n_same_error_messagescxx . . $ _grn_ctx_impl#n_same_error_messages.++;
700 return false;
701 }
702
703 return true;
704 }
705
706 void
707 grn_ctx_impl_set_current_error_message(grn_ctx *ctx)
708 {
709 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
710 return;
711 }
712
713 grn_ctx_impl_clear_n_same_error_messagges(ctx);
714 grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(ctx->impl->previous_errbuf, GRN_CTX_MSGSIZE, ctx->errbuf);
715 }
716
717 void
718 grn_ctx_impl_columns_cache_clear(grn_ctx *ctx)
719 {
720 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(ctx->impl->columns_cache_lock);
721 GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, ctx->impl->columns_cache, cursor, id)
722 {
723 void *value;
724 grn_hash_cursor_get_value(ctx, cursor, &value);
725 grn_hash *columns = *((grn_hash **)value);
726 grn_hash_close(ctx, columns);
727 grn_hash_cursor_delete(ctx, cursor, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
728 }
729 GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor);
730 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(ctx->impl->columns_cache_lock);
731 }
732
733 void
734 grn_ctx_impl_columns_cache_delete(grn_ctx *ctx, grn_id table_id)
735 {
736 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(ctx->impl->columns_cache_lock);
737 grn_id cache_id;
738 void *value;
739 cache_id = grn_hash_get(ctx,
740 ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache.,
741 &table_id,
742 sizeof(grn_id),
743 &value);
744 if (cache_id != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) {
745 grn_hash *columns = *((grn_hash **)value);
746 grn_hash_close(ctx, columns);
747 grn_hash_delete_by_id(ctx, ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache., cache_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
748 }
749 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(ctx->impl->columns_cache_lock);
750 }
751
752 static grn_rc
753 grn_ctx_impl_fin(grn_ctx *ctx)
754 {
755 grn_rc rc;
756
757 grn_ctx_impl_clear_n_same_error_messagges(ctx);
758 if (ctx->implcxx . . $ _grn_ctx#impl.->finalizercxx . . $ _grn_ctx_impl#finalizer.) {
759 ctx->implcxx . . $ _grn_ctx#impl.->finalizercxx . . $ _grn_ctx_impl#finalizer.(ctx, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, &(ctx->user_datacxx . . $ _grn_ctx#user_data.));
760 }
761
762 ctx->implcxx . . $ _grn_ctx#impl.->trace_logcxx . . $ _grn_ctx_impl#trace_log..start_timecxx . . $ _grn_ctx_impl#$anonymous_type_10#start_time. = 0;
763 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->trace_log.depths));
764 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->trace_log.sequence_stack));
765 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->trace_log.sequences));
766 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->trace_log.names));
767 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->trace_log.values));
768 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->trace_log.elapsed_times));
769
770 {
771 while (GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(ctx->impl->children.pool)) > 0) {
772 grn_obj *value;
773 GRN_PTR_POPcxx . . $ `include/groonga/groonga.h:3248:9`!(&(ctx->impl->children.pool), value);
774 grn_ctx *child_ctx = (grn_ctx *)value;
775 grn_ctx_close(child_ctx);
776 }
777 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->children.pool));
778 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(ctx->impl->children.lock);
779 }
780 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(ctx->impl->temporary_objects_lock);
781
782 GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, ctx->impl->variables, cursor, id)
783 {
784 void *value;
785 grn_hash_cursor_get_value(ctx, cursor, &value);
786 auto variable = static_cast<grn_ctx_local_variable *>(value);
787 if (variable->close_func) {
788 variable->close_func(ctx, variable->data);
789 }
790 }
791 GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor);
792 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables.);
793 {
794 grn_obj *stack;
795 grn_obj *spaces;
796 size_t i, n_spaces;
797
798 stack = &(ctx->implcxx . . $ _grn_ctx#impl.->temporary_open_spacescxx . . $ _grn_ctx_impl#temporary_open_spaces..stackcxx . . $ _grn_ctx_impl#$anonymous_type_6#stack.);
799 spaces = (grn_obj *)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(stack);
800 n_spaces = GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(stack) / sizeof(grn_obj);
801 for (i = 0; i < n_spaces; i++) {
802 grn_obj *space = spaces + (n_spaces - i - 1);
803 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, space);
804 }
805 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, stack);
806 }
807 grn_ctx_impl_lua_fin(ctx);
808 grn_ctx_impl_mrb_fin(ctx);
809 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->slow_log.start_times));
810 grn_ctx_loader_clear(ctx);
811 grn_ctx_expr_parsers_clear(ctx);
812 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(ctx->impl->expr_parsers));
813 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->current_request_id);
814 if (ctx->implcxx . . $ _grn_ctx#impl.->valuescxx . . $ _grn_ctx_impl#values.) {
815 #ifndef GRN_WITH_MEMORY_DEBUG
816 grn_db_obj *o;
817 GRN_ARRAY_EACHcxx . . $ `include/groonga/array.h:53:9`!(ctx, ctx->impl->values, 0, 0, id, &o, {
818 grn_obj_close(ctx, *((grn_obj **)o));
819 });
820 #endif
821 grn_array_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->valuescxx . . $ _grn_ctx_impl#values.);
822 }
823 if (ctx->implcxx . . $ _grn_ctx#impl.->temporary_columnscxx . . $ _grn_ctx_impl#temporary_columns.) {
824 #ifndef GRN_WITH_MEMORY_DEBUG
825 grn_obj *value;
826 GRN_PAT_EACHcxx . . $ `include/groonga/pat.h:156:9`!(ctx, ctx->impl->temporary_columns, id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, &value, {
827 grn_obj_close(ctx, *((grn_obj **)value));
828 });
829 #endif
830 grn_pat_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->temporary_columnscxx . . $ _grn_ctx_impl#temporary_columns.);
831 }
832 if (ctx->implcxx . . $ _grn_ctx#impl.->temporary_optionscxx . . $ _grn_ctx_impl#temporary_options.) {
833 grn_options_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->temporary_optionscxx . . $ _grn_ctx_impl#temporary_options.);
834 }
835 if (ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache.) {
836 grn_ctx_impl_columns_cache_clear(ctx);
837 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->columns_cachecxx . . $ _grn_ctx_impl#columns_cache.);
838 }
839 if (ctx->implcxx . . $ _grn_ctx#impl.->ioscxx . . $ _grn_ctx_impl#ios.) {
840 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->ioscxx . . $ _grn_ctx_impl#ios.);
841 }
842 if (ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com.) {
843 if (ctx->statcxx . . $ _grn_ctx#stat. != GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!) {
844 int flags;
845 char *str;
846 unsigned int str_len;
847 grn_ctx_send(ctx, "quit", 4, GRN_CTX_HEADcxx . . $ `include/groonga/groonga.h:3295:9`!);
848 grn_ctx_recv(ctx, &str, &str_len, &flags);
849 }
850 grn_ctx_send(ctx, "ACK", 3, GRN_CTX_HEADcxx . . $ `include/groonga/groonga.h:3295:9`!);
851 rc = grn_com_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com.);
852 }
853 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->query_log_buf);
854 if (ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..task_executorcxx . . $ _grn_ctx_impl#$anonymous_type_2#task_executor.) {
855 delete static_cast<grncxx . . $ grn/::TaskExecutorcxx . . $ grn/TaskExecutor# *>(ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..task_executorcxx . . $ _grn_ctx_impl#$anonymous_type_2#task_executor.);
856 }
857 if (ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..arrow_stream_writercxx . . $ _grn_ctx_impl#$anonymous_type_0#arrow_stream_writer.) {
858 grn_arrow_stream_writer_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..arrow_stream_writercxx . . $ _grn_ctx_impl#$anonymous_type_0#arrow_stream_writer.);
859 }
860 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->output.names);
861 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &ctx->impl->output.levels);
862 rc = grn_obj_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.);
863 if (ctx->implcxx . . $ _grn_ctx#impl.->expr_varscxx . . $ _grn_ctx_impl#expr_vars.) {
864 grn_hash **vp;
865 grn_obj *value;
866 GRN_HASH_EACHcxx . . $ `include/groonga/hash.h:121:9`!(ctx, ctx->impl->expr_vars, eid, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, &vp, {
867 if (*vp) {
868 GRN_HASH_EACHcxx . . $ `include/groonga/hash.h:121:9`!(ctx, *vp, id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, &value, {
869 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, value);
870 });
871 }
872 grn_hash_close(ctx, *vp);
873 });
874 grn_hash_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->expr_varscxx . . $ _grn_ctx_impl#expr_vars.);
875 }
876 if (ctx->implcxx . . $ _grn_ctx#impl.->stackcxx . . $ _grn_ctx_impl#stack.) {
877 GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(ctx->impl->stack);
878 }
879 if (ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db. && ctx->flagscxx . . $ _grn_ctx#flags. & GRN_CTX_PER_DBcxx . . $ `include/groonga/groonga.h:378:9`!) {
880 grn_obj *db = ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.;
881 ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
882 grn_obj_close(ctx, db);
883 }
884 grn_alloc_fin_ctx_impl(ctx);
885 grn_alloc_info_dump(ctx);
886 grn_alloc_info_free(ctx);
887 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(ctx->impl->columns_cache_lock);
888 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(ctx->impl->lock);
889 {
890 grn_io_mapinfo mi;
891 mi.map = (void *)ctx->implcxx . . $ _grn_ctx#impl.;
892 grn_io_anon_unmap(ctx, &mi, IMPL_SIZEcxx . . $ `lib/ctx.cpp:328:9`!);
893 }
894
895 return rc;
896 }
897
898 static grn_rc
899 grn_ctx_init_internal(grn_ctx *ctx, int flags)
900 {
901 if (!ctx) {
902 return GRN_INVALID_ARGUMENT;
903 }
904 // if (ctx->stat != GRN_CTX_FIN) { return GRN_INVALID_ARGUMENT; }
905 ctx->rccxx . . $ _grn_ctx#rc. = GRN_SUCCESS;
906 ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx);
907 ctx->flagscxx . . $ _grn_ctx#flags. = flags;
908 if (grn_ctx_per_db) {
909 ctx->flagscxx . . $ _grn_ctx#flags. |= GRN_CTX_PER_DBcxx . . $ `include/groonga/groonga.h:378:9`!;
910 }
911 ctx->statcxx . . $ _grn_ctx#stat. = GRN_CTX_INITEDcxx . . $ `lib/grn_ctx_impl.h:48:9`!;
912 ctx->encodingcxx . . $ _grn_ctx#encoding. = grn_gctx.encodingcxx . . $ _grn_ctx#encoding.;
913 ctx->seqnocxx . . $ _grn_ctx#seqno. = 0;
914 ctx->seqno2cxx . . $ _grn_ctx#seqno2. = 0;
915 ctx->subnocxx . . $ _grn_ctx#subno. = 0;
916 ctx->implcxx . . $ _grn_ctx#impl. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
917 ctx->user_datacxx . . $ _grn_ctx#user_data..ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
918 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(grn_glock);
919 ctx->nextcxx . . $ _grn_ctx#next. = grn_gctx.nextcxx . . $ _grn_ctx#next.;
920 ctx->prevcxx . . $ _grn_ctx#prev. = &grn_gctx;
921 grn_gctx.nextcxx . . $ _grn_ctx#next.->prevcxx . . $ _grn_ctx#prev. = ctx;
922 grn_gctx.nextcxx . . $ _grn_ctx#next. = ctx;
923 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(grn_glock);
924 ctx->errlinecxx . . $ _grn_ctx#errline. = 0;
925 ctx->errfilecxx . . $ _grn_ctx#errfile. = "";
926 ctx->errfunccxx . . $ _grn_ctx#errfunc. = "";
927 ctx->tracecxx . . $ _grn_ctx#trace.[0] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
928 ctx->errbufcxx . . $ _grn_ctx#errbuf.[0] = '\0';
929 return GRN_SUCCESS;
930 }
931
932 grn_rc
933 grn_ctx_init(grn_ctx *ctx, int flags)
934 {
935 grn_rc rc;
936
937 rc = grn_ctx_init_internal(ctx, flags);
938 if (rc == GRN_SUCCESS) {
939 grn_ctx_impl_init(ctx);
940 rc = ctx->rccxx . . $ _grn_ctx#rc.;
941 if (rc != GRN_SUCCESS) {
942 grn_ctx_fin(ctx);
943 if (flags & GRN_CTX_ALLOCATEDcxx . . $ `lib/grn_ctx.h:85:9`!) {
944 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(grn_glock);
945 ctx->nextcxx . . $ _grn_ctx#next.->prevcxx . . $ _grn_ctx#prev. = ctx->prevcxx . . $ _grn_ctx#prev.;
946 ctx->prevcxx . . $ _grn_ctx#prev.->nextcxx . . $ _grn_ctx#next. = ctx->nextcxx . . $ _grn_ctx#next.;
947 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(grn_glock);
948 }
949 }
950 }
951
952 return rc;
953 }
954
955 grn_ctx *
956 grn_ctx_open(int flags)
957 {
958 grn_ctx *ctx = GRN_GMALLOCNcxx . . $ `lib/grn_alloc.h:52:9`!(grn_ctx, 1);
959 if (ctx) {
960 grn_ctx_init(ctx, flags | GRN_CTX_ALLOCATEDcxx . . $ `lib/grn_ctx.h:85:9`!);
961 if (ERRPcxx . . $ `lib/grn_error.h:149:9`!(ctx, GRN_ERRORcxx . . $ `lib/grn_error.h:33:9`!)) {
962 GRN_GFREEcxx . . $ `lib/grn_alloc.h:51:9`!(ctx);
963 ctx = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
964 }
965 }
966 return ctx;
967 }
968
969 grn_rc
970 grn_ctx_fin(grn_ctx *ctx)
971 {
972 grn_rc rc = GRN_SUCCESS;
973 if (!ctx) {
974 return GRN_INVALID_ARGUMENT;
975 }
976 if (ctx->statcxx . . $ _grn_ctx#stat. == GRN_CTX_FINcxx . . $ `include/groonga/groonga.h:335:9`!) {
977 return GRN_INVALID_ARGUMENT;
978 }
979 if (!(ctx->flagscxx . . $ _grn_ctx#flags. & GRN_CTX_ALLOCATEDcxx . . $ `lib/grn_ctx.h:85:9`!)) {
980 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(grn_glock);
981 ctx->nextcxx . . $ _grn_ctx#next.->prevcxx . . $ _grn_ctx#prev. = ctx->prevcxx . . $ _grn_ctx#prev.;
982 ctx->prevcxx . . $ _grn_ctx#prev.->nextcxx . . $ _grn_ctx#next. = ctx->nextcxx . . $ _grn_ctx#next.;
983 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(grn_glock);
984 }
985 if (ctx->implcxx . . $ _grn_ctx#impl.) {
986 rc = grn_ctx_impl_fin(ctx);
987 ctx->implcxx . . $ _grn_ctx#impl. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
988 }
989 ctx->statcxx . . $ _grn_ctx#stat. = GRN_CTX_FINcxx . . $ `include/groonga/groonga.h:335:9`!;
990 return rc;
991 }
992
993 grn_rc
994 grn_ctx_set_finalizer(grn_ctx *ctx, grn_proc_func *finalizer)
995 {
996 if (!ctx) {
997 return GRN_INVALID_ARGUMENT;
998 }
999 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
1000 if (ERRPcxx . . $ `lib/grn_error.h:149:9`!(ctx, GRN_ERRORcxx . . $ `lib/grn_error.h:33:9`!)) {
1001 return ctx->rccxx . . $ _grn_ctx#rc.;
1002 }
1003 }
1004 ctx->implcxx . . $ _grn_ctx#impl.->finalizercxx . . $ _grn_ctx_impl#finalizer. = finalizer;
1005 return GRN_SUCCESS;
1006 }
1007
1008 grn_timeval grn_starttime;
1009
1010 static void
1011 check_overcommit_memory(grn_ctx *ctx)
1012 {
1013 FILE *file;
1014 int value;
1015 file = grn_fopencxx . . $ `include/groonga/portability.h:76:11`!("/proc/sys/vm/overcommit_memory", "r");
1016 if (!file) {
1017 return;
1018 }
1019 value = fgetc(file);
1020 if (value != '1') {
1021 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
1022 GRN_LOG_NOTICE,
1023 "vm.overcommit_memory kernel parameter should be 1: <%c>: "
1024 "See INFO level log to resolve this",
1025 value);
1026 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
1027 GRN_LOG_INFO,
1028 "Some processings with vm.overcommit_memory != 1 "
1029 "may break DB under low memory condition.");
1030 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_INFO, "To set vm.overcommit_memory to 1");
1031 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
1032 GRN_LOG_INFO,
1033 "add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and "
1034 "restart your system or");
1035 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
1036 GRN_LOG_INFO,
1037 "run 'sudo /sbin/sysctl vm.overcommit_memory=1' command.");
1038 }
1039 fclose(file);
1040 }
1041
1042 grn_rc
1043 grn_init(void)
1044 {
1045 grn_rc rc;
1046 grn_ctx *ctx = &grn_gctx;
1047 #ifdef WIN32
1048 grn_windows_init();
1049 #endif
1050 grn_slow_log_init();
1051 grn_init_from_env();
1052 grn_init_external_libraries();
1053 grn_alloc_info_init();
1054 grn_logger_init();
1055 grn_query_logger_init();
1056 CRITICAL_SECTION_INITcxx . . $ `lib/grn.h:226:11`!(grn_glock);
1057 grn_gtick = 0;
1058 ctx->nextcxx . . $ _grn_ctx#next. = ctx;
1059 ctx->prevcxx . . $ _grn_ctx#prev. = ctx;
1060 rc = grn_ctx_init_internal(ctx, 0);
1061 if (rc) {
1062 goto fail_ctx_init_internal;
1063 }
1064 ctx->encodingcxx . . $ _grn_ctx#encoding. = grn_encoding_parse(GRN_DEFAULT_ENCODINGcxx . . $ `build/config.h:21:9`!);
1065 rc = grn_timeval_now(ctx, &grn_starttime);
1066 if (rc) {
1067 goto fail_start_time;
1068 }
1069 #ifdef WIN32
1070 {
1071 SYSTEM_INFO si;
1072 GetSystemInfo(&si);
1073 grn_pagesize = si.dwAllocationGranularity;
1074 }
1075 #else /* WIN32 */
1076 if ((grn_pagesize = (int)sysconf(_SC_PAGESIZEcxx . . $ `<external>/6393649343499073842/confname.h:134:9`!)) == -1) {
1077 SERRcxx . . $ `lib/grn_error.h:411:11`!("_SC_PAGESIZE");
1078 rc = ctx->rccxx . . $ _grn_ctx#rc.;
1079 goto fail_page_size;
1080 }
1081 #endif /* WIN32 */
1082 if (grn_pagesize & (grn_pagesize - 1)) {
1083 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_CRIT, "pagesize=%x", grn_pagesize);
1084 }
1085 // expand_stack();
1086 if ((rc = grn_com_init())) {
1087 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_ALERT, "grn_com_init failed (%d)", rc);
1088 goto fail_com;
1089 }
1090 if ((rc = grn_ctx_impl_init(ctx))) {
1091 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_ALERT, "grn_ctx_impl_init failed (%d)", rc);
1092 goto fail_ctx_impl;
1093 }
1094 if ((rc = grn_plugins_init())) {
1095 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_ALERT, "grn_plugins_init failed (%d)", rc);
1096 goto fail_plugins;
1097 }
1098 if ((rc = grn_normalizer_init())) {
1099 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_ALERT, "grn_normalizer_init failed (%d)", rc);
1100 goto fail_normalizer;
1101 }
1102 if ((rc = grn_tokenizers_init())) {
1103 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_ALERT, "grn_tokenizers_init failed (%d)", rc);
1104 goto fail_tokenizer;
1105 }
1106 grn_cache_init();
1107 if (!grn_request_canceler_init()) {
1108 rc = ctx->rccxx . . $ _grn_ctx#rc.;
1109 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
1110 GRN_LOG_ALERT,
1111 "failed to initialize request canceler (%d)",
1112 rc);
1113 goto fail_request_canceler;
1114 }
1115 if (!grn_request_timer_init()) {
1116 rc = ctx->rccxx . . $ _grn_ctx#rc.;
1117 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_ALERT, "failed to initialize request timer (%d)", rc);
1118 goto fail_request_timer;
1119 }
1120 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_NOTICE, "grn_init: <%s>", grn_get_version());
1121 check_overcommit_memory(ctx);
1122 return rc;
1123
1124 fail_request_timer:
1125 grn_request_canceler_fin();
1126 fail_request_canceler:
1127 grn_cache_fin();
1128 fail_tokenizer:
1129 grn_normalizer_fin();
1130 fail_normalizer:
1131 grn_plugins_fin();
1132 fail_plugins:
1133 grn_ctx_fin(ctx);
1134 fail_ctx_impl:
1135 grn_com_fin();
1136 fail_com:
1137 #ifndef WIN32
1138 fail_page_size:
1139 #endif /* WIN32 */
1140 fail_start_time:
1141 fail_ctx_init_internal:
1142 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_NOTICE, "grn_init: <%s>: failed", grn_get_version());
1143 grn_query_logger_fin(ctx);
1144 grn_logger_fin(ctx);
1145 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(grn_glock);
1146 grn_alloc_info_fin();
1147 grn_fin_external_libraries();
1148 #ifdef WIN32
1149 grn_windows_fin();
1150 #endif
1151 return rc;
1152 }
1153
1154 grn_encoding
1155 grn_get_default_encoding(void)
1156 {
1157 return grn_gctx.encodingcxx . . $ _grn_ctx#encoding.;
1158 }
1159
1160 grn_rc
1161 grn_set_default_encoding(grn_encoding encoding)
1162 {
1163 switch (encoding) {
1164 case GRN_ENC_DEFAULT:
1165 grn_gctx.encodingcxx . . $ _grn_ctx#encoding. = grn_encoding_parse(GRN_DEFAULT_ENCODINGcxx . . $ `build/config.h:21:9`!);
1166 return GRN_SUCCESS;
1167 case GRN_ENC_NONE:
1168 case GRN_ENC_EUC_JP:
1169 case GRN_ENC_UTF8:
1170 case GRN_ENC_SJIS:
1171 case GRN_ENC_LATIN1:
1172 case GRN_ENC_KOI8R:
1173 grn_gctx.encodingcxx . . $ _grn_ctx#encoding. = encoding;
1174 return GRN_SUCCESS;
1175 default:
1176 return GRN_INVALID_ARGUMENT;
1177 }
1178 }
1179
1180 grn_command_version
1181 grn_get_default_command_version(void)
1182 {
1183 return grn_ctx_get_command_version(&grn_gctx);
1184 }
1185
1186 grn_rc
1187 grn_set_default_command_version(grn_command_version version)
1188 {
1189 return grn_ctx_set_command_version(&grn_gctx, version);
1190 }
1191
1192 int64_t
1193 grn_get_default_match_escalation_threshold(void)
1194 {
1195 return grn_ctx_get_match_escalation_threshold(&grn_gctx);
1196 }
1197
1198 grn_rc
1199 grn_set_default_match_escalation_threshold(int64_t threshold)
1200 {
1201 return grn_ctx_set_match_escalation_threshold(&grn_gctx, threshold);
1202 }
1203
1204 int32_t
1205 grn_get_default_n_workers(void)
1206 {
1207 return grn_n_workers_default;
1208 }
1209
1210 grn_rc
1211 grn_set_default_n_workers(int32_t n_workers)
1212 {
1213 grn_n_workers_default = n_workers;
1214 return GRN_SUCCESS;
1215 }
1216
1217 int
1218 grn_get_lock_timeout(void)
1219 {
1220 return grn_lock_timeout;
1221 }
1222
1223 grn_rc
1224 grn_set_lock_timeout(int timeout)
1225 {
1226 grn_lock_timeout = timeout;
1227 return GRN_SUCCESS;
1228 }
1229
1230 grn_rc
1231 grn_fin(void)
1232 {
1233 grn_ctx *ctx, *ctx_;
1234 if (grn_gctx.statcxx . . $ _grn_ctx#stat. == GRN_CTX_FINcxx . . $ `include/groonga/groonga.h:335:9`!) {
1235 return GRN_INVALID_ARGUMENT;
1236 }
1237 /* Clear ctx pool to avoid double free. */
1238 for (ctx = grn_gctx.nextcxx . . $ _grn_ctx#next.; ctx != &grn_gctx; ctx = ctx->nextcxx . . $ _grn_ctx#next.) {
1239 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
1240 continue;
1241 }
1242 if (GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&(ctx->impl->children.pool)) == 0) {
1243 continue;
1244 }
1245 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&(ctx->impl->children.pool));
1246 }
1247 for (ctx = grn_gctx.nextcxx . . $ _grn_ctx#next.; ctx != &grn_gctx; ctx = ctx_) {
1248 ctx_ = ctx->nextcxx . . $ _grn_ctx#next.;
1249 if (ctx->statcxx . . $ _grn_ctx#stat. != GRN_CTX_FINcxx . . $ `include/groonga/groonga.h:335:9`!) {
1250 grn_ctx_fin(ctx);
1251 }
1252 if (ctx->flagscxx . . $ _grn_ctx#flags. & GRN_CTX_ALLOCATEDcxx . . $ `lib/grn_ctx.h:85:9`!) {
1253 ctx->nextcxx . . $ _grn_ctx#next.->prevcxx . . $ _grn_ctx#prev. = ctx->prevcxx . . $ _grn_ctx#prev.;
1254 ctx->prevcxx . . $ _grn_ctx#prev.->nextcxx . . $ _grn_ctx#next. = ctx->nextcxx . . $ _grn_ctx#next.;
1255 GRN_GFREEcxx . . $ `lib/grn_alloc.h:51:9`!(ctx);
1256 }
1257 }
1258 grn_query_logger_fin(ctx);
1259 grn_request_timer_fin();
1260 grn_request_canceler_fin();
1261 grn_cache_fin();
1262 grn_tokenizers_fin();
1263 grn_normalizer_fin();
1264 grn_plugins_fin();
1265 grn_ctx_fin(ctx);
1266 grn_com_fin();
1267 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_NOTICE, "grn_fin (%u)", grn_alloc_count());
1268 grn_logger_fin(ctx);
1269 CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(grn_glock);
1270 grn_alloc_info_fin();
1271 grn_fin_external_libraries();
1272 #ifdef WIN32
1273 grn_windows_fin();
1274 #endif
1275 return GRN_SUCCESS;
1276 }
1277
1278 grn_rc
1279 grn_ctx_connect(grn_ctx *ctx, const char *host, int port, int flags)
1280 {
1281 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1282 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
1283 goto exit;
1284 }
1285 {
1286 grn_com *com = grn_com_copen(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, host, port);
1287 if (com) {
1288 ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com. = com;
1289 }
1290 }
1291 exit:
1292 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1293 }
1294
1295 grn_rc
1296 grn_ctx_close(grn_ctx *ctx)
1297 {
1298 grn_rc rc = grn_ctx_fin(ctx);
1299 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(grn_glock);
1300 ctx->nextcxx . . $ _grn_ctx#next.->prevcxx . . $ _grn_ctx#prev. = ctx->prevcxx . . $ _grn_ctx#prev.;
1301 ctx->prevcxx . . $ _grn_ctx#prev.->nextcxx . . $ _grn_ctx#next. = ctx->nextcxx . . $ _grn_ctx#next.;
1302 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(grn_glock);
1303 GRN_GFREEcxx . . $ `lib/grn_alloc.h:51:9`!(ctx);
1304 return rc;
1305 }
1306
1307 grn_command_version
1308 grn_ctx_get_command_version(grn_ctx *ctx)
1309 {
1310 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1311 return ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version.;
1312 } else {
1313 return GRN_COMMAND_VERSION_STABLEcxx . . $ `include/groonga/groonga.h:189:9`!;
1314 }
1315 }
1316
1317 grn_rc
1318 grn_ctx_set_command_version(grn_ctx *ctx, grn_command_version version)
1319 {
1320 switch (version) {
1321 case GRN_COMMAND_VERSION_DEFAULT:
1322 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version. = GRN_COMMAND_VERSION_STABLEcxx . . $ `include/groonga/groonga.h:189:9`!;
1323 return GRN_SUCCESS;
1324 default:
1325 if (GRN_COMMAND_VERSION_MINcxx . . $ `include/groonga/groonga.h:188:9`! <= version &&
1326 version <= GRN_COMMAND_VERSION_MAXcxx . . $ `include/groonga/groonga.h:190:9`!) {
1327 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#version. = version;
1328 return GRN_SUCCESS;
1329 } else {
1330 return GRN_UNSUPPORTED_COMMAND_VERSION;
1331 }
1332 }
1333 }
1334
1335 grn_content_type
1336 grn_ctx_get_output_type(grn_ctx *ctx)
1337 {
1338 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1339 return ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.;
1340 } else {
1341 return GRN_CONTENT_NONE;
1342 }
1343 }
1344
1345 grn_rc
1346 grn_ctx_set_output_type(grn_ctx *ctx, grn_content_type type)
1347 {
1348 grn_rc rc = GRN_SUCCESS;
1349
1350 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1351 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = type;
1352 switch (ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.) {
1353 case GRN_CONTENT_NONE:
1354 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/octet-stream";
1355 break;
1356 case GRN_CONTENT_TSV:
1357 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/tab-separated-values";
1358 break;
1359 case GRN_CONTENT_JSON:
1360 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/json";
1361 break;
1362 case GRN_CONTENT_XML:
1363 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/xml";
1364 break;
1365 case GRN_CONTENT_MSGPACK:
1366 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/x-msgpack";
1367 break;
1368 case GRN_CONTENT_GROONGA_COMMAND_LIST:
1369 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/x-groonga-command-list";
1370 break;
1371 case GRN_CONTENT_APACHE_ARROW:
1372 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/x-apache-arrow-streaming";
1373 break;
1374 }
1375 } else {
1376 rc = GRN_INVALID_ARGUMENT;
1377 }
1378
1379 return rc;
1380 }
1381
1382 const char *
1383 grn_ctx_get_mime_type(grn_ctx *ctx)
1384 {
1385 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1386 return ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type.;
1387 } else {
1388 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
1389 }
1390 }
1391
1392 int64_t
1393 grn_ctx_get_match_escalation_threshold(grn_ctx *ctx)
1394 {
1395 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1396 return ctx->implcxx . . $ _grn_ctx#impl.->match_escalation_thresholdcxx . . $ _grn_ctx_impl#match_escalation_threshold.;
1397 } else {
1398 return GRN_DEFAULT_MATCH_ESCALATION_THRESHOLDcxx . . $ `build/config.h:22:9`!;
1399 }
1400 }
1401
1402 grn_rc
1403 grn_ctx_set_match_escalation_threshold(grn_ctx *ctx, int64_t threshold)
1404 {
1405 ctx->implcxx . . $ _grn_ctx#impl.->match_escalation_thresholdcxx . . $ _grn_ctx_impl#match_escalation_threshold. = threshold;
1406 return GRN_SUCCESS;
1407 }
1408
1409 bool
1410 grn_ctx_get_force_match_escalation(grn_ctx *ctx)
1411 {
1412 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1413 return ctx->implcxx . . $ _grn_ctx#impl.->force_match_escalationcxx . . $ _grn_ctx_impl#force_match_escalation.;
1414 } else {
1415 return false;
1416 }
1417 }
1418
1419 grn_rc
1420 grn_ctx_set_force_match_escalation(grn_ctx *ctx, bool force)
1421 {
1422 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1423 ctx->implcxx . . $ _grn_ctx#impl.->force_match_escalationcxx . . $ _grn_ctx_impl#force_match_escalation. = force;
1424 return GRN_SUCCESS;
1425 } else {
1426 return GRN_INVALID_ARGUMENT;
1427 }
1428 }
1429
1430 int32_t
1431 grn_ctx_get_n_workers(grn_ctx *ctx)
1432 {
1433 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1434 return ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers.;
1435 } else {
1436 return grn_n_workers_default;
1437 }
1438 }
1439
1440 grn_rc
1441 grn_ctx_set_n_workers(grn_ctx *ctx, int32_t n_workers)
1442 {
1443 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1444 ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers. = n_workers;
1445 return GRN_SUCCESS;
1446 } else {
1447 return GRN_INVALID_ARGUMENT;
1448 }
1449 }
1450
1451 grn_wal_role
1452 grn_ctx_get_wal_role(grn_ctx *ctx)
1453 {
1454 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1455 return ctx->implcxx . . $ _grn_ctx#impl.->walcxx . . $ _grn_ctx_impl#wal..rolecxx . . $ _grn_ctx_impl#$anonymous_type_7#role.;
1456 } else {
1457 return GRN_WAL_ROLE_NONE;
1458 }
1459 }
1460
1461 grn_rc
1462 grn_ctx_set_wal_role(grn_ctx *ctx, grn_wal_role role)
1463 {
1464 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1465 ctx->implcxx . . $ _grn_ctx#impl.->walcxx . . $ _grn_ctx_impl#wal..rolecxx . . $ _grn_ctx_impl#$anonymous_type_7#role. = role;
1466 return GRN_SUCCESS;
1467 } else {
1468 return GRN_INVALID_ARGUMENT;
1469 }
1470 }
1471
1472 grn_rc
1473 grn_ctx_set_variable(grn_ctx *ctx,
1474 const char *name,
1475 int name_size,
1476 void *data,
1477 grn_close_func close_func)
1478 {
1479 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1480 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
1481 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "[ctx][variable][set] not initialized ctx");
1482 goto exit;
1483 }
1484 if (name_size < 0) {
1485 name_size = (int)strlen(name);
1486 }
1487 if (data) {
1488 void *value;
1489 int added;
1490 grn_id id = grn_hash_add(ctx,
1491 ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables.,
1492 name,
1493 (unsigned int)name_size,
1494 &value,
1495 &added);
1496 if (id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) {
1497 grn_rc rc = ctx->rccxx . . $ _grn_ctx#rc.;
1498 if (rc == GRN_SUCCESS) {
1499 rc = GRN_UNKNOWN_ERROR;
1500 }
1501 ERRcxx . . $ `lib/grn_error.h:156:9`!(rc, "[ctx][variable][set] failed to add variable");
1502 goto exit;
1503 }
1504 auto variable = static_cast<grn_ctx_local_variable *>(value);
1505 if (!added) {
1506 if (variable->close_func) {
1507 variable->close_func(ctx, variable->data);
1508 }
1509 }
1510 variable->data = data;
1511 variable->close_func = close_func;
1512 } else {
1513 void *value;
1514 grn_id id = grn_hash_get(ctx,
1515 ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables.,
1516 name,
1517 (unsigned int)name_size,
1518 &value);
1519 if (id != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) {
1520 auto variable = static_cast<grn_ctx_local_variable *>(value);
1521 if (variable->close_func) {
1522 variable->close_func(ctx, variable->data);
1523 }
1524 grn_hash_delete_by_id(ctx, ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables., id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
1525 }
1526 }
1527 exit:
1528 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1529 }
1530
1531 void *
1532 grn_ctx_get_variable(grn_ctx *ctx, const char *name, int name_size)
1533 {
1534 void *data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
1535 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1536 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
1537 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "[ctx][variable][get] not initialized ctx");
1538 goto exit;
1539 }
1540 if (name_size < 0) {
1541 name_size = (int)strlen(name);
1542 }
1543 {
1544 void *value;
1545 grn_id id = grn_hash_get(ctx,
1546 ctx->implcxx . . $ _grn_ctx#impl.->variablescxx . . $ _grn_ctx_impl#variables.,
1547 name,
1548 (unsigned int)name_size,
1549 &value);
1550 if (id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) {
1551 goto exit;
1552 }
1553 {
1554 auto variable = static_cast<grn_ctx_local_variable *>(value);
1555 data = variable->data;
1556 }
1557 }
1558 exit:
1559 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(data);
1560 }
1561
1562 grn_rc
1563 grn_unset_variable(const char *name, int name_size)
1564 {
1565 grn_rc rc = GRN_SUCCESS;
1566 grn_ctx *ctx = grn_gctx.nextcxx . . $ _grn_ctx#next.;
1567 while (ctx != &grn_gctx) {
1568 if (ctx->implcxx . . $ _grn_ctx#impl.) {
1569 rc = grn_ctx_set_variable(ctx, name, name_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
1570 if (rc != GRN_SUCCESS) {
1571 break;
1572 }
1573 }
1574 CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(grn_glock);
1575 ctx = ctx->nextcxx . . $ _grn_ctx#next.;
1576 CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(grn_glock);
1577 }
1578 return rc;
1579 }
1580
1581 grn_content_type
1582 grn_get_ctype(grn_obj *var)
1583 {
1584 return grn_content_type_parse(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, var, GRN_CONTENT_JSON);
1585 }
1586
1587 grn_content_type
1588 grn_content_type_parse(grn_ctx *ctx,
1589 grn_obj *var,
1590 grn_content_type default_value)
1591 {
1592 grn_content_type ct = default_value;
1593 if (var->headercxx . . $ _grn_obj#header..domain == GRN_DB_INT32) {
1594 ct = static_cast<grn_content_type>(GRN_INT32_VALUEcxx . . $ `include/groonga/groonga.h:3102:9`!(var));
1595 } else {
1596 grn_raw_string input;
1597 GRN_RAW_STRING_SETcxx . . $ `include/groonga/raw_string.h:31:9`!(input, var);
1598 if (GRN_RAW_STRING_EQUAL_CSTRING_CIcxx . . $ `include/groonga/raw_string.h:63:9`!(input, "tsv")) {
1599 ct = GRN_CONTENT_TSV;
1600 } else if (GRN_RAW_STRING_EQUAL_CSTRING_CIcxx . . $ `include/groonga/raw_string.h:63:9`!(input, "json")) {
1601 ct = GRN_CONTENT_JSON;
1602 } else if (GRN_RAW_STRING_EQUAL_CSTRING_CIcxx . . $ `include/groonga/raw_string.h:63:9`!(input, "xml")) {
1603 ct = GRN_CONTENT_XML;
1604 } else if (GRN_RAW_STRING_EQUAL_CSTRING_CIcxx . . $ `include/groonga/raw_string.h:63:9`!(input, "apache-arrow")) {
1605 ct = GRN_CONTENT_APACHE_ARROW;
1606 }
1607 }
1608 return ct;
1609 }
1610
1611 static void
1612 get_content_mime_type(grn_ctx *ctx, const char *p, const char *pe)
1613 {
1614 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1615 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/octet-stream";
1616
1617 grn_raw_string type;
1618 type.value = p;
1619 type.length = (size_t)(pe - p);
1620
1621 if (type.length < 2) {
1622 return;
1623 }
1624
1625 switch (type.value[0]) {
1626 case 'c':
1627 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "css")) {
1628 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1629 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/css";
1630 }
1631 break;
1632 case 'g':
1633 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "gif")) {
1634 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1635 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "image/gif";
1636 }
1637 break;
1638 case 'h':
1639 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "html")) {
1640 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1641 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/html";
1642 }
1643 break;
1644 case 'j':
1645 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "js")) {
1646 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1647 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/javascript";
1648 } else if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "json")) {
1649 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_JSON;
1650 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/json";
1651 } else if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "jpg") ||
1652 GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "jpeg")) {
1653 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1654 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "image/jpeg";
1655 }
1656 break;
1657 #ifdef GRN_WITH_MESSAGE_PACKcxx . . $ `build/config.h:108:9`!
1658 case 'm':
1659 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "msgpack")) {
1660 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_MSGPACK;
1661 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/x-msgpack";
1662 }
1663 break;
1664 #endif
1665 #ifdef GRN_WITH_APACHE_ARROW
1666 case 'a':
1667 if (GRN_RAW_STRING_EQUAL_CSTRING(type, "arrows")) {
1668 ctx->impl->output.type = GRN_CONTENT_APACHE_ARROW;
1669 ctx->impl->output.mime_type = "application/vnd.apache.arrow.stream";
1670 } else if (GRN_RAW_STRING_EQUAL_CSTRING(type, "arrow") ||
1671 GRN_RAW_STRING_EQUAL_CSTRING(type, "apache-arrow")) {
1672 ctx->impl->output.type = GRN_CONTENT_APACHE_ARROW;
1673 ctx->impl->output.mime_type = "application/x-apache-arrow-streaming";
1674 }
1675 break;
1676 #endif
1677 case 'p':
1678 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "png")) {
1679 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1680 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "image/png";
1681 }
1682 break;
1683 case 't':
1684 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "txt")) {
1685 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_NONE;
1686 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/plain";
1687 } else if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "tsv")) {
1688 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_TSV;
1689 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/tab-separated-values";
1690 }
1691 break;
1692 case 'x':
1693 if (GRN_RAW_STRING_EQUAL_CSTRINGcxx . . $ `include/groonga/raw_string.h:57:9`!(type, "xml")) {
1694 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_XML;
1695 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "text/xml";
1696 }
1697 break;
1698 }
1699 }
1700
1701 static void
1702 grn_str_get_mime_type(grn_ctx *ctx,
1703 const char *p,
1704 const char *pe,
1705 const char **key_end,
1706 const char **filename_end)
1707 {
1708 const char *pd = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
1709 for (; p < pe && *p != '?' && *p != '#'; p++) {
1710 if (*p == '.') {
1711 pd = p;
1712 }
1713 }
1714 *filename_end = p;
1715 if (pd && pd < p) {
1716 get_content_mime_type(ctx, pd + 1, p);
1717 *key_end = pd;
1718 } else {
1719 *key_end = pe;
1720 }
1721 }
1722
1723 static void
1724 get_command_version(grn_ctx *ctx, const char *p, const char *pe)
1725 {
1726 grn_command_version version;
1727 const char *rest;
1728
1729 version = static_cast<grn_command_version>(grn_atoui(p, pe, &rest));
1730 if (pe == rest) {
1731 grn_rc rc;
1732 rc = grn_ctx_set_command_version(ctx, version);
1733 if (rc == GRN_UNSUPPORTED_COMMAND_VERSION) {
1734 ERRcxx . . $ `lib/grn_error.h:156:9`!(rc,
1735 "unsupported command version is specified: %d: "
1736 "stable command version: %d: "
1737 "available command versions: %d-%d",
1738 version,
1739 GRN_COMMAND_VERSION_STABLEcxx . . $ `include/groonga/groonga.h:189:9`!,
1740 GRN_COMMAND_VERSION_MINcxx . . $ `include/groonga/groonga.h:188:9`!,
1741 GRN_COMMAND_VERSION_MAXcxx . . $ `include/groonga/groonga.h:190:9`!);
1742 }
1743 }
1744 }
1745
1746 static void
1747 get_n_workers(grn_ctx *ctx, const char *p, const char *pe)
1748 {
1749 const char *rest;
1750 int32_t n_workers = grn_atoi(p, pe, &rest);
1751 if (pe == rest) {
1752 grn_ctx_set_n_workers(ctx, n_workers);
1753 }
1754 }
1755
1756 #define INDEX_HTMLcxx . . $ `lib/ctx.cpp:1756:9`! "index.html"
1757 #define OUTPUT_TYPEcxx . . $ `lib/ctx.cpp:1757:9`! "output_type"
1758 #define COMMAND_VERSIONcxx . . $ `lib/ctx.cpp:1758:9`! "command_version"
1759 #define REQUEST_IDcxx . . $ `lib/ctx.cpp:1759:9`! "request_id"
1760 #define REQUEST_TIMEOUTcxx . . $ `lib/ctx.cpp:1760:9`! "request_timeout"
1761 #define OUTPUT_PRETTYcxx . . $ `lib/ctx.cpp:1761:9`! "output_pretty"
1762 #define OUTPUT_TRACE_LOGcxx . . $ `lib/ctx.cpp:1762:9`! "output_trace_log"
1763 #define N_WORKERScxx . . $ `lib/ctx.cpp:1763:9`! "n_workers"
1764 #define EXPR_MISSINGcxx . . $ `lib/ctx.cpp:1764:9`! "expr_missing"
1765 #define OUTPUT_TYPE_LENcxx . . $ `lib/ctx.cpp:1765:9`! (sizeof(OUTPUT_TYPEcxx . . $ `lib/ctx.cpp:1757:9`!) - 1)
1766 #define COMMAND_VERSION_LENcxx . . $ `lib/ctx.cpp:1766:9`! (sizeof(COMMAND_VERSIONcxx . . $ `lib/ctx.cpp:1758:9`!) - 1)
1767 #define REQUEST_ID_LENcxx . . $ `lib/ctx.cpp:1767:9`! (sizeof(REQUEST_IDcxx . . $ `lib/ctx.cpp:1759:9`!) - 1)
1768 #define REQUEST_TIMEOUT_LENcxx . . $ `lib/ctx.cpp:1768:9`! (sizeof(REQUEST_TIMEOUTcxx . . $ `lib/ctx.cpp:1760:9`!) - 1)
1769 #define OUTPUT_PRETTY_LENcxx . . $ `lib/ctx.cpp:1769:9`! (sizeof(OUTPUT_PRETTYcxx . . $ `lib/ctx.cpp:1761:9`!) - 1)
1770 #define OUTPUT_TRACE_LOG_LENcxx . . $ `lib/ctx.cpp:1770:9`! (sizeof(OUTPUT_TRACE_LOGcxx . . $ `lib/ctx.cpp:1762:9`!) - 1)
1771 #define N_WORKERS_LENcxx . . $ `lib/ctx.cpp:1771:9`! (sizeof(N_WORKERScxx . . $ `lib/ctx.cpp:1763:9`!) - 1)
1772
1773 #define HTTP_QUERY_PAIR_DELIMITERcxx . . $ `lib/ctx.cpp:1773:9`! "="
1774 #define HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`! "&;"
1775
1776 static inline int
1777 command_proc_p(grn_obj *expr)
1778 {
1779 return (expr->headercxx . . $ _grn_obj#header..type == GRN_PROCcxx . . $ `include/groonga/groonga.h:893:9`! &&
1780 ((grn_proc *)expr)->typecxx . . $ _grn_proc#type. == GRN_PROC_COMMAND);
1781 }
1782
1783 grn_obj *
1784 grn_ctx_qe_exec_uri(grn_ctx *ctx, const char *path, uint32_tcxx . . $ uint32_t# path_len)
1785 {
1786 grn_obj buf, *expr, *val;
1787 grn_obj request_id;
1788 double request_timeout;
1789 const char *p = path, *e = path + path_len, *v, *key_end, *filename_end;
1790
1791 request_timeout = grn_get_default_request_timeout();
1792
1793 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&buf, 0);
1794 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&request_id, 0);
1795 p = grn_text_urldec(ctx, &buf, p, e, '?');
1796 if (!GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf)) {
1797 GRN_TEXT_SETScxx . . $ `include/groonga/groonga.h:2783:9`!(ctx, &buf, INDEX_HTMLcxx . . $ `lib/ctx.cpp:1756:9`!);
1798 }
1799 v = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf);
1800 grn_str_get_mime_type(ctx, v, GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&buf), &key_end, &filename_end);
1801 if ((GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf) >= 2 && v[0] == 'd' && v[1] == '/')) {
1802 const char *command_name = v + 2;
1803 ptrdiff_t command_name_size = key_end - command_name;
1804 expr = grn_ctx_get(ctx, command_name, (int)command_name_size);
1805 if (expr && command_proc_p(expr)) {
1806 while (p < e) {
1807 size_t l;
1808 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1809 p = grn_text_cgidec(ctx, &buf, p, e, HTTP_QUERY_PAIR_DELIMITERcxx . . $ `lib/ctx.cpp:1773:9`!);
1810 v = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf);
1811 l = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf);
1812 if (l == OUTPUT_TYPE_LENcxx . . $ `lib/ctx.cpp:1765:9`! && !memcmp(v, OUTPUT_TYPEcxx . . $ `lib/ctx.cpp:1757:9`!, OUTPUT_TYPE_LENcxx . . $ `lib/ctx.cpp:1765:9`!)) {
1813 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1814 p = grn_text_cgidec(ctx, &buf, p, e, HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1815 v = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf);
1816 get_content_mime_type(ctx, v, GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&buf));
1817 } else if (l == COMMAND_VERSION_LENcxx . . $ `lib/ctx.cpp:1766:9`! &&
1818 !memcmp(v, COMMAND_VERSIONcxx . . $ `lib/ctx.cpp:1758:9`!, COMMAND_VERSION_LENcxx . . $ `lib/ctx.cpp:1766:9`!)) {
1819 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1820 p = grn_text_cgidec(ctx, &buf, p, e, HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1821 get_command_version(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&buf));
1822 if (ctx->rccxx . . $ _grn_ctx#rc.) {
1823 goto exit;
1824 }
1825 } else if (l == REQUEST_ID_LENcxx . . $ `lib/ctx.cpp:1767:9`! &&
1826 !memcmp(v, REQUEST_IDcxx . . $ `lib/ctx.cpp:1759:9`!, REQUEST_ID_LENcxx . . $ `lib/ctx.cpp:1767:9`!)) {
1827 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&request_id);
1828 p = grn_text_cgidec(ctx,
1829 &request_id,
1830 p,
1831 e,
1832 HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1833 } else if (l == REQUEST_TIMEOUT_LENcxx . . $ `lib/ctx.cpp:1768:9`! &&
1834 !memcmp(v, REQUEST_TIMEOUTcxx . . $ `lib/ctx.cpp:1760:9`!, REQUEST_TIMEOUT_LENcxx . . $ `lib/ctx.cpp:1768:9`!)) {
1835 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1836 p = grn_text_cgidec(ctx, &buf, p, e, HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1837 GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &buf, '\0');
1838 request_timeout = strtodcxx . . $ strtod(d6476bb9e2fdf17c).(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
1839 } else if (l == OUTPUT_PRETTY_LENcxx . . $ `lib/ctx.cpp:1769:9`! &&
1840 !memcmp(v, OUTPUT_PRETTYcxx . . $ `lib/ctx.cpp:1761:9`!, OUTPUT_PRETTY_LENcxx . . $ `lib/ctx.cpp:1769:9`!)) {
1841 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1842 p = grn_text_cgidec(ctx, &buf, p, e, HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1843 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf) == strlen("yes") &&
1844 !memcmp(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), "yes", GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf))) {
1845 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..is_prettycxx . . $ _grn_ctx_impl#$anonymous_type_0#is_pretty. = true;
1846 } else {
1847 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..is_prettycxx . . $ _grn_ctx_impl#$anonymous_type_0#is_pretty. = false;
1848 }
1849 } else if (l == OUTPUT_TRACE_LOG_LENcxx . . $ `lib/ctx.cpp:1770:9`! &&
1850 !memcmp(v, OUTPUT_TRACE_LOGcxx . . $ `lib/ctx.cpp:1762:9`!, OUTPUT_TRACE_LOG_LENcxx . . $ `lib/ctx.cpp:1770:9`!)) {
1851 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1852 p = grn_text_cgidec(ctx, &buf, p, e, HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1853 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf) == strlen("yes") &&
1854 !memcmp(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), "yes", GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf))) {
1855 grn_ctx_trace_log_enable(ctx);
1856 } else {
1857 grn_ctx_trace_log_disable(ctx);
1858 }
1859 } else if (l == N_WORKERS_LENcxx . . $ `lib/ctx.cpp:1771:9`! && !memcmp(v, N_WORKERScxx . . $ `lib/ctx.cpp:1763:9`!, N_WORKERS_LENcxx . . $ `lib/ctx.cpp:1771:9`!)) {
1860 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1861 p = grn_text_cgidec(ctx, &buf, p, e, HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1862 get_n_workers(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&buf));
1863 } else {
1864 if (!(val = grn_expr_get_or_add_var(ctx, expr, v, (unsigned int)l))) {
1865 val = &buf;
1866 }
1867 grn_obj_reinit(ctx, val, GRN_DB_TEXT, 0);
1868 p = grn_text_cgidec(ctx, val, p, e, HTTP_QUERY_PAIRS_DELIMITERScxx . . $ `lib/ctx.cpp:1774:9`!);
1869 }
1870 }
1871 if (request_timeout > 0 && GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id) == 0) {
1872 grn_text_printf(ctx, &request_id, "%p", ctx);
1873 }
1874 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id) > 0) {
1875 GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx,
1876 &ctx->impl->current_request_id,
1877 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&request_id),
1878 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id));
1879 grn_request_canceler_register(ctx,
1880 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&request_id),
1881 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id));
1882 if (request_timeout > 0.0) {
1883 ctx->implcxx . . $ _grn_ctx#impl.->current_request_timer_idcxx . . $ _grn_ctx_impl#current_request_timer_id. =
1884 grn_request_timer_register(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&request_id),
1885 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id),
1886 request_timeout);
1887 }
1888 }
1889 ctx->implcxx . . $ _grn_ctx#impl.->curr_exprcxx . . $ _grn_ctx_impl#curr_expr. = expr;
1890 grn_expr_exec(ctx, expr, 0);
1891 } else {
1892 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT,
1893 "invalid command name: %.*s",
1894 (int)command_name_size,
1895 command_name);
1896 }
1897 } else if ((expr = grn_ctx_get(ctx,
1898 GRN_EXPR_MISSING_NAMEcxx . . $ `lib/grn_ctx_impl.h:44:9`!,
1899 strlen(GRN_EXPR_MISSING_NAMEcxx . . $ `lib/grn_ctx_impl.h:44:9`!)))) {
1900 if ((val = grn_expr_get_var_by_offset(ctx, expr, 0))) {
1901 grn_obj_reinit(ctx, val, GRN_DB_TEXT, 0);
1902 GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, val, v, filename_end - v);
1903 }
1904 ctx->implcxx . . $ _grn_ctx#impl.->curr_exprcxx . . $ _grn_ctx_impl#curr_expr. = expr;
1905 grn_expr_exec(ctx, expr, 0);
1906 }
1907 exit:
1908 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &request_id);
1909 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &buf);
1910
1911 return expr;
1912 }
1913
1914 grn_obj *
1915 grn_ctx_qe_exec(grn_ctx *ctx, const char *str, uint32_tcxx . . $ uint32_t# str_len)
1916 {
1917 uint8_tcxx . . $ uint8_t# tok_type;
1918 unsigned int offset = 0;
1919 grn_obj buf, *expr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, *val = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
1920 grn_obj request_id;
1921 double request_timeout;
1922 const char *p = str, *e = str + str_len, *v;
1923
1924 request_timeout = grn_get_default_request_timeout();
1925
1926 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&buf, 0);
1927 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&request_id, 0);
1928 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1929 expr = grn_ctx_get(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf));
1930 while (p < e) {
1931 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1932 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1933 v = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf);
1934 switch (tok_type) {
1935 case GRN_TOK_VOIDcxx . . $ `lib/grn_str.h:140:9`!:
1936 p = e;
1937 break;
1938 case GRN_TOK_SYMBOLcxx . . $ `lib/grn_str.h:141:9`!:
1939 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf) > 2 && v[0] == '-' && v[1] == '-') {
1940 size_t l = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf) - 2;
1941 v += 2;
1942 if (l == OUTPUT_TYPE_LENcxx . . $ `lib/ctx.cpp:1765:9`! && !memcmp(v, OUTPUT_TYPEcxx . . $ `lib/ctx.cpp:1757:9`!, OUTPUT_TYPE_LENcxx . . $ `lib/ctx.cpp:1765:9`!)) {
1943 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1944 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1945 v = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf);
1946 get_content_mime_type(ctx, v, GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&buf));
1947 } else if (l == COMMAND_VERSION_LENcxx . . $ `lib/ctx.cpp:1766:9`! &&
1948 !memcmp(v, COMMAND_VERSIONcxx . . $ `lib/ctx.cpp:1758:9`!, COMMAND_VERSION_LENcxx . . $ `lib/ctx.cpp:1766:9`!)) {
1949 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1950 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1951 get_command_version(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&buf));
1952 if (ctx->rccxx . . $ _grn_ctx#rc.) {
1953 goto exit;
1954 }
1955 } else if (l == REQUEST_ID_LENcxx . . $ `lib/ctx.cpp:1767:9`! &&
1956 !memcmp(v, REQUEST_IDcxx . . $ `lib/ctx.cpp:1759:9`!, REQUEST_ID_LENcxx . . $ `lib/ctx.cpp:1767:9`!)) {
1957 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&request_id);
1958 p = grn_text_unesc_tok(ctx, &request_id, p, e, &tok_type);
1959 } else if (l == REQUEST_TIMEOUT_LENcxx . . $ `lib/ctx.cpp:1768:9`! &&
1960 !memcmp(v, REQUEST_TIMEOUTcxx . . $ `lib/ctx.cpp:1760:9`!, REQUEST_TIMEOUT_LENcxx . . $ `lib/ctx.cpp:1768:9`!)) {
1961 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1962 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1963 GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &buf, '\0');
1964 request_timeout = strtodcxx . . $ strtod(d6476bb9e2fdf17c).(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
1965 } else if (l == OUTPUT_PRETTY_LENcxx . . $ `lib/ctx.cpp:1769:9`! &&
1966 !memcmp(v, OUTPUT_PRETTYcxx . . $ `lib/ctx.cpp:1761:9`!, OUTPUT_PRETTY_LENcxx . . $ `lib/ctx.cpp:1769:9`!)) {
1967 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1968 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1969 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf) == strlen("yes") &&
1970 !memcmp(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), "yes", GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf))) {
1971 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..is_prettycxx . . $ _grn_ctx_impl#$anonymous_type_0#is_pretty. = true;
1972 } else {
1973 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..is_prettycxx . . $ _grn_ctx_impl#$anonymous_type_0#is_pretty. = false;
1974 }
1975 } else if (l == OUTPUT_TRACE_LOG_LENcxx . . $ `lib/ctx.cpp:1770:9`! &&
1976 !memcmp(v, OUTPUT_TRACE_LOGcxx . . $ `lib/ctx.cpp:1762:9`!, OUTPUT_TRACE_LOG_LENcxx . . $ `lib/ctx.cpp:1770:9`!)) {
1977 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1978 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1979 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf) == strlen("yes") &&
1980 !memcmp(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), "yes", GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf))) {
1981 grn_ctx_trace_log_enable(ctx);
1982 } else {
1983 grn_ctx_trace_log_disable(ctx);
1984 }
1985 } else if (l == N_WORKERS_LENcxx . . $ `lib/ctx.cpp:1771:9`! && !memcmp(v, N_WORKERScxx . . $ `lib/ctx.cpp:1763:9`!, N_WORKERS_LENcxx . . $ `lib/ctx.cpp:1771:9`!)) {
1986 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
1987 p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type);
1988 get_n_workers(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), GRN_BULK_CURRcxx . . $ `include/groonga/groonga.h:2650:9`!(&buf));
1989 } else if (expr &&
1990 (val =
1991 grn_expr_get_or_add_var(ctx, expr, v, (unsigned int)l))) {
1992 grn_obj_reinit(ctx, val, GRN_DB_TEXT, 0);
1993 p = grn_text_unesc_tok(ctx, val, p, e, &tok_type);
1994 } else {
1995 p = e;
1996 }
1997 break;
1998 }
1999 // fallthru
2000 case GRN_TOK_STRINGcxx . . $ `lib/grn_str.h:142:9`!:
2001 case GRN_TOK_QUOTEcxx . . $ `lib/grn_str.h:143:9`!:
2002 if (expr && (val = grn_expr_get_var_by_offset(ctx, expr, offset++))) {
2003 grn_obj_reinit(ctx, val, GRN_DB_TEXT, 0);
2004 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, val, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf));
2005 } else {
2006 p = e;
2007 }
2008 break;
2009 }
2010 }
2011 if (request_timeout > 0 && GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id) == 0) {
2012 grn_text_printf(ctx, &request_id, "%p", ctx);
2013 }
2014 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id) > 0) {
2015 GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx,
2016 &ctx->impl->current_request_id,
2017 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&request_id),
2018 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id));
2019 grn_request_canceler_register(ctx,
2020 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&request_id),
2021 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id));
2022 if (request_timeout > 0.0) {
2023 ctx->implcxx . . $ _grn_ctx#impl.->current_request_timer_idcxx . . $ _grn_ctx_impl#current_request_timer_id. =
2024 grn_request_timer_register(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&request_id),
2025 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&request_id),
2026 request_timeout);
2027 }
2028 }
2029 ctx->implcxx . . $ _grn_ctx#impl.->curr_exprcxx . . $ _grn_ctx_impl#curr_expr. = expr;
2030 if (expr && command_proc_p(expr)) {
2031 grn_expr_exec(ctx, expr, 0);
2032 } else {
2033 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&buf);
2034 grn_text_unesc_tok(ctx, &buf, str, str + str_len, &tok_type);
2035 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf)) {
2036 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT,
2037 "invalid command name: %.*s",
2038 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf),
2039 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf));
2040 }
2041 }
2042 exit:
2043 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &request_id);
2044 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &buf);
2045
2046 return expr;
2047 }
2048
2049 grn_rc
2050 grn_ctx_sendv(grn_ctx *ctx, int argc, char **argv, int flags)
2051 {
2052 grn_obj buf;
2053 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
2054 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&buf, 0);
2055 while (argc--) {
2056 // todo : encode into json like syntax
2057 GRN_TEXT_PUTScxx . . $ `include/groonga/groonga.h:2781:9`!(ctx, &buf, *argv);
2058 argv++;
2059 if (argc) {
2060 GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &buf, ' ');
2061 }
2062 }
2063 grn_ctx_send(ctx,
2064 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&buf),
2065 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&buf),
2066 flags);
2067 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &buf);
2068 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
2069 }
2070
2071 static bool
2072 comment_command_p(const char *command, unsigned int length)
2073 {
2074 const char *p, *e;
2075
2076 e = command + length;
2077 for (p = command; p < e; p++) {
2078 switch (*p) {
2079 case '#':
2080 return true;
2081 case ' ':
2082 case '\t':
2083 break;
2084 default:
2085 return false;
2086 }
2087 }
2088 return false;
2089 }
2090
2091 unsigned int
2092 grn_ctx_send(grn_ctx *ctx, const char *str, unsigned int str_len, int flags)
2093 {
2094 if (!ctx) {
2095 return 0;
2096 }
2097 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
2098 if (ctx->implcxx . . $ _grn_ctx#impl.) {
2099 if ((flags & GRN_CTX_MOREcxx . . $ `include/groonga/groonga.h:3293:9`!)) {
2100 flags |= GRN_CTX_QUIETcxx . . $ `include/groonga/groonga.h:3296:9`!;
2101 }
2102 if (ctx->statcxx . . $ _grn_ctx#stat. == GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!) {
2103 flags |= GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!;
2104 }
2105
2106 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..flagscxx . . $ _grn_ctx_impl#$anonymous_type_3#flags. = flags;
2107 if (ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com.) {
2108 grn_rc rc;
2109 grn_com_header sheader;
2110 grn_timeval_now(ctx, &ctx->implcxx . . $ _grn_ctx#impl.->tvcxx . . $ _grn_ctx_impl#tv.);
2111 sheader.protocxx . . $ _grn_com_header#proto. = GRN_COM_PROTO_GQTPcxx . . $ `lib/grn_com.h:168:9`!;
2112 sheader.qtypecxx . . $ _grn_com_header#qtype. = 0;
2113 sheader.keylencxx . . $ _grn_com_header#keylen. = 0;
2114 sheader.levelcxx . . $ _grn_com_header#level. = 0;
2115 sheader.flagscxx . . $ _grn_com_header#flags. = (uint8_tcxx . . $ uint8_t#)flags;
2116 sheader.statuscxx . . $ _grn_com_header#status. = 0;
2117 sheader.opaquecxx . . $ _grn_com_header#opaque. = 0;
2118 sheader.cascxx . . $ _grn_com_header#cas. = 0;
2119 if ((rc = grn_com_send(ctx,
2120 ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com.,
2121 &sheader,
2122 (char *)str,
2123 str_len,
2124 0))) {
2125 ERRcxx . . $ `lib/grn_error.h:156:9`!(rc, "grn_com_send failed");
2126 }
2127 goto exit;
2128 } else {
2129 grn_obj *expr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
2130 bool is_comment = false;
2131 bool processed = false;
2132
2133 grn_command_version command_version = grn_ctx_get_command_version(ctx);
2134 int32_t n_workers = grn_ctx_get_n_workers(ctx);
2135 if (ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..commandcxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#command.) {
2136 grn_obj *val;
2137 expr = ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..commandcxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#command.;
2138 ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..commandcxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#command. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
2139 grn_ctx_set_command_version(ctx, ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..versioncxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#version.);
2140 grn_ctx_set_n_workers(ctx, ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#n_workers.);
2141 if ((val = grn_expr_get_var_by_offset(ctx, expr, 0))) {
2142 grn_obj_reinit(ctx, val, GRN_DB_TEXT, 0);
2143 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, val, str, str_len);
2144 }
2145 grn_expr_exec(ctx, expr, 0);
2146 } else if (comment_command_p(str, str_len)) {
2147 is_comment = true;
2148 } else {
2149 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(ctx->impl->output.buf);
2150 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&(ctx->impl->output.levels));
2151 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = GRN_CONTENT_JSON;
2152 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..mime_typecxx . . $ _grn_ctx_impl#$anonymous_type_0#mime_type. = "application/json";
2153 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..is_prettycxx . . $ _grn_ctx_impl#$anonymous_type_0#is_pretty. = false;
2154 grn_timeval_now(ctx, &ctx->implcxx . . $ _grn_ctx#impl.->tvcxx . . $ _grn_ctx_impl#tv.);
2155 GRN_QUERY_LOGcxx . . $ `include/groonga/groonga.h:2585:9`!(ctx, GRN_QUERY_LOG_COMMANDcxx . . $ `include/groonga/groonga.h:212:9`!, ">", "%.*s", str_len, str);
2156 if (str_len && *str == '/') {
2157 expr = grn_ctx_qe_exec_uri(ctx, str + 1, str_len - 1);
2158 } else {
2159 expr = grn_ctx_qe_exec(ctx, str, str_len);
2160 }
2161 }
2162 if (ctx->statcxx . . $ _grn_ctx#stat. == GRN_CTX_QUITTINGcxx . . $ `lib/grn_ctx_impl.h:49:9`!) {
2163 ctx->statcxx . . $ _grn_ctx#stat. = GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!;
2164 }
2165 if (!is_comment) {
2166 if (ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..keepcxx . . $ _grn_ctx_impl#$anonymous_type_3#keep..commandcxx . . $ _grn_ctx_impl#$anonymous_type_3#$anonymous_type_4#command.) {
2167 ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx);
2168 } else {
2169 if (ctx->implcxx . . $ _grn_ctx#impl.->current_request_timer_idcxx . . $ _grn_ctx_impl#current_request_timer_id.) {
2170 void *timer_id = ctx->implcxx . . $ _grn_ctx#impl.->current_request_timer_idcxx . . $ _grn_ctx_impl#current_request_timer_id.;
2171 ctx->implcxx . . $ _grn_ctx#impl.->current_request_timer_idcxx . . $ _grn_ctx_impl#current_request_timer_id. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
2172 grn_request_timer_unregister(timer_id);
2173 }
2174 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&ctx->impl->current_request_id) > 0) {
2175 grn_obj *request_id = &ctx->implcxx . . $ _grn_ctx#impl.->current_request_idcxx . . $ _grn_ctx_impl#current_request_id.;
2176 grn_request_canceler_unregister(
2177 ctx,
2178 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(request_id),
2179 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(request_id));
2180 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&ctx->impl->current_request_id);
2181 }
2182 processed = true;
2183 }
2184 }
2185 if (!(ctx->implcxx . . $ _grn_ctx#impl.->commandcxx . . $ _grn_ctx_impl#command..flagscxx . . $ _grn_ctx_impl#$anonymous_type_3#flags. & GRN_CTX_QUIETcxx . . $ `include/groonga/groonga.h:3296:9`!) &&
2186 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..funccxx . . $ _grn_ctx_impl#$anonymous_type_0#func.) {
2187 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..funccxx . . $ _grn_ctx_impl#$anonymous_type_0#func.(ctx, GRN_CTX_TAILcxx . . $ `include/groonga/groonga.h:3294:9`!, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..datacxx . . $ _grn_ctx_impl#$anonymous_type_0#data..ptrcxx . . $ _grn_ctx_impl#$anonymous_type_0#$anonymous_type_1#ptr.);
2188 }
2189 if (processed) {
2190 GRN_QUERY_LOGcxx . . $ `include/groonga/groonga.h:2585:9`!(ctx, GRN_QUERY_LOG_RESULT_CODEcxx . . $ `include/groonga/groonga.h:213:9`!, "<", "rc=%d", ctx->rc);
2191 grn_ctx_trace_log_disable(ctx);
2192 }
2193 if (expr) {
2194 grn_expr_clear_vars(ctx, expr);
2195 }
2196 grn_ctx_set_command_version(ctx, command_version);
2197 grn_ctx_set_n_workers(ctx, n_workers);
2198 if (processed) {
2199 grn_db_command_processed(ctx, ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.);
2200 }
2201 goto exit;
2202 }
2203 }
2204 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "invalid ctx assigned");
2205 exit:
2206 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(0);
2207 }
2208
2209 grn_rc
2210 grn_ctx_recv(grn_ctx *ctx, char **str, unsigned int *str_len, int *flags)
2211 {
2212 if (!ctx) {
2213 return GRN_INVALID_ARGUMENT;
2214 }
2215
2216 *flags = 0;
2217
2218 if (ctx->statcxx . . $ _grn_ctx#stat. == GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!) {
2219 bool have_buffer = false;
2220
2221 if (ctx->implcxx . . $ _grn_ctx#impl. && !ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com. &&
2222 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(ctx->impl->output.buf) > 0) {
2223 have_buffer = true;
2224 }
2225
2226 *flags = GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!;
2227 if (!have_buffer) {
2228 *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
2229 *str_len = 0;
2230 return GRN_SUCCESS;
2231 }
2232 }
2233
2234 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
2235 if (ctx->implcxx . . $ _grn_ctx#impl.) {
2236 if (ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com.) {
2237 grn_com_header header;
2238 if (grn_com_recv(ctx, ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com., &header, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.)) {
2239 *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
2240 *str_len = 0;
2241 *flags = 0;
2242 } else {
2243 *str = GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(ctx->impl->output.buf);
2244 *str_len = (unsigned int)GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(ctx->impl->output.buf);
2245 if (header.flagscxx . . $ _grn_com_header#flags. & GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!) {
2246 ctx->statcxx . . $ _grn_ctx#stat. = GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!;
2247 *flags = GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!;
2248 } else {
2249 if (!(header.flagscxx . . $ _grn_com_header#flags. & GRN_CTX_TAILcxx . . $ `include/groonga/groonga.h:3294:9`!)) {
2250 *flags = GRN_CTX_MOREcxx . . $ `include/groonga/groonga.h:3293:9`!;
2251 }
2252 }
2253 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type. = static_cast<grn_content_type>(header.qtypecxx . . $ _grn_com_header#qtype.);
2254 ctx->rccxx . . $ _grn_ctx#rc. =
2255 static_cast<grn_rc>(static_cast<int16_t>(ntohscxx . . $ `<external>/9581057695539925927/in.h:429:12`!(header.status)));
2256 ctx->errbufcxx . . $ _grn_ctx#errbuf.[0] = '\0';
2257 ctx->errlinecxx . . $ _grn_ctx#errline. = 0;
2258 ctx->errfilecxx . . $ _grn_ctx#errfile. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
2259 ctx->errfunccxx . . $ _grn_ctx#errfunc. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!;
2260 }
2261 goto exit;
2262 } else {
2263 grn_obj *buf = ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.;
2264 *str = GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(buf);
2265 *str_len = (unsigned int)GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(buf);
2266 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(ctx->impl->output.buf);
2267 goto exit;
2268 }
2269 }
2270 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "invalid ctx assigned");
2271 exit:
2272 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(GRN_SUCCESS);
2273 }
2274
2275 void
2276 grn_ctx_stream_out_func(grn_ctx *ctx, int flags, void *stream)
2277 {
2278 if (ctx && ctx->implcxx . . $ _grn_ctx#impl.) {
2279 grn_obj *buf = ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.;
2280 size_t size = GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(buf);
2281 if (size) {
2282 if (fwrite(GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(buf), 1, size, (FILE *)stream)) {
2283 fputc('\n', (FILE *)stream);
2284 fflush((FILE *)stream);
2285 }
2286 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(buf);
2287 }
2288 }
2289 }
2290
2291 void
2292 grn_ctx_recv_handler_set(grn_ctx *ctx,
2293 grn_recv_handler_func func,
2294 void *func_arg)
2295 {
2296 if (ctx && ctx->implcxx . . $ _grn_ctx#impl.) {
2297 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..funccxx . . $ _grn_ctx_impl#$anonymous_type_0#func. = func;
2298 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..datacxx . . $ _grn_ctx_impl#$anonymous_type_0#data..ptrcxx . . $ _grn_ctx_impl#$anonymous_type_0#$anonymous_type_1#ptr. = func_arg;
2299 }
2300 }
2301
2302 grn_rc
2303 grn_ctx_info_get(grn_ctx *ctx, grn_ctx_info *info)
2304 {
2305 if (!ctx || !ctx->implcxx . . $ _grn_ctx#impl.) {
2306 return GRN_INVALID_ARGUMENT;
2307 }
2308 if (ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com.) {
2309 info->fdcxx . . $ _grn_ctx_info#fd. = ctx->implcxx . . $ _grn_ctx#impl.->comcxx . . $ _grn_ctx_impl#com.->fdcxx . . $ _grn_com#fd.;
2310 info->com_statuscxx . . $ _grn_ctx_info#com_status. = ctx->implcxx . . $ _grn_ctx#impl.->com_statuscxx . . $ _grn_ctx_impl#com_status.;
2311 info->outbufcxx . . $ _grn_ctx_info#outbuf. = ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.;
2312 info->statcxx . . $ _grn_ctx_info#stat. = ctx->statcxx . . $ _grn_ctx#stat.;
2313 } else {
2314 info->fdcxx . . $ _grn_ctx_info#fd. = -1;
2315 info->com_statuscxx . . $ _grn_ctx_info#com_status. = 0;
2316 info->outbufcxx . . $ _grn_ctx_info#outbuf. = ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.;
2317 info->statcxx . . $ _grn_ctx_info#stat. = ctx->statcxx . . $ _grn_ctx#stat.;
2318 }
2319 return GRN_SUCCESS;
2320 }
2321
2322 #define DB_Pcxx . . $ `lib/ctx.cpp:2322:9`!(s) ((s) && (s)->header.type == GRN_DBcxx . . $ `include/groonga/groonga.h:899:9`!)
2323
2324 grn_rc
2325 grn_ctx_use(grn_ctx *ctx, grn_obj *db)
2326 {
2327 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
2328 if (db && !DB_Pcxx . . $ `lib/ctx.cpp:2322:9`!(db)) {
2329 ctx->rccxx . . $ _grn_ctx#rc. = GRN_INVALID_ARGUMENT;
2330 } else {
2331 if (!ctx->rccxx . . $ _grn_ctx#rc.) {
2332 ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db. = db;
2333 if (db) {
2334 grn_obj buf;
2335 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&buf, 0);
2336 grn_obj_get_info(ctx, db, GRN_INFO_ENCODING, &buf);
2337 ctx->encodingcxx . . $ _grn_ctx#encoding. = *(grn_encoding *)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(&buf);
2338 grn_obj_close(ctx, &buf);
2339 }
2340 }
2341 }
2342 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
2343 }
2344
2345 /* don't handle error inside logger functions */
2346
2347 void
2348 grn_ctx_log(grn_ctx *ctx, const char *fmt, ...)
2349 {
2350 va_listcxx . . $ va_list# ap;
2351 va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(ap, fmt);
2352 grn_ctx_logv(ctx, fmt, ap);
2353 va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(ap);
2354 }
2355
2356 void
2357 grn_ctx_logv(grn_ctx *ctx, const char *fmt, va_listcxx . . $ va_list# ap)
2358 {
2359 char buffer[GRN_CTX_MSGSIZEcxx . . $ `include/groonga/groonga.h:334:9`!];
2360 grn_vsnprintfcxx . . $ `include/groonga/portability.h:148:11`!(buffer, GRN_CTX_MSGSIZEcxx . . $ `include/groonga/groonga.h:334:9`!, fmt, ap);
2361 grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(ctx->errbuf, GRN_CTX_MSGSIZE, buffer);
2362 }
2363
2364 #ifdef WIN32
2365 /* This is for clang-format.
2366 * clang-format can't work with "static __declspec(noinline) void". */
2367 # define grn_noinline __declspec(noinline)
2368 static grn_noinline void
2369 grn_ctx_log_back_trace_windows(grn_ctx *ctx, grn_log_level level)
2370 {
2371 # ifdef GRN_WITH_WINDOWS_BACK_TRACE
2372 # define MAX_N_FRAMES 62
2373 ULONG frames_to_skip = 0;
2374 ULONG frames_to_capture = MAX_N_FRAMES;
2375 void *back_trace[MAX_N_FRAMES];
2376 # undef MAX_N_FRAMES
2377 USHORT n_frames =
2378 CaptureStackBackTrace(frames_to_skip, frames_to_capture, back_trace, NULL);
2379 if (n_frames == 0) {
2380 return;
2381 }
2382
2383 HANDLE process = GetCurrentProcess();
2384 if (!grn_windows_symbol_initialize(ctx, process)) {
2385 GRN_LOG(ctx,
2386 level,
2387 "[log][back-trace] failed to initialize symbol handler");
2388 return;
2389 }
2390
2391 USHORT i;
2392 for (i = 0; i < n_frames; i++) {
2393 void *address = back_trace[i];
2394 grn_windows_log_back_trace_entry(ctx, level, process, (DWORD64)address);
2395 }
2396
2397 grn_windows_symbol_cleanup(ctx, process);
2398 # endif
2399 }
2400 #else
2401 # ifdef HAVE_BACKTRACEcxx . . $ `build/config.h:164:9`!
2402 static void
2403 grn_ctx_log_back_trace_backtrace(grn_ctx *ctx, grn_log_level level)
2404 {
2405 # define MAX_N_TRACEScxx . . $ `lib/ctx.cpp:2405:13`! 16
2406 void *traces[MAX_N_TRACEScxx . . $ `lib/ctx.cpp:2405:13`!];
2407 int n_traces = backtrace(traces, MAX_N_TRACEScxx . . $ `lib/ctx.cpp:2405:13`!);
2408 # undef MAX_N_TRACEScxx . . $ `lib/ctx.cpp:2405:13`!
2409 char **symbols;
2410 symbols = backtrace_symbols(traces, n_traces);
2411 if (symbols) {
2412 int i;
2413 for (i = 0; i < n_traces; i++) {
2414 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, level, "%s", symbols[i]);
2415 }
2416 freecxx . . $ free(bd21765a0afc8e3c).(symbols);
2417 } else {
2418 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, level, "[log][back-trace] backtrace_symbols() is failed");
2419 }
2420 }
2421 # endif
2422 #endif
2423
2424 bool
2425 grn_is_back_trace_enable(void)
2426 {
2427 return grn_back_trace_enable;
2428 }
2429
2430 grn_rc
2431 grn_set_back_trace_enable(bool enable)
2432 {
2433 grn_back_trace_enable = enable;
2434 return GRN_SUCCESS;
2435 }
2436
2437 void
2438 grn_ctx_log_back_trace(grn_ctx *ctx, grn_log_level level)
2439 {
2440 if (!grn_back_trace_enable) {
2441 return;
2442 }
2443 #ifdef WIN32
2444 grn_ctx_log_back_trace_windows(ctx, level);
2445 #else
2446 # ifdef HAVE_BACKTRACEcxx . . $ `build/config.h:164:9`!
2447 grn_ctx_log_back_trace_backtrace(ctx, level);
2448 # endif
2449 #endif
2450 }
2451
2452 void
2453 grn_assert(grn_ctx *ctx, int cond, const char *file, int line, const char *func)
2454 {
2455 if (!cond) {
2456 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_WARNING, "ASSERT fail on %s %s:%d", func, file, line);
2457 }
2458 }
2459
2460 const char *
2461 grn_get_version(void)
2462 {
2463 return GRN_VERSIONcxx . . $ `build/include/groonga/version.h:21:9`!;
2464 }
2465
2466 uint32_tcxx . . $ uint32_t#
2467 grn_get_version_major(void)
2468 {
2469 return GRN_VERSION_MAJORcxx . . $ `build/include/groonga/version.h:22:9`!;
2470 }
2471
2472 uint32_tcxx . . $ uint32_t#
2473 grn_get_version_minor(void)
2474 {
2475 return GRN_VERSION_MINORcxx . . $ `build/include/groonga/version.h:23:9`!;
2476 }
2477
2478 uint32_tcxx . . $ uint32_t#
2479 grn_get_version_micro(void)
2480 {
2481 return GRN_VERSION_MICROcxx . . $ `build/include/groonga/version.h:24:9`!;
2482 }
2483
2484 const char *
2485 grn_get_package(void)
2486 {
2487 return PACKAGEcxx . . $ `build/config.h:8:9`!;
2488 }
2489
2490 const char *
2491 grn_get_package_label(void)
2492 {
2493 return PACKAGE_LABELcxx . . $ `build/config.h:10:9`!;
2494 }
2495
2496 #ifdef WIN32
2497 static LONG WINAPI
2498 grn_exception_filter(EXCEPTION_POINTERS *info)
2499 {
2500 grn_ctx *ctx = &grn_gctx;
2501 GRN_LOG(ctx, GRN_LOG_CRIT, "-- CRASHED!!! --");
2502 grn_windows_log_back_trace(ctx,
2503 GRN_LOG_CRIT,
2504 GetCurrentProcess(),
2505 GetCurrentThread(),
2506 info->ContextRecord);
2507 GRN_LOG(ctx, GRN_LOG_CRIT, "----------------");
2508 return EXCEPTION_CONTINUE_SEARCH;
2509 }
2510 #elif defined(HAVE_SIGNAL_Hcxx . . $ `build/config.h:134:9`!) /* WIN32 */
2511 static bool crashed = false;
2512 static void
2513 grn_crash_handler(int signal_number, siginfo_t *info, void *context)
2514 {
2515 grn_ctx *ctx = &grn_gctx;
2516
2517 if (crashed) {
2518 if (signal_number == SIGSEGVcxx . . $ `<external>/11773118241360591791/signum-generic.h:52:9`!) {
2519 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_CRIT, "crashed in SEGV handler.");
2520 } else if (signal_number == SIGABRTcxx . . $ `<external>/11773118241360591791/signum-generic.h:50:9`!) {
2521 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_CRIT, "crashed in ABRT handler.");
2522 } else {
2523 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
2524 GRN_LOG_CRIT,
2525 "crashed in signal(%d) handler.",
2526 signal_number);
2527 }
2528 return;
2529 }
2530 crashed = true;
2531
2532 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_CRIT, "-- CRASHED!!! --");
2533 # ifdef HAVE_BACKTRACEcxx . . $ `build/config.h:164:9`!
2534 # define N_TRACE_LEVELcxx . . $ `lib/ctx.cpp:2534:13`! 1024
2535 {
2536 static void *trace[N_TRACE_LEVELcxx . . $ `lib/ctx.cpp:2534:13`!];
2537 int n = backtrace(trace, N_TRACE_LEVELcxx . . $ `lib/ctx.cpp:2534:13`!);
2538 char **symbols = backtrace_symbols(trace, n);
2539 int i;
2540
2541 if (symbols) {
2542 for (i = 0; i < n; i++) {
2543 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_CRIT, "%s", symbols[i]);
2544 }
2545 freecxx . . $ free(bd21765a0afc8e3c).(symbols);
2546 }
2547 }
2548 # else /* HAVE_BACKTRACE */
2549 GRN_LOG(ctx, GRN_LOG_CRIT, "backtrace() isn't available.");
2550 # endif /* HAVE_BACKTRACE */
2551 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_CRIT, "----------------");
2552
2553 struct sigaction default_action;
2554 memset(&default_action, 0, sizeof(default_action));
2555 sigemptyset(&default_action.sa_mask);
2556 default_action.sa_handlercxx . . $ `<external>/16635209305659446502/sigaction.h:39:10`! = SIG_DFLcxx . . $ `<external>/11773118241360591791/signum-generic.h:29:9`!;
2557 default_action.sa_flags = SA_SIGINFOcxx . . $ `<external>/16635209305659446502/sigaction.h:58:9`! | SA_ONSTACKcxx . . $ `<external>/16635209305659446502/sigaction.h:61:10`!;
2558 if (sigaction(SIGABRTcxx . . $ `<external>/11773118241360591791/signum-generic.h:50:9`!, &default_action, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!) == 0) {
2559 abortcxx . . $ abort(15d318a79ddce9e0).();
2560 } else {
2561 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
2562 GRN_LOG_CRIT,
2563 "exiting because resetting SIGABRT handler failed");
2564 _exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
2565 }
2566 }
2567 #endif /* WIN32 */
2568
2569 grn_rc
2570 grn_set_segv_handler(void)
2571 {
2572 grn_rc rc = GRN_SUCCESS;
2573 #ifdef WIN32
2574 SetUnhandledExceptionFilter(grn_exception_filter);
2575 #elif defined(HAVE_SIGNAL_Hcxx . . $ `build/config.h:134:9`!) /* WIN32 */
2576 grn_ctx *ctx = &grn_gctx;
2577 struct sigaction action;
2578 memset(&action, 0, sizeof(action));
2579 sigemptyset(&action.sa_mask);
2580 action.sa_sigactioncxx . . $ `<external>/16635209305659446502/sigaction.h:40:10`! = grn_crash_handler;
2581 action.sa_flags = SA_SIGINFOcxx . . $ `<external>/16635209305659446502/sigaction.h:58:9`! | SA_ONSTACKcxx . . $ `<external>/16635209305659446502/sigaction.h:61:10`!;
2582 if (sigaction(SIGSEGVcxx . . $ `<external>/11773118241360591791/signum-generic.h:52:9`!, &action, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!)) {
2583 SERRcxx . . $ `lib/grn_error.h:411:11`!("failed to set SIGSEGV action");
2584 rc = ctx->rccxx . . $ _grn_ctx#rc.;
2585 }
2586 #endif /* WIN32 */
2587 return rc;
2588 }
2589
2590 grn_rc
2591 grn_set_abrt_handler(void)
2592 {
2593 grn_rc rc = GRN_SUCCESS;
2594 #if !defined(WIN32) && defined(HAVE_SIGNAL_Hcxx . . $ `build/config.h:134:9`!)
2595 grn_ctx *ctx = &grn_gctx;
2596 struct sigaction action;
2597 memset(&action, 0, sizeof(action));
2598 sigemptyset(&action.sa_mask);
2599 action.sa_sigactioncxx . . $ `<external>/16635209305659446502/sigaction.h:40:10`! = grn_crash_handler;
2600 action.sa_flags = SA_SIGINFOcxx . . $ `<external>/16635209305659446502/sigaction.h:58:9`! | SA_ONSTACKcxx . . $ `<external>/16635209305659446502/sigaction.h:61:10`!;
2601 if (sigaction(SIGABRTcxx . . $ `<external>/11773118241360591791/signum-generic.h:50:9`!, &action, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!)) {
2602 SERRcxx . . $ `lib/grn_error.h:411:11`!("failed to set SIGABRT action");
2603 rc = ctx->rccxx . . $ _grn_ctx#rc.;
2604 }
2605 #endif
2606 return rc;
2607 }
2608
2609 #if defined(HAVE_SIGNAL_Hcxx . . $ `build/config.h:134:9`!) && !defined(WIN32)
2610 static struct sigaction old_int_handler;
2611 static void
2612 int_handler(int signal_number, siginfo_t *info, void *context)
2613 {
2614 grn_gctx.statcxx . . $ _grn_ctx#stat. = GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!;
2615 sigaction(signal_number, &old_int_handler, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
2616 }
2617
2618 static struct sigaction old_term_handler;
2619 static void
2620 term_handler(int signal_number, siginfo_t *info, void *context)
2621 {
2622 grn_gctx.statcxx . . $ _grn_ctx#stat. = GRN_CTX_QUITcxx . . $ `include/groonga/groonga.h:3297:9`!;
2623 sigaction(signal_number, &old_term_handler, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!);
2624 }
2625 #endif /* defined(HAVE_SIGNAL_H) && !defined(WIN32) */
2626
2627 grn_rc
2628 grn_set_int_handler(void)
2629 {
2630 grn_rc rc = GRN_SUCCESS;
2631 #if defined(HAVE_SIGNAL_Hcxx . . $ `build/config.h:134:9`!) && !defined(WIN32)
2632 grn_ctx *ctx = &grn_gctx;
2633 struct sigaction action;
2634
2635 sigemptyset(&action.sa_mask);
2636 action.sa_sigactioncxx . . $ `<external>/16635209305659446502/sigaction.h:40:10`! = int_handler;
2637 action.sa_flags = SA_SIGINFOcxx . . $ `<external>/16635209305659446502/sigaction.h:58:9`!;
2638
2639 if (sigaction(SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, &action, &old_int_handler)) {
2640 SERRcxx . . $ `lib/grn_error.h:411:11`!("failed to set SIGINT action");
2641 rc = ctx->rccxx . . $ _grn_ctx#rc.;
2642 }
2643 #endif
2644 return rc;
2645 }
2646
2647 grn_rc
2648 grn_set_term_handler(void)
2649 {
2650 grn_rc rc = GRN_SUCCESS;
2651 #if defined(HAVE_SIGNAL_Hcxx . . $ `build/config.h:134:9`!) && !defined(WIN32)
2652 grn_ctx *ctx = &grn_gctx;
2653 struct sigaction action;
2654
2655 sigemptyset(&action.sa_mask);
2656 action.sa_sigactioncxx . . $ `<external>/16635209305659446502/sigaction.h:40:10`! = term_handler;
2657 action.sa_flags = SA_SIGINFOcxx . . $ `<external>/16635209305659446502/sigaction.h:58:9`!;
2658
2659 if (sigaction(SIGTERMcxx . . $ `<external>/11773118241360591791/signum-generic.h:53:9`!, &action, &old_term_handler)) {
2660 SERRcxx . . $ `lib/grn_error.h:411:11`!("failed to set SIGTERM action");
2661 rc = ctx->rccxx . . $ _grn_ctx#rc.;
2662 }
2663 #endif
2664 return rc;
2665 }
2666
2667 void
2668 grn_ctx_output_flush(grn_ctx *ctx, int flags)
2669 {
2670 if (flags & GRN_CTX_QUIETcxx . . $ `include/groonga/groonga.h:3296:9`!) {
2671 return;
2672 }
2673 if (!ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..funccxx . . $ _grn_ctx_impl#$anonymous_type_0#func.) {
2674 return;
2675 }
2676 if (ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..arrow_stream_writercxx . . $ _grn_ctx_impl#$anonymous_type_0#arrow_stream_writer.) {
2677 grn_arrow_stream_writer_flush(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..arrow_stream_writercxx . . $ _grn_ctx_impl#$anonymous_type_0#arrow_stream_writer.);
2678 }
2679 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..funccxx . . $ _grn_ctx_impl#$anonymous_type_0#func.(ctx, flags, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..datacxx . . $ _grn_ctx_impl#$anonymous_type_0#data..ptrcxx . . $ _grn_ctx_impl#$anonymous_type_0#$anonymous_type_1#ptr.);
2680 }
2681
2682 void
2683 grn_ctx_output_array_open(grn_ctx *ctx, const char *name, int nelements)
2684 {
2685 grn_output_array_open(ctx,
2686 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2687 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2688 name,
2689 nelements);
2690 }
2691
2692 void
2693 grn_ctx_output_array_close(grn_ctx *ctx)
2694 {
2695 grn_output_array_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.);
2696 }
2697
2698 void
2699 grn_ctx_output_map_open(grn_ctx *ctx, const char *name, int nelements)
2700 {
2701 grn_output_map_open(ctx,
2702 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2703 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2704 name,
2705 nelements);
2706 }
2707
2708 void
2709 grn_ctx_output_map_close(grn_ctx *ctx)
2710 {
2711 grn_output_map_close(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.);
2712 }
2713
2714 void
2715 grn_ctx_output_null(grn_ctx *ctx)
2716 {
2717 grn_output_null(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.);
2718 }
2719
2720 void
2721 grn_ctx_output_int32(grn_ctx *ctx, int32_t value)
2722 {
2723 grn_output_int32(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2724 }
2725
2726 void
2727 grn_ctx_output_uint32(grn_ctx *ctx, uint32_tcxx . . $ uint32_t# value)
2728 {
2729 grn_output_uint32(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2730 }
2731
2732 void
2733 grn_ctx_output_int64(grn_ctx *ctx, int64_t value)
2734 {
2735 grn_output_int64(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2736 }
2737
2738 void
2739 grn_ctx_output_uint64(grn_ctx *ctx, uint64_tcxx . . $ uint64_t# value)
2740 {
2741 grn_output_uint64(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2742 }
2743
2744 void
2745 grn_ctx_output_float32(grn_ctx *ctx, float value)
2746 {
2747 grn_output_float32(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2748 }
2749
2750 void
2751 grn_ctx_output_float(grn_ctx *ctx, double value)
2752 {
2753 grn_output_float(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2754 }
2755
2756 void
2757 grn_ctx_output_cstr(grn_ctx *ctx, const char *value)
2758 {
2759 grn_output_cstr(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2760 }
2761
2762 void
2763 grn_ctx_output_str(grn_ctx *ctx, const char *value, size_t value_len)
2764 {
2765 grn_output_str(ctx,
2766 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2767 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2768 value,
2769 value_len);
2770 }
2771
2772 void
2773 grn_ctx_output_bool(grn_ctx *ctx, bool value)
2774 {
2775 grn_output_bool(ctx, ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf., ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type., value);
2776 }
2777
2778 void
2779 grn_ctx_output_obj(grn_ctx *ctx, grn_obj *value, grn_obj_format *format)
2780 {
2781 grn_output_obj(ctx,
2782 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2783 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2784 value,
2785 format);
2786 }
2787
2788 void
2789 grn_ctx_output_result_set_open_metadata(grn_ctx *ctx,
2790 grn_obj *result_set,
2791 grn_obj_format *format,
2792 uint32_tcxx . . $ uint32_t# n_additional_elements)
2793 {
2794 grn_output_result_set_open_metadata(ctx,
2795 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2796 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2797 result_set,
2798 format,
2799 n_additional_elements);
2800 }
2801
2802 void
2803 grn_ctx_output_result_set_open(grn_ctx *ctx,
2804 grn_obj *result_set,
2805 grn_obj_format *format,
2806 uint32_tcxx . . $ uint32_t# n_additional_elements)
2807 {
2808 grn_output_result_set_open(ctx,
2809 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2810 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2811 result_set,
2812 format,
2813 n_additional_elements);
2814 }
2815
2816 void
2817 grn_ctx_output_result_set_close(grn_ctx *ctx,
2818 grn_obj *result_set,
2819 grn_obj_format *format)
2820 {
2821 grn_output_result_set_close(ctx,
2822 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2823 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2824 result_set,
2825 format);
2826 }
2827
2828 void
2829 grn_ctx_output_result_set(grn_ctx *ctx,
2830 grn_obj *result_set,
2831 grn_obj_format *format)
2832 {
2833 grn_output_result_set(ctx,
2834 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2835 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2836 result_set,
2837 format);
2838 }
2839
2840 void
2841 grn_ctx_output_table_columns(grn_ctx *ctx,
2842 grn_obj *table,
2843 grn_obj_format *format)
2844 {
2845 grn_output_table_columns(ctx,
2846 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2847 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2848 table,
2849 format);
2850 }
2851
2852 void
2853 grn_ctx_output_table_records_open(grn_ctx *ctx, int n_records)
2854 {
2855 grn_output_table_records_open(ctx,
2856 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2857 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2858 n_records);
2859 }
2860
2861 void
2862 grn_ctx_output_table_records_close(grn_ctx *ctx)
2863 {
2864 grn_output_table_records_close(ctx,
2865 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2866 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.);
2867 }
2868
2869 void
2870 grn_ctx_output_table_records_content(grn_ctx *ctx,
2871 grn_obj *table,
2872 grn_obj_format *format)
2873 {
2874 grn_output_table_records_content(ctx,
2875 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2876 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2877 table,
2878 format);
2879 }
2880
2881 void
2882 grn_ctx_output_table_records(grn_ctx *ctx,
2883 grn_obj *table,
2884 grn_obj_format *format)
2885 {
2886 grn_output_table_records(ctx,
2887 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..bufcxx . . $ _grn_ctx_impl#$anonymous_type_0#buf.,
2888 ctx->implcxx . . $ _grn_ctx#impl.->outputcxx . . $ _grn_ctx_impl#output..typecxx . . $ _grn_ctx_impl#$anonymous_type_0#type.,
2889 table,
2890 format);
2891 }
2892 }
2893
2894 grncxx . . $ grn/::TaskExecutorcxx . . $ grn/TaskExecutor# *
2895 grn_ctx_get_task_executorcxx . . $ grn_ctx_get_task_executor(a6ad17b0d499b7c8).(grn_ctx *ctx)
2896 {
2897 if (!ctx->implcxx . . $ _grn_ctx#impl.) {
2898 return nullptr;
2899 }
2900 if (!ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..task_executorcxx . . $ _grn_ctx_impl#$anonymous_type_2#task_executor.) {
2901 ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..task_executorcxx . . $ _grn_ctx_impl#$anonymous_type_2#task_executor. = new grncxx . . $ grn/::TaskExecutorcxx . . $ grn/TaskExecutor#(ctx);
2902 }
2903 auto task_executor =
2904 static_cast<grncxx . . $ grn/::TaskExecutorcxx . . $ grn/TaskExecutor# *>(ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..task_executorcxx . . $ _grn_ctx_impl#$anonymous_type_2#task_executor.);
2905 task_executor->set_n_workerscxx . . $ grn/TaskExecutor#set_n_workers(d4f767463ce0a6b3).(ctx->implcxx . . $ _grn_ctx#impl.->parallelcxx . . $ _grn_ctx_impl#parallel..n_workerscxx . . $ _grn_ctx_impl#$anonymous_type_2#n_workers.);
2906 return task_executor;
2907 }