| 1 | /* -*- c-basic-offset: 2 -*- */cxx . . $ `<file>/storage/mroonga/vendor/groonga/lib/index_column.c`/ |
| 2 | /* |
| 3 | Copyright(C) 2009-2015 Brazil |
| 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 version 2.1 as published by the Free Software Foundation. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 17 | */ |
| 18 | |
| 19 | #include "grn_index_column.h"cxx . . $ `<file>/storage/mroonga/vendor/groonga/lib/grn_index_column.h`/ |
| 20 | #include "grn_ii.h"cxx . . $ `<file>/storage/mroonga/vendor/groonga/lib/grn_ii.h`/ |
| 21 | #include "grn_hash.h"cxx . . $ `<file>/storage/mroonga/vendor/groonga/lib/grn_hash.h`/ |
| 22 | |
| 23 | #include <string.h> |
| 24 | |
| 25 | static uint64_tcxx . . $ uint64_t# grn_index_sparsitycxx . . $ grn_index_sparsity. = 10; |
| 26 | static grn_boolcxx . . $ grn_bool# grn_index_chunk_split_enablecxx . . $ grn_index_chunk_split_enable. = GRN_TRUEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:44:9`!; |
| 27 | |
| 28 | void |
| 29 | grn_index_column_init_from_envcxx . . $ grn_index_column_init_from_env(49f6e7a06ebc5aa8).(void) |
| 30 | { |
| 31 | { |
| 32 | char grn_index_sparsity_env[GRN_ENV_BUFFER_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/portability.h:41:9`!]; |
| 33 | grn_getenvcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/portability.h:56:10`!("GRN_INDEX_SPARSITY", |
| 34 | grn_index_sparsity_env, |
| 35 | GRN_ENV_BUFFER_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/portability.h:41:9`!); |
| 36 | if (grn_index_sparsity_env[0]) { |
| 37 | uint64_tcxx . . $ uint64_t# sparsity; |
| 38 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 39 | sparsity = strtoullcxx . . $ strtoull(fa707f2e7d9ad629).(grn_index_sparsity_env, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 40 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == 0) { |
| 41 | grn_index_sparsitycxx . . $ grn_index_sparsity. = sparsity; |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | { |
| 47 | char grn_index_chunk_split_enable_env[GRN_ENV_BUFFER_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/portability.h:41:9`!]; |
| 48 | grn_getenvcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/portability.h:56:10`!("GRN_INDEX_CHUNK_SPLIT_ENABLE", |
| 49 | grn_index_chunk_split_enable_env, |
| 50 | GRN_ENV_BUFFER_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/portability.h:41:9`!); |
| 51 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(grn_index_chunk_split_enable_env, "no") == 0) { |
| 52 | grn_index_chunk_split_enablecxx . . $ grn_index_chunk_split_enable. = GRN_FALSEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:45:9`!; |
| 53 | } else { |
| 54 | grn_index_chunk_split_enablecxx . . $ grn_index_chunk_split_enable. = GRN_TRUEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:44:9`!; |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | inline static void |
| 60 | grn_index_column_build_call_hookcxx . . $ grn_index_column_build_call_hook(7163b242eb71bd7c).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *obj, |
| 61 | grn_idcxx . . $ grn_id# id, grn_objcxx . . $ grn_obj# *value, int flags) |
| 62 | { |
| 63 | grn_hookcxx . . $ grn_hook# *hooks = DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(obj)->hookscxx . . $ $anonymous_type_9afa47707a1d1b6d_0#hooks.[GRN_HOOK_SETcxx . . $ GRN_HOOK_SET.]; |
| 64 | |
| 65 | if (hooks) { |
| 66 | grn_objcxx . . $ grn_obj# oldvalue; |
| 67 | /* todo : grn_proc_ctx_open() */ |
| 68 | grn_objcxx . . $ grn_obj# id_, flags_; |
| 69 | grn_proc_ctxcxx . . $ grn_proc_ctx# pctx = {{0}, hooks->proccxx . . $ _grn_hook#proc., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, hooks, hooks, PROC_INITcxx . . $ PROC_INIT., 4, 4, |
| 70 | {{0}}}; |
| 71 | GRN_TEXT_INITcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:1275:9`!(&oldvalue, 0); |
| 72 | GRN_UINT32_INITcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:1319:9`!(&id_, 0); |
| 73 | GRN_UINT32_INITcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:1319:9`!(&flags_, 0); |
| 74 | GRN_UINT32_SETcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:1363:9`!(ctx, &id_, id); |
| 75 | GRN_UINT32_SETcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:1363:9`!(ctx, &flags_, flags); |
| 76 | while (hooks) { |
| 77 | grn_ctx_pushcxx . . $ grn_ctx_push(4865d068a46d0f83).(ctx, &id_); |
| 78 | grn_ctx_pushcxx . . $ grn_ctx_push(4865d068a46d0f83).(ctx, &oldvalue); |
| 79 | grn_ctx_pushcxx . . $ grn_ctx_push(4865d068a46d0f83).(ctx, value); |
| 80 | grn_ctx_pushcxx . . $ grn_ctx_push(4865d068a46d0f83).(ctx, &flags_); |
| 81 | pctx.callercxx . . $ _grn_proc_ctx#caller. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 82 | pctx.currhcxx . . $ _grn_proc_ctx#currh. = hooks; |
| 83 | if (hooks->proccxx . . $ _grn_hook#proc.) { |
| 84 | hooks->proccxx . . $ _grn_hook#proc.->funcscxx . . $ _grn_proc#funcs.[PROC_INITcxx . . $ PROC_INIT.](ctx, 1, &obj, &pctx.user_datacxx . . $ _grn_proc_ctx#user_data.); |
| 85 | } else { |
| 86 | grn_obj_default_set_value_hookcxx . . $ grn_obj_default_set_value_hook(fd082858389c8bb0).(ctx, 1, &obj, &pctx.user_datacxx . . $ _grn_proc_ctx#user_data.); |
| 87 | } |
| 88 | if (ctx->rccxx . . $ _grn_ctx#rc.) { |
| 89 | grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, &oldvalue); |
| 90 | return; |
| 91 | } |
| 92 | hooks = hooks->nextcxx . . $ _grn_hook#next.; |
| 93 | pctx.offsetcxx . . $ _grn_proc_ctx#offset.++; |
| 94 | } |
| 95 | grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, &oldvalue); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | grn_rccxx . . $ grn_rc# |
| 100 | grn_index_column_buildcxx . . $ grn_index_column_build(4865d068a46d0f83).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *index_column) |
| 101 | { |
| 102 | grn_objcxx . . $ grn_obj# *src, **cp, **col, *target; |
| 103 | grn_idcxx . . $ grn_id# *s = DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(index_column)->sourcecxx . . $ $anonymous_type_9afa47707a1d1b6d_0#source.; |
| 104 | if (!(DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(index_column)->source_sizecxx . . $ $anonymous_type_9afa47707a1d1b6d_0#source_size.) || !s) { return ctx->rccxx . . $ _grn_ctx#rc.; } |
| 105 | if ((src = grn_ctx_atcxx . . $ grn_ctx_at(ac4544c8400954c9).(ctx, *s))) { |
| 106 | target = GRN_OBJ_TABLEPcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:194:9`!(src) ? src : grn_ctx_atcxx . . $ grn_ctx_at(ac4544c8400954c9).(ctx, src->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain.); |
| 107 | if (target) { |
| 108 | int i, ncol = DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(index_column)->source_sizecxx . . $ $anonymous_type_9afa47707a1d1b6d_0#source_size. / sizeof(grn_idcxx . . $ grn_id#); |
| 109 | grn_table_flagscxx . . $ grn_table_flags# flags; |
| 110 | grn_iicxx . . $ grn_ii# *ii = (grn_iicxx . . $ grn_ii# *)index_column; |
| 111 | grn_boolcxx . . $ grn_bool# use_grn_ii_build; |
| 112 | grn_objcxx . . $ grn_obj# *tokenizer = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 113 | grn_table_get_infocxx . . $ grn_table_get_info(a1e4a6d36d3aee7c).(ctx, ii->lexiconcxx . . $ _grn_ii#lexicon., &flags, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tokenizer, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 114 | switch (flags & GRN_OBJ_TABLE_TYPE_MASKcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:293:9`!) { |
| 115 | case GRN_OBJ_TABLE_PAT_KEYcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:295:9`! : |
| 116 | case GRN_OBJ_TABLE_DAT_KEYcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:296:9`! : |
| 117 | use_grn_ii_build = GRN_TRUEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:44:9`!; |
| 118 | break; |
| 119 | default : |
| 120 | use_grn_ii_build = GRN_FALSEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:45:9`!; |
| 121 | break; |
| 122 | } |
| 123 | if ((ii->headercxx . . $ _grn_ii#header.->flagscxx . . $ grn_ii_header#flags. & GRN_OBJ_WITH_WEIGHTcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:322:9`!)) { |
| 124 | use_grn_ii_build = GRN_FALSEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:45:9`!; |
| 125 | } |
| 126 | if ((ii->headercxx . . $ _grn_ii#header.->flagscxx . . $ grn_ii_header#flags. & GRN_OBJ_WITH_POSITIONcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:323:9`!) && |
| 127 | (!tokenizer && |
| 128 | !GRN_TYPE_IS_TEXT_FAMILYcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/type.h:27:9`!(ii->lexicon->header.domain))) { |
| 129 | /* TODO: Support offline index construction for WITH_POSITION |
| 130 | * index against UInt32 vector column. */ |
| 131 | use_grn_ii_build = GRN_FALSEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:45:9`!; |
| 132 | } |
| 133 | if ((col = GRN_MALLOCcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_alloc.h:38:9`!(ncol * sizeof(grn_obj *)))) { |
| 134 | for (cp = col, i = ncol; i; s++, cp++, i--) { |
| 135 | if (!(*cp = grn_ctx_atcxx . . $ grn_ctx_at(ac4544c8400954c9).(ctx, *s))) { |
| 136 | ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT, "source invalid, n=%d",i); |
| 137 | GRN_FREEcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_alloc.h:46:9`!(col); |
| 138 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 139 | } |
| 140 | if (GRN_OBJ_TABLEPcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:194:9`!(grn_ctx_at(ctx, DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(*cp)->range))) { |
| 141 | use_grn_ii_build = GRN_FALSEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:45:9`!; |
| 142 | } |
| 143 | } |
| 144 | if (use_grn_ii_build) { |
| 145 | if (grn_index_chunk_split_enablecxx . . $ grn_index_chunk_split_enable.) { |
| 146 | grn_ii_build2cxx . . $ grn_ii_build2(439ab1227c2cf654).(ctx, ii, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 147 | } else { |
| 148 | grn_ii_buildcxx . . $ grn_ii_build(7ce09903cc9e3631).(ctx, ii, grn_index_sparsitycxx . . $ grn_index_sparsity.); |
| 149 | } |
| 150 | } else { |
| 151 | grn_table_cursorcxx . . $ grn_table_cursor# *tc; |
| 152 | if ((tc = grn_table_cursor_opencxx . . $ grn_table_cursor_open(a4cddc3087c69e91).(ctx, target, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, |
| 153 | 0, -1, GRN_CURSOR_BY_IDcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/table.h:63:9`!))) { |
| 154 | grn_idcxx . . $ grn_id# id; |
| 155 | grn_objcxx . . $ grn_obj# rv; |
| 156 | GRN_TEXT_INITcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:1275:9`!(&rv, 0); |
| 157 | while ((id = grn_table_cursor_nextcxx . . $ grn_table_cursor_next(8dd58acc9865e889).(ctx, tc)) != GRN_ID_NILcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:41:9`!) { |
| 158 | for (cp = col, i = ncol; i; i--, cp++) { |
| 159 | GRN_BULK_REWINDcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:1167:9`!(&rv); |
| 160 | if (GRN_OBJ_TABLEPcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:194:9`!(*cp)) { |
| 161 | grn_table_get_key2cxx . . $ grn_table_get_key2(bd0cb75328e85567).(ctx, *cp, id, &rv); |
| 162 | } else { |
| 163 | grn_obj_get_valuecxx . . $ grn_obj_get_value(6e06fec66698a6a).(ctx, *cp, id, &rv); |
| 164 | } |
| 165 | grn_index_column_build_call_hookcxx . . $ grn_index_column_build_call_hook(7163b242eb71bd7c).(ctx, *cp, id, &rv, 0); |
| 166 | } |
| 167 | } |
| 168 | GRN_OBJ_FINcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:436:9`!(ctx, &rv); |
| 169 | grn_table_cursor_closecxx . . $ grn_table_cursor_close(4865d068a46d0f83).(ctx, tc); |
| 170 | } |
| 171 | } |
| 172 | GRN_FREEcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_alloc.h:46:9`!(col); |
| 173 | grn_obj_touchcxx . . $ grn_obj_touch(7ce09bc2deb0d26b).(ctx, index_column, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 174 | } |
| 175 | } else { |
| 176 | ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT, "invalid target"); |
| 177 | } |
| 178 | } else { |
| 179 | ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT, "invalid source"); |
| 180 | } |
| 181 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 182 | } |
| 183 | |
| 184 | grn_rccxx . . $ grn_rc# |
| 185 | grn_index_column_rebuildcxx . . $ grn_index_column_rebuild(4865d068a46d0f83).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *index_column) |
| 186 | { |
| 187 | grn_iicxx . . $ grn_ii# *ii = (grn_iicxx . . $ grn_ii# *)index_column; |
| 188 | |
| 189 | GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!; |
| 190 | |
| 191 | grn_ii_truncatecxx . . $ grn_ii_truncate(57810f222e723019).(ctx, ii); |
| 192 | grn_index_column_buildcxx . . $ grn_index_column_build(4865d068a46d0f83).(ctx, index_column); |
| 193 | |
| 194 | GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc); |
| 195 | } |