| 1 | /* |
| 2 | Copyright (C) 2009-2017 Brazil |
| 3 | Copyright (C) 2021-2023 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_cache.h"cxx . . $ `<file>/lib/grn_cache.h`/ |
| 21 | #include "grn_ctx.h"cxx . . $ `<file>/lib/grn_ctx.h`/ |
| 22 | #include "grn_ctx_impl.h"cxx . . $ `<file>/lib/grn_ctx_impl.h`/ |
| 23 | #include "grn_hash.h"cxx . . $ `<file>/lib/grn_hash.h`/ |
| 24 | #include "grn_pat.h"cxx . . $ `<file>/lib/grn_pat.h`/ |
| 25 | #include "grn_store.h"cxx . . $ `<file>/lib/grn_store.h`/ |
| 26 | #include "grn_db.h"cxx . . $ `<file>/lib/grn_db.h`/ |
| 27 | #include "grn_file_lock.h"cxx . . $ `<file>/lib/grn_file_lock.h`/ |
| 28 | |
| 29 | #include <sys/stat.h> |
| 30 | |
| 31 | typedef uint8_tcxx . . $ uint8_t# grn_cache_flagscxx . . $ grn_cache_flags#; |
| 32 | #define GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`! (1 << 0) |
| 33 | |
| 34 | typedef struct _grn_cache_entry_memorycxx . . $ _grn_cache_entry_memory# grn_cache_entry_memorycxx . . $ grn_cache_entry_memory#; |
| 35 | |
| 36 | struct _grn_cache_entry_memorycxx . . $ _grn_cache_entry_memory# { |
| 37 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *nextcxx . . $ _grn_cache_entry_memory#next.; |
| 38 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *prevcxx . . $ _grn_cache_entry_memory#prev.; |
| 39 | grn_objcxx . . $ grn_obj# *valuecxx . . $ _grn_cache_entry_memory#value.; |
| 40 | grn_timevalcxx . . $ grn_timeval# tvcxx . . $ _grn_cache_entry_memory#tv.; |
| 41 | grn_idcxx . . $ grn_id# idcxx . . $ _grn_cache_entry_memory#id.; |
| 42 | }; |
| 43 | |
| 44 | typedef struct _grn_cache_entry_persistent_datacxx . . $ _grn_cache_entry_persistent_data# { |
| 45 | grn_idcxx . . $ grn_id# nextcxx . . $ _grn_cache_entry_persistent_data#next.; |
| 46 | grn_idcxx . . $ grn_id# prevcxx . . $ _grn_cache_entry_persistent_data#prev.; |
| 47 | grn_timevalcxx . . $ grn_timeval# modified_timecxx . . $ _grn_cache_entry_persistent_data#modified_time.; |
| 48 | } grn_cache_entry_persistent_datacxx . . $ grn_cache_entry_persistent_data#; |
| 49 | |
| 50 | /* |
| 51 | sizeof(grn_cache_entry_persistent_metadata) should be equal or smaller |
| 52 | than sizeof(grn_cache_entry_persistent_data). |
| 53 | */ |
| 54 | typedef struct _grn_cache_entry_persistent_metadatacxx . . $ _grn_cache_entry_persistent_metadata# { |
| 55 | uint32_tcxx . . $ uint32_t# max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries.; |
| 56 | uint32_tcxx . . $ uint32_t# nfetchescxx . . $ _grn_cache_entry_persistent_metadata#nfetches.; |
| 57 | uint32_tcxx . . $ uint32_t# nhitscxx . . $ _grn_cache_entry_persistent_metadata#nhits.; |
| 58 | uint32_tcxx . . $ uint32_t# flagscxx . . $ _grn_cache_entry_persistent_metadata#flags.; |
| 59 | } grn_cache_entry_persistent_metadatacxx . . $ grn_cache_entry_persistent_metadata#; |
| 60 | |
| 61 | typedef union _grn_cache_entry_persistentcxx . . $ _grn_cache_entry_persistent# { |
| 62 | grn_cache_entry_persistent_datacxx . . $ grn_cache_entry_persistent_data# datacxx . . $ _grn_cache_entry_persistent#data.; |
| 63 | grn_cache_entry_persistent_metadatacxx . . $ grn_cache_entry_persistent_metadata# metadatacxx . . $ _grn_cache_entry_persistent#metadata.; |
| 64 | } grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent#; |
| 65 | |
| 66 | struct _grn_cachecxx . . $ _grn_cache# { |
| 67 | unioncxx . . $ _grn_cache#$anonymous_type_0# { |
| 68 | structcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1# { |
| 69 | /* next and prev is the same layout as grn_cache_entry_memory to |
| 70 | * use this struct as the root entry. */ |
| 71 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *nextcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#next.; |
| 72 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *prevcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#prev.; |
| 73 | grn_hashcxx . . $ grn_hash# *hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash.; |
| 74 | grn_mutexcxx . . $ grn_mutex# mutexcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#mutex.; |
| 75 | uint32_tcxx . . $ uint32_t# max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries.; |
| 76 | uint32_tcxx . . $ uint32_t# nfetchescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nfetches.; |
| 77 | uint32_tcxx . . $ uint32_t# nhitscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nhits.; |
| 78 | } memorycxx . . $ _grn_cache#$anonymous_type_0#memory.; |
| 79 | structcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2# { |
| 80 | grn_hashcxx . . $ grn_hash# *keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 81 | grn_jacxx . . $ grn_ja# *valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.; |
| 82 | int timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout.; |
| 83 | } persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent.; |
| 84 | } implcxx . . $ _grn_cache#impl.; |
| 85 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_memorycxx . . $ _grn_cache#is_memory.; |
| 86 | grn_ctxcxx . . $ grn_ctx# *ctxcxx . . $ _grn_cache#ctx.; |
| 87 | }; |
| 88 | |
| 89 | #define GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`! 1 |
| 90 | #define GRN_CACHE_PERSISTENT_ROOT_KEYcxx . . $ `lib/cache.c:90:9`! "\0" |
| 91 | #define GRN_CACHE_PERSISTENT_ROOT_KEY_LENcxx . . $ `lib/cache.c:91:9`! \ |
| 92 | (sizeof(GRN_CACHE_PERSISTENT_ROOT_KEYcxx . . $ `lib/cache.c:90:9`!) - 1) |
| 93 | #define GRN_CACHE_PERSISTENT_METADATA_IDcxx . . $ `lib/cache.c:93:9`! 2 |
| 94 | #define GRN_CACHE_PERSISTENT_METADATA_KEYcxx . . $ `lib/cache.c:94:9`! "\1" |
| 95 | #define GRN_CACHE_PERSISTENT_METADATA_KEY_LENcxx . . $ `lib/cache.c:95:9`! \ |
| 96 | (sizeof(GRN_CACHE_PERSISTENT_METADATA_KEYcxx . . $ `lib/cache.c:94:9`!) - 1) |
| 97 | |
| 98 | static grn_ctxcxx . . $ grn_ctx# grn_cache_ctxcxx . . $ grn_cache_ctx.; |
| 99 | static grn_cachecxx . . $ grn_cache# *grn_cache_currentcxx . . $ grn_cache_current. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 100 | static grn_cachecxx . . $ grn_cache# *grn_cache_defaultcxx . . $ grn_cache_default. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 101 | static char grn_cache_default_base_pathcxx . . $ grn_cache_default_base_path.[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 102 | |
| 103 | void |
| 104 | grn_set_default_cache_base_pathcxx . . $ grn_set_default_cache_base_path(85c52e162fed56f9).(const char *base_path) |
| 105 | { |
| 106 | if (base_path) { |
| 107 | grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(grn_cache_default_base_path, |
| 108 | PATH_MAX, |
| 109 | base_path); |
| 110 | } else { |
| 111 | grn_cache_default_base_pathcxx . . $ grn_cache_default_base_path.[0] = '\0'; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | const char * |
| 116 | grn_get_default_cache_base_pathcxx . . $ grn_get_default_cache_base_path(33a1f659e94feb42).(void) |
| 117 | { |
| 118 | if (grn_cache_default_base_pathcxx . . $ grn_cache_default_base_path.[0] == '\0') { |
| 119 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 120 | } else { |
| 121 | return grn_cache_default_base_pathcxx . . $ grn_cache_default_base_path.; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | static void |
| 126 | grn_cache_open_memorycxx . . $ grn_cache_open_memory(b3f630924e6bcbb0).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache) |
| 127 | { |
| 128 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..nextcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#next. = (grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *)&(cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory.); |
| 129 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..prevcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#prev. = (grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *)&(cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory.); |
| 130 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash. = grn_hash_createcxx . . $ grn_hash_create(db1bba7e0d64660).(cache->ctxcxx . . $ _grn_cache#ctx., |
| 131 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 132 | GRN_CACHE_MAX_KEY_SIZEcxx . . $ `lib/grn_cache.h:28:9`!, |
| 133 | sizeof(grn_cache_entry_memorycxx . . $ grn_cache_entry_memory#), |
| 134 | GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`!); |
| 135 | if (!cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash.) { |
| 136 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_NO_MEMORY_AVAILABLE, "[cache] failed to create hash table"); |
| 137 | return; |
| 138 | } |
| 139 | MUTEX_INITcxx . . $ `lib/grn.h:219:11`!(cache->impl.memory.mutex); |
| 140 | |
| 141 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries. = GRN_CACHE_DEFAULT_MAX_N_ENTRIEScxx . . $ `include/groonga/cache.h:25:9`!; |
| 142 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..nfetchescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nfetches. = 0; |
| 143 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..nhitscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nhits. = 0; |
| 144 | } |
| 145 | |
| 146 | static void |
| 147 | grn_cache_open_persistentcxx . . $ grn_cache_open_persistent(c154176958b26d0a).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 148 | grn_cachecxx . . $ grn_cache# *cache, |
| 149 | const char *base_path) |
| 150 | { |
| 151 | grn_file_lockcxx . . $ grn_file_lock# file_lock; |
| 152 | char *keys_path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 153 | char *values_path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 154 | char lock_path_buffer[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 155 | char keys_path_buffer[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 156 | char values_path_buffer[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 157 | |
| 158 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout. = 1000; |
| 159 | |
| 160 | if (base_path) { |
| 161 | struct statcxx . . $ stat# stat_buffer; |
| 162 | |
| 163 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(lock_path_buffer, PATH_MAX, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, "%s.lock", base_path); |
| 164 | grn_file_lock_initcxx . . $ grn_file_lock_init(b6f038a97f7c4fb7).(ctx, &file_lock, lock_path_buffer); |
| 165 | |
| 166 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(keys_path_buffer, PATH_MAX, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, "%s.keys", base_path); |
| 167 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(values_path_buffer, PATH_MAX, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, "%s.values", base_path); |
| 168 | keys_path = keys_path_buffer; |
| 169 | values_path = values_path_buffer; |
| 170 | |
| 171 | if (!grn_file_lock_acquirecxx . . $ grn_file_lock_acquire(ab0e5af768e5a780).(ctx, |
| 172 | &file_lock, |
| 173 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout., |
| 174 | "[cache][persistent][open]")) { |
| 175 | goto exit; |
| 176 | } |
| 177 | |
| 178 | if (statcxx . . $ stat(a9cd1e23e96f423c).(keys_path, &stat_buffer) == 0) { |
| 179 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys. = grn_hash_opencxx . . $ grn_hash_open(4c2cb85ada117b1b).(ctx, keys_path); |
| 180 | if (cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.) { |
| 181 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values. = grn_ja_opencxx . . $ grn_ja_open(26b27a6ad48eb6db).(ctx, values_path); |
| 182 | } |
| 183 | } |
| 184 | if (!cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.) { |
| 185 | if (cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.) { |
| 186 | grn_ja_closecxx . . $ grn_ja_close(9f990ad2d2754423).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.); |
| 187 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 188 | } |
| 189 | if (statcxx . . $ stat(a9cd1e23e96f423c).(keys_path, &stat_buffer) == 0) { |
| 190 | if (grn_hash_removecxx . . $ grn_hash_remove(cae1c943be750b4c).(ctx, keys_path) != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 191 | ERRNO_ERRcxx . . $ `lib/grn_error.h:569:11`!("[cache][persistent] " |
| 192 | "failed to remove path for cache keys: <%s>", |
| 193 | keys_path); |
| 194 | goto exit; |
| 195 | } |
| 196 | } |
| 197 | if (statcxx . . $ stat(a9cd1e23e96f423c).(values_path, &stat_buffer) == 0) { |
| 198 | if (grn_ja_removecxx . . $ grn_ja_remove(cae1c943be750b4c).(ctx, values_path) != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 199 | ERRNO_ERRcxx . . $ `lib/grn_error.h:569:11`!("[cache][persistent] " |
| 200 | "failed to remove path for cache values: <%s>", |
| 201 | values_path); |
| 202 | goto exit; |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if (!cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.) { |
| 209 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys. = |
| 210 | grn_hash_createcxx . . $ grn_hash_create(db1bba7e0d64660).(ctx, |
| 211 | keys_path, |
| 212 | GRN_CACHE_MAX_KEY_SIZEcxx . . $ `lib/grn_cache.h:28:9`!, |
| 213 | sizeof(grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent#), |
| 214 | GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`!); |
| 215 | if (!cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.) { |
| 216 | ERRcxx . . $ `lib/grn_error.h:156:9`!(ctx->rc == GRN_SUCCESS ? GRN_FILE_CORRUPT : ctx->rc, |
| 217 | "[cache][persistent] failed to create cache keys storage: <%s>", |
| 218 | keys_path ? keys_path : "(memory)"); |
| 219 | goto exit; |
| 220 | } |
| 221 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values. = |
| 222 | grn_ja_createcxx . . $ grn_ja_create(8e06967be2729ebb).(ctx, |
| 223 | values_path, |
| 224 | 1 << 16, |
| 225 | 0); |
| 226 | if (!cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.) { |
| 227 | grn_hash_closecxx . . $ grn_hash_close(c005d027d163fb0b).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.); |
| 228 | ERRcxx . . $ `lib/grn_error.h:156:9`!(ctx->rc == GRN_SUCCESS ? GRN_FILE_CORRUPT : ctx->rc, |
| 229 | "[cache][persistent] failed to create cache values storage: <%s>", |
| 230 | values_path ? values_path : "(memory)"); |
| 231 | goto exit; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | { |
| 236 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *entry; |
| 237 | grn_idcxx . . $ grn_id# root_id; |
| 238 | int added; |
| 239 | |
| 240 | root_id = grn_hash_addcxx . . $ grn_hash_add(251a256fc515235e).(ctx, |
| 241 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys., |
| 242 | GRN_CACHE_PERSISTENT_ROOT_KEYcxx . . $ `lib/cache.c:90:9`!, |
| 243 | GRN_CACHE_PERSISTENT_ROOT_KEY_LENcxx . . $ `lib/cache.c:91:9`!, |
| 244 | (void **)&entry, |
| 245 | &added); |
| 246 | if (root_id != GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`!) { |
| 247 | grn_ja_closecxx . . $ grn_ja_close(9f990ad2d2754423).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.); |
| 248 | grn_hash_closecxx . . $ grn_hash_close(c005d027d163fb0b).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.); |
| 249 | if (values_path) { |
| 250 | grn_ja_removecxx . . $ grn_ja_remove(cae1c943be750b4c).(ctx, values_path); |
| 251 | } |
| 252 | if (keys_path) { |
| 253 | grn_hash_removecxx . . $ grn_hash_remove(cae1c943be750b4c).(ctx, keys_path); |
| 254 | } |
| 255 | ERRcxx . . $ `lib/grn_error.h:156:9`!(ctx->rc == GRN_SUCCESS ? GRN_FILE_CORRUPT : ctx->rc, |
| 256 | "[cache][persistent] broken cache keys storage: broken root: <%s>", |
| 257 | keys_path ? keys_path : "(memory)"); |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | if (added) { |
| 262 | entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next. = root_id; |
| 263 | entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev. = root_id; |
| 264 | entry->datacxx . . $ _grn_cache_entry_persistent#data..modified_timecxx . . $ _grn_cache_entry_persistent_data#modified_time..tv_seccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_sec. = 0; |
| 265 | entry->datacxx . . $ _grn_cache_entry_persistent#data..modified_timecxx . . $ _grn_cache_entry_persistent_data#modified_time..tv_nseccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_nsec. = 0; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | { |
| 270 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *entry; |
| 271 | grn_idcxx . . $ grn_id# metadata_id; |
| 272 | int added; |
| 273 | |
| 274 | metadata_id = grn_hash_addcxx . . $ grn_hash_add(251a256fc515235e).(ctx, |
| 275 | cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys., |
| 276 | GRN_CACHE_PERSISTENT_METADATA_KEYcxx . . $ `lib/cache.c:94:9`!, |
| 277 | GRN_CACHE_PERSISTENT_METADATA_KEY_LENcxx . . $ `lib/cache.c:95:9`!, |
| 278 | (void **)&entry, |
| 279 | &added); |
| 280 | if (metadata_id != GRN_CACHE_PERSISTENT_METADATA_IDcxx . . $ `lib/cache.c:93:9`!) { |
| 281 | grn_ja_closecxx . . $ grn_ja_close(9f990ad2d2754423).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.); |
| 282 | grn_hash_closecxx . . $ grn_hash_close(c005d027d163fb0b).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.); |
| 283 | if (values_path) { |
| 284 | grn_ja_removecxx . . $ grn_ja_remove(cae1c943be750b4c).(ctx, values_path); |
| 285 | } |
| 286 | if (keys_path) { |
| 287 | grn_hash_removecxx . . $ grn_hash_remove(cae1c943be750b4c).(ctx, keys_path); |
| 288 | } |
| 289 | ERRcxx . . $ `lib/grn_error.h:156:9`!(ctx->rc == GRN_SUCCESS ? GRN_FILE_CORRUPT : ctx->rc, |
| 290 | "[cache][persistent] broken cache keys storage: broken metadata: <%s>", |
| 291 | keys_path ? keys_path : "(memory)"); |
| 292 | goto exit; |
| 293 | } |
| 294 | |
| 295 | if (added) { |
| 296 | entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries. = GRN_CACHE_DEFAULT_MAX_N_ENTRIEScxx . . $ `include/groonga/cache.h:25:9`!; |
| 297 | entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..nfetchescxx . . $ _grn_cache_entry_persistent_metadata#nfetches. = 0; |
| 298 | entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..nhitscxx . . $ _grn_cache_entry_persistent_metadata#nhits. = 0; |
| 299 | entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..flagscxx . . $ _grn_cache_entry_persistent_metadata#flags. = GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | exit : |
| 304 | if (base_path) { |
| 305 | grn_file_lock_releasecxx . . $ grn_file_lock_release(7fc6e84b96ea19e9).(ctx, &file_lock); |
| 306 | grn_file_lock_fincxx . . $ grn_file_lock_fin(7fc6e84b96ea19e9).(ctx, &file_lock); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | static grn_cachecxx . . $ grn_cache# * |
| 311 | grn_cache_open_rawcxx . . $ grn_cache_open_raw(d6579e8a20177e92).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 312 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_memory, |
| 313 | const char *base_path) |
| 314 | { |
| 315 | grn_cachecxx . . $ grn_cache# *cache = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 316 | |
| 317 | GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!; |
| 318 | cache = GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(grn_cache)); |
| 319 | if (!cache) { |
| 320 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_NO_MEMORY_AVAILABLE, "[cache] failed to allocate grn_cache"); |
| 321 | goto exit; |
| 322 | } |
| 323 | |
| 324 | cache->ctxcxx . . $ _grn_cache#ctx. = ctx; |
| 325 | cache->is_memorycxx . . $ _grn_cache#is_memory. = is_memory; |
| 326 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 327 | grn_cache_open_memorycxx . . $ grn_cache_open_memory(b3f630924e6bcbb0).(ctx, cache); |
| 328 | } else { |
| 329 | grn_cache_open_persistentcxx . . $ grn_cache_open_persistent(c154176958b26d0a).(ctx, cache, base_path); |
| 330 | } |
| 331 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 332 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(cache); |
| 333 | cache = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 334 | goto exit; |
| 335 | } |
| 336 | |
| 337 | exit : |
| 338 | GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(cache); |
| 339 | } |
| 340 | |
| 341 | grn_cachecxx . . $ grn_cache# * |
| 342 | grn_cache_opencxx . . $ grn_cache_open(ef516a6d4bcbf29d).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 343 | { |
| 344 | const char *base_path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 345 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_memory; |
| 346 | |
| 347 | if (grn_cache_default_base_pathcxx . . $ grn_cache_default_base_path.[0] != '\0') { |
| 348 | base_path = grn_cache_default_base_pathcxx . . $ grn_cache_default_base_path.; |
| 349 | } |
| 350 | |
| 351 | if (base_path) { |
| 352 | is_memory = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 353 | } else { |
| 354 | char grn_cache_type_env[GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!]; |
| 355 | grn_getenvcxx . . $ `include/groonga/portability.h:58:11`!("GRN_CACHE_TYPE", grn_cache_type_env, GRN_ENV_BUFFER_SIZEcxx . . $ `include/groonga/portability.h:42:9`!); |
| 356 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(grn_cache_type_env, "persistent") == 0) { |
| 357 | is_memory = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 358 | } else { |
| 359 | is_memory = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | return grn_cache_open_rawcxx . . $ grn_cache_open_raw(d6579e8a20177e92).(ctx, is_memory, base_path); |
| 364 | } |
| 365 | |
| 366 | grn_cachecxx . . $ grn_cache# * |
| 367 | grn_persistent_cache_opencxx . . $ grn_persistent_cache_open(a89f9a98c0b9c90a).(grn_ctxcxx . . $ grn_ctx# *ctx, const char *base_path) |
| 368 | { |
| 369 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_memory = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 370 | return grn_cache_open_rawcxx . . $ grn_cache_open_raw(d6579e8a20177e92).(ctx, is_memory, base_path); |
| 371 | } |
| 372 | |
| 373 | |
| 374 | static void |
| 375 | grn_cache_close_memorycxx . . $ grn_cache_close_memory(b3f630924e6bcbb0).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache) |
| 376 | { |
| 377 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, cache->impl.memory.hash, cursor, id) { |
| 378 | void *value; |
| 379 | grn_hash_cursor_get_valuecxx . . $ grn_hash_cursor_get_value(248c0d78df691c42).(ctx, cursor, &value); |
| 380 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *entry = value; |
| 381 | grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, entry->valuecxx . . $ _grn_cache_entry_memory#value.); |
| 382 | } GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 383 | grn_hash_closecxx . . $ grn_hash_close(c005d027d163fb0b).(ctx, cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash.); |
| 384 | MUTEX_FINcxx . . $ `lib/grn.h:223:11`!(cache->impl.memory.mutex); |
| 385 | } |
| 386 | |
| 387 | static void |
| 388 | grn_cache_close_persistentcxx . . $ grn_cache_close_persistent(b3f630924e6bcbb0).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache) |
| 389 | { |
| 390 | grn_hash_closecxx . . $ grn_hash_close(c005d027d163fb0b).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.); |
| 391 | grn_ja_closecxx . . $ grn_ja_close(9f990ad2d2754423).(ctx, cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.); |
| 392 | } |
| 393 | |
| 394 | grn_rccxx . . $ grn_rc# |
| 395 | grn_cache_closecxx . . $ grn_cache_close(f6beb3535a4b847).(grn_ctxcxx . . $ grn_ctx# *ctx_not_used, grn_cachecxx . . $ grn_cache# *cache) |
| 396 | { |
| 397 | grn_ctxcxx . . $ grn_ctx# *ctx = cache->ctxcxx . . $ _grn_cache#ctx.; |
| 398 | |
| 399 | GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!; |
| 400 | |
| 401 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 402 | grn_cache_close_memorycxx . . $ grn_cache_close_memory(b3f630924e6bcbb0).(ctx, cache); |
| 403 | } else { |
| 404 | grn_cache_close_persistentcxx . . $ grn_cache_close_persistent(b3f630924e6bcbb0).(ctx, cache); |
| 405 | } |
| 406 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(cache); |
| 407 | |
| 408 | GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc); |
| 409 | } |
| 410 | |
| 411 | grn_rccxx . . $ grn_rc# |
| 412 | grn_cache_current_setcxx . . $ grn_cache_current_set(f6beb3535a4b847).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache) |
| 413 | { |
| 414 | grn_cache_currentcxx . . $ grn_cache_current. = cache; |
| 415 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 416 | } |
| 417 | |
| 418 | grn_cachecxx . . $ grn_cache# * |
| 419 | grn_cache_current_getcxx . . $ grn_cache_current_get(ef516a6d4bcbf29d).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 420 | { |
| 421 | if (ctx && ctx->implcxx . . $ _grn_ctx#impl. && ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db. && ((grn_dbcxx . . $ grn_db# *)ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)->cachecxx . . $ _grn_db#cache.) { |
| 422 | return ((grn_dbcxx . . $ grn_db# *)ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)->cachecxx . . $ _grn_db#cache.; |
| 423 | } |
| 424 | return grn_cache_currentcxx . . $ grn_cache_current.; |
| 425 | } |
| 426 | |
| 427 | void |
| 428 | grn_cache_initcxx . . $ grn_cache_init(49f6e7a06ebc5aa8).(void) |
| 429 | { |
| 430 | grn_ctxcxx . . $ grn_ctx# *ctx = &grn_cache_ctxcxx . . $ grn_cache_ctx.; |
| 431 | |
| 432 | grn_ctx_initcxx . . $ grn_ctx_init(670fdc69e3f5dbb5).(ctx, 0); |
| 433 | |
| 434 | grn_cache_defaultcxx . . $ grn_cache_default. = grn_cache_opencxx . . $ grn_cache_open(ef516a6d4bcbf29d).(ctx); |
| 435 | grn_cache_current_setcxx . . $ grn_cache_current_set(f6beb3535a4b847).(ctx, grn_cache_defaultcxx . . $ grn_cache_default.); |
| 436 | } |
| 437 | |
| 438 | grn_rccxx . . $ grn_rc# |
| 439 | grn_cache_default_reopencxx . . $ grn_cache_default_reopen(d5bb96df31a8101).(void) |
| 440 | { |
| 441 | grn_ctxcxx . . $ grn_ctx# *ctx = &grn_cache_ctxcxx . . $ grn_cache_ctx.; |
| 442 | grn_cachecxx . . $ grn_cache# *new_default; |
| 443 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! default_is_current; |
| 444 | |
| 445 | GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!; |
| 446 | |
| 447 | new_default = grn_cache_opencxx . . $ grn_cache_open(ef516a6d4bcbf29d).(ctx); |
| 448 | if (!new_default) { |
| 449 | GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc); |
| 450 | } |
| 451 | |
| 452 | default_is_current = (grn_cache_defaultcxx . . $ grn_cache_default. == grn_cache_current_getcxx . . $ grn_cache_current_get(ef516a6d4bcbf29d).(ctx)); |
| 453 | if (default_is_current) { |
| 454 | grn_cache_current_setcxx . . $ grn_cache_current_set(f6beb3535a4b847).(ctx, new_default); |
| 455 | } |
| 456 | |
| 457 | if (grn_cache_defaultcxx . . $ grn_cache_default.) { |
| 458 | grn_cache_closecxx . . $ grn_cache_close(f6beb3535a4b847).(ctx, grn_cache_defaultcxx . . $ grn_cache_default.); |
| 459 | } |
| 460 | grn_cache_defaultcxx . . $ grn_cache_default. = new_default; |
| 461 | |
| 462 | GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc); |
| 463 | } |
| 464 | |
| 465 | static void |
| 466 | grn_cache_expire_entry_memorycxx . . $ grn_cache_expire_entry_memory(330f6164b12adfc4).(grn_cachecxx . . $ grn_cache# *cache, grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *ce) |
| 467 | { |
| 468 | ce->prevcxx . . $ _grn_cache_entry_memory#prev.->nextcxx . . $ _grn_cache_entry_memory#next. = ce->nextcxx . . $ _grn_cache_entry_memory#next.; |
| 469 | ce->nextcxx . . $ _grn_cache_entry_memory#next.->prevcxx . . $ _grn_cache_entry_memory#prev. = ce->prevcxx . . $ _grn_cache_entry_memory#prev.; |
| 470 | grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(cache->ctxcxx . . $ _grn_cache#ctx., ce->valuecxx . . $ _grn_cache_entry_memory#value.); |
| 471 | grn_hash_delete_by_idcxx . . $ grn_hash_delete_by_id(1721f36f0335b634).(cache->ctxcxx . . $ _grn_cache#ctx., cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash., ce->idcxx . . $ _grn_cache_entry_memory#id., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 472 | } |
| 473 | |
| 474 | static void |
| 475 | grn_cache_entry_persistent_delete_linkcxx . . $ grn_cache_entry_persistent_delete_link(b630b05c8bc92cfa).(grn_cachecxx . . $ grn_cache# *cache, |
| 476 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *entry) |
| 477 | { |
| 478 | grn_ctxcxx . . $ grn_ctx# *ctx = cache->ctxcxx . . $ _grn_cache#ctx.; |
| 479 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 480 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *prev_entry; |
| 481 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *next_entry; |
| 482 | |
| 483 | prev_entry = |
| 484 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 485 | keys, |
| 486 | entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev., |
| 487 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 488 | next_entry = |
| 489 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 490 | keys, |
| 491 | entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next., |
| 492 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 493 | prev_entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next. = entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next.; |
| 494 | next_entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev. = entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev.; |
| 495 | } |
| 496 | |
| 497 | static void |
| 498 | grn_cache_entry_persistent_prepend_linkcxx . . $ grn_cache_entry_persistent_prepend_link(6476760daa537107).(grn_cachecxx . . $ grn_cache# *cache, |
| 499 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *entry, |
| 500 | grn_idcxx . . $ grn_id# entry_id, |
| 501 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *head_entry, |
| 502 | grn_idcxx . . $ grn_id# head_entry_id) |
| 503 | { |
| 504 | grn_ctxcxx . . $ grn_ctx# *ctx = cache->ctxcxx . . $ _grn_cache#ctx.; |
| 505 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 506 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *head_next_entry; |
| 507 | |
| 508 | entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next. = head_entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next.; |
| 509 | entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev. = head_entry_id; |
| 510 | head_next_entry = |
| 511 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 512 | keys, |
| 513 | head_entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next., |
| 514 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 515 | head_next_entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev. = entry_id; |
| 516 | head_entry->datacxx . . $ _grn_cache_entry_persistent#data..nextcxx . . $ _grn_cache_entry_persistent_data#next. = entry_id; |
| 517 | } |
| 518 | |
| 519 | static void |
| 520 | grn_cache_expire_entry_persistentcxx . . $ grn_cache_expire_entry_persistent(e347e0f90c9aee4e).(grn_cachecxx . . $ grn_cache# *cache, |
| 521 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *entry, |
| 522 | grn_idcxx . . $ grn_id# cache_id) |
| 523 | { |
| 524 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 525 | grn_jacxx . . $ grn_ja# *values = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.; |
| 526 | |
| 527 | grn_cache_entry_persistent_delete_linkcxx . . $ grn_cache_entry_persistent_delete_link(b630b05c8bc92cfa).(cache, entry); |
| 528 | grn_ja_putcxx . . $ grn_ja_put(35c973a3630485be).(cache->ctxcxx . . $ _grn_cache#ctx., values, cache_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0, GRN_OBJ_SETcxx . . $ `include/groonga/groonga.h:1466:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 529 | grn_hash_delete_by_idcxx . . $ grn_hash_delete_by_id(1721f36f0335b634).(cache->ctxcxx . . $ _grn_cache#ctx., keys, cache_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 530 | } |
| 531 | |
| 532 | static void |
| 533 | grn_cache_expire_memory_without_lockcxx . . $ grn_cache_expire_memory_without_lock(c205dd1ff4316349).(grn_cachecxx . . $ grn_cache# *cache, uint32_tcxx . . $ uint32_t# size) |
| 534 | { |
| 535 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *ce0 = |
| 536 | (grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *)(&(cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory.)); |
| 537 | while (ce0 != ce0->prevcxx . . $ _grn_cache_entry_memory#prev. && size--) { |
| 538 | grn_cache_expire_entry_memorycxx . . $ grn_cache_expire_entry_memory(330f6164b12adfc4).(cache, ce0->prevcxx . . $ _grn_cache_entry_memory#prev.); |
| 539 | } |
| 540 | if (size == 0) { |
| 541 | grn_hash_truncatecxx . . $ grn_hash_truncate(c005d027d163fb0b).(cache->ctxcxx . . $ _grn_cache#ctx., cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash.); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | static void |
| 546 | grn_cache_expire_persistent_without_lockcxx . . $ grn_cache_expire_persistent_without_lock(c205dd1ff4316349).(grn_cachecxx . . $ grn_cache# *cache, uint32_tcxx . . $ uint32_t# size) |
| 547 | { |
| 548 | grn_ctxcxx . . $ grn_ctx# *ctx = cache->ctxcxx . . $ _grn_cache#ctx.; |
| 549 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 550 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *head_entry; |
| 551 | |
| 552 | head_entry = |
| 553 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 554 | keys, |
| 555 | GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`!, |
| 556 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 557 | while (head_entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev. != GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`! && |
| 558 | size > 0) { |
| 559 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *tail_entry; |
| 560 | tail_entry = |
| 561 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 562 | keys, |
| 563 | head_entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev., |
| 564 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 565 | grn_cache_expire_entry_persistentcxx . . $ grn_cache_expire_entry_persistent(e347e0f90c9aee4e).(cache, tail_entry, head_entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev.); |
| 566 | size--; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | static grn_rccxx . . $ grn_rc# |
| 571 | grn_cache_set_max_n_entries_memorycxx . . $ grn_cache_set_max_n_entries_memory(5e00bd443a95fa3d).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 572 | grn_cachecxx . . $ grn_cache# *cache, |
| 573 | unsigned int n) |
| 574 | { |
| 575 | uint32_tcxx . . $ uint32_t# current_max_n_entries; |
| 576 | |
| 577 | MUTEX_LOCKcxx . . $ `lib/grn.h:220:11`!(cache->impl.memory.mutex); |
| 578 | current_max_n_entries = cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries.; |
| 579 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries. = n; |
| 580 | if (n < current_max_n_entries) { |
| 581 | grn_cache_expire_memory_without_lockcxx . . $ grn_cache_expire_memory_without_lock(c205dd1ff4316349).(cache, current_max_n_entries - n); |
| 582 | } |
| 583 | MUTEX_UNLOCKcxx . . $ `lib/grn.h:222:11`!(cache->impl.memory.mutex); |
| 584 | |
| 585 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 586 | } |
| 587 | |
| 588 | static grn_rccxx . . $ grn_rc# |
| 589 | grn_cache_set_max_n_entries_persistentcxx . . $ grn_cache_set_max_n_entries_persistent(5e00bd443a95fa3d).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 590 | grn_cachecxx . . $ grn_cache# *cache, |
| 591 | unsigned int n) |
| 592 | { |
| 593 | grn_rccxx . . $ grn_rc# rc; |
| 594 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 595 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *metadata_entry; |
| 596 | uint32_tcxx . . $ uint32_t# current_max_n_entries; |
| 597 | |
| 598 | rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, keys->iocxx . . $ _grn_hash#io., cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout.); |
| 599 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 600 | return rc; |
| 601 | } |
| 602 | |
| 603 | metadata_entry = |
| 604 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 605 | keys, |
| 606 | GRN_CACHE_PERSISTENT_METADATA_IDcxx . . $ `lib/cache.c:93:9`!, |
| 607 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 608 | |
| 609 | current_max_n_entries = metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries.; |
| 610 | metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries. = n; |
| 611 | if (n < current_max_n_entries) { |
| 612 | grn_cache_expire_persistent_without_lockcxx . . $ grn_cache_expire_persistent_without_lock(c205dd1ff4316349).(cache, current_max_n_entries - n); |
| 613 | } |
| 614 | grn_io_unlockcxx . . $ grn_io_unlock(341fd28fcb683921).(ctx, keys->iocxx . . $ _grn_hash#io.); |
| 615 | |
| 616 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 617 | } |
| 618 | |
| 619 | grn_rccxx . . $ grn_rc# |
| 620 | grn_cache_set_max_n_entriescxx . . $ grn_cache_set_max_n_entries(5e00bd443a95fa3d).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, unsigned int n) |
| 621 | { |
| 622 | if (!cache) { |
| 623 | return GRN_INVALID_ARGUMENTcxx . . $ GRN_INVALID_ARGUMENT.; |
| 624 | } |
| 625 | |
| 626 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 627 | return grn_cache_set_max_n_entries_memorycxx . . $ grn_cache_set_max_n_entries_memory(5e00bd443a95fa3d).(cache->ctxcxx . . $ _grn_cache#ctx., cache, n); |
| 628 | } else { |
| 629 | return grn_cache_set_max_n_entries_persistentcxx . . $ grn_cache_set_max_n_entries_persistent(5e00bd443a95fa3d).(cache->ctxcxx . . $ _grn_cache#ctx., cache, n); |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | static uint32_tcxx . . $ uint32_t# |
| 634 | grn_cache_get_max_n_entries_memorycxx . . $ grn_cache_get_max_n_entries_memory(ba86ec883991c18a).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache) |
| 635 | { |
| 636 | return cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries.; |
| 637 | } |
| 638 | |
| 639 | static uint32_tcxx . . $ uint32_t# |
| 640 | grn_cache_get_max_n_entries_persistentcxx . . $ grn_cache_get_max_n_entries_persistent(ba86ec883991c18a).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache) |
| 641 | { |
| 642 | grn_rccxx . . $ grn_rc# rc; |
| 643 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 644 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *metadata_entry; |
| 645 | uint32_tcxx . . $ uint32_t# current_max_n_entries; |
| 646 | |
| 647 | rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, keys->iocxx . . $ _grn_hash#io., cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout.); |
| 648 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | metadata_entry = |
| 653 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 654 | keys, |
| 655 | GRN_CACHE_PERSISTENT_METADATA_IDcxx . . $ `lib/cache.c:93:9`!, |
| 656 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 657 | current_max_n_entries = metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries.; |
| 658 | grn_io_unlockcxx . . $ grn_io_unlock(341fd28fcb683921).(ctx, keys->iocxx . . $ _grn_hash#io.); |
| 659 | |
| 660 | return current_max_n_entries; |
| 661 | } |
| 662 | |
| 663 | uint32_tcxx . . $ uint32_t# |
| 664 | grn_cache_get_max_n_entriescxx . . $ grn_cache_get_max_n_entries(ba86ec883991c18a).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache) |
| 665 | { |
| 666 | if (!cache) { |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 671 | return grn_cache_get_max_n_entries_memorycxx . . $ grn_cache_get_max_n_entries_memory(ba86ec883991c18a).(cache->ctxcxx . . $ _grn_cache#ctx., cache); |
| 672 | } else { |
| 673 | return grn_cache_get_max_n_entries_persistentcxx . . $ grn_cache_get_max_n_entries_persistent(ba86ec883991c18a).(cache->ctxcxx . . $ _grn_cache#ctx., cache); |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | static void |
| 678 | grn_cache_get_statistics_memorycxx . . $ grn_cache_get_statistics_memory(dcaf1d9c443b9507).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 679 | grn_cache_statisticscxx . . $ grn_cache_statistics# *statistics) |
| 680 | { |
| 681 | MUTEX_LOCKcxx . . $ `lib/grn.h:220:11`!(cache->impl.memory.mutex); |
| 682 | statistics->nentriescxx . . $ $anonymous_type_ec0490bd338ef9cc_0#nentries. = GRN_HASH_SIZEcxx . . $ `lib/grn_hash.h:376:9`!(cache->impl.memory.hash); |
| 683 | statistics->max_nentriescxx . . $ $anonymous_type_ec0490bd338ef9cc_0#max_nentries. = cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries.; |
| 684 | statistics->nfetchescxx . . $ $anonymous_type_ec0490bd338ef9cc_0#nfetches. = cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..nfetchescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nfetches.; |
| 685 | statistics->nhitscxx . . $ $anonymous_type_ec0490bd338ef9cc_0#nhits. = cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..nhitscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nhits.; |
| 686 | MUTEX_UNLOCKcxx . . $ `lib/grn.h:222:11`!(cache->impl.memory.mutex); |
| 687 | } |
| 688 | |
| 689 | static void |
| 690 | grn_cache_get_statistics_persistentcxx . . $ grn_cache_get_statistics_persistent(dcaf1d9c443b9507).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 691 | grn_cache_statisticscxx . . $ grn_cache_statistics# *statistics) |
| 692 | { |
| 693 | grn_rccxx . . $ grn_rc# rc = GRN_INVALID_ARGUMENTcxx . . $ GRN_INVALID_ARGUMENT.; |
| 694 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 695 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *metadata_entry; |
| 696 | |
| 697 | rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, keys->iocxx . . $ _grn_hash#io., cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout.); |
| 698 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 699 | return; |
| 700 | } |
| 701 | |
| 702 | metadata_entry = |
| 703 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 704 | keys, |
| 705 | GRN_CACHE_PERSISTENT_METADATA_IDcxx . . $ `lib/cache.c:93:9`!, |
| 706 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 707 | |
| 708 | statistics->nentriescxx . . $ $anonymous_type_ec0490bd338ef9cc_0#nentries. = GRN_HASH_SIZEcxx . . $ `lib/grn_hash.h:376:9`!(keys); |
| 709 | statistics->max_nentriescxx . . $ $anonymous_type_ec0490bd338ef9cc_0#max_nentries. = metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries.; |
| 710 | statistics->nfetchescxx . . $ $anonymous_type_ec0490bd338ef9cc_0#nfetches. = metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..nfetchescxx . . $ _grn_cache_entry_persistent_metadata#nfetches.; |
| 711 | statistics->nhitscxx . . $ $anonymous_type_ec0490bd338ef9cc_0#nhits. = metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..nhitscxx . . $ _grn_cache_entry_persistent_metadata#nhits.; |
| 712 | |
| 713 | grn_io_unlockcxx . . $ grn_io_unlock(341fd28fcb683921).(ctx, keys->iocxx . . $ _grn_hash#io.); |
| 714 | } |
| 715 | |
| 716 | void |
| 717 | grn_cache_get_statisticscxx . . $ grn_cache_get_statistics(dcaf1d9c443b9507).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 718 | grn_cache_statisticscxx . . $ grn_cache_statistics# *statistics) |
| 719 | { |
| 720 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 721 | grn_cache_get_statistics_memorycxx . . $ grn_cache_get_statistics_memory(dcaf1d9c443b9507).(ctx, cache, statistics); |
| 722 | } else { |
| 723 | grn_cache_get_statistics_persistentcxx . . $ grn_cache_get_statistics_persistent(dcaf1d9c443b9507).(ctx, cache, statistics); |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | static grn_rccxx . . $ grn_rc# |
| 728 | grn_cache_fetch_memorycxx . . $ grn_cache_fetch_memory(9d5d5d838b51bac8).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 729 | const char *key, uint32_tcxx . . $ uint32_t# key_len, |
| 730 | grn_objcxx . . $ grn_obj# *output) |
| 731 | { |
| 732 | /* TODO: How about GRN_NOT_FOUND? */ |
| 733 | grn_rccxx . . $ grn_rc# rc = GRN_INVALID_ARGUMENTcxx . . $ GRN_INVALID_ARGUMENT.; |
| 734 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *ce; |
| 735 | |
| 736 | MUTEX_LOCKcxx . . $ `lib/grn.h:220:11`!(cache->impl.memory.mutex); |
| 737 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..nfetchescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nfetches.++; |
| 738 | if (grn_hash_getcxx . . $ grn_hash_get(4e868e5367e71b67).(cache->ctxcxx . . $ _grn_cache#ctx., cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash., key, key_len, |
| 739 | (void **)&ce)) { |
| 740 | if (ce->tvcxx . . $ _grn_cache_entry_memory#tv..tv_seccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_sec. <= grn_db_get_last_modifiedcxx . . $ grn_db_get_last_modified(8dd58acc9865e889).(ctx, ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)) { |
| 741 | grn_cache_expire_entry_memorycxx . . $ grn_cache_expire_entry_memory(330f6164b12adfc4).(cache, ce); |
| 742 | goto exit; |
| 743 | } |
| 744 | rc = GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 745 | const char *value = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(ce->value); |
| 746 | size_t value_size = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(ce->value); |
| 747 | grn_cache_flagscxx . . $ grn_cache_flags# flags = 0; |
| 748 | if (value_size > sizeof(uint8_tcxx . . $ uint8_t#)) { |
| 749 | flags = *((uint8_tcxx . . $ uint8_t# *)value); |
| 750 | value += sizeof(uint8_tcxx . . $ uint8_t#); |
| 751 | value_size -= sizeof(uint8_tcxx . . $ uint8_t#); |
| 752 | } |
| 753 | if (flags & GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!) { |
| 754 | size_t used_size = grn_ctx_trace_log_restorecxx . . $ grn_ctx_trace_log_restore(e2e34019f4a887ab).(ctx, value, value_size); |
| 755 | value += used_size; |
| 756 | value_size -= used_size; |
| 757 | } |
| 758 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, value, value_size); |
| 759 | ce->prevcxx . . $ _grn_cache_entry_memory#prev.->nextcxx . . $ _grn_cache_entry_memory#next. = ce->nextcxx . . $ _grn_cache_entry_memory#next.; |
| 760 | ce->nextcxx . . $ _grn_cache_entry_memory#next.->prevcxx . . $ _grn_cache_entry_memory#prev. = ce->prevcxx . . $ _grn_cache_entry_memory#prev.; |
| 761 | { |
| 762 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *ce0 = |
| 763 | (grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *)(&(cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory.)); |
| 764 | ce->nextcxx . . $ _grn_cache_entry_memory#next. = ce0->nextcxx . . $ _grn_cache_entry_memory#next.; |
| 765 | ce->prevcxx . . $ _grn_cache_entry_memory#prev. = ce0; |
| 766 | ce0->nextcxx . . $ _grn_cache_entry_memory#next.->prevcxx . . $ _grn_cache_entry_memory#prev. = ce; |
| 767 | ce0->nextcxx . . $ _grn_cache_entry_memory#next. = ce; |
| 768 | } |
| 769 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..nhitscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#nhits.++; |
| 770 | } |
| 771 | exit : |
| 772 | MUTEX_UNLOCKcxx . . $ `lib/grn.h:222:11`!(cache->impl.memory.mutex); |
| 773 | return rc; |
| 774 | } |
| 775 | |
| 776 | static grn_rccxx . . $ grn_rc# |
| 777 | grn_cache_fetch_persistentcxx . . $ grn_cache_fetch_persistent(9d5d5d838b51bac8).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 778 | const char *key, uint32_tcxx . . $ uint32_t# key_len, |
| 779 | grn_objcxx . . $ grn_obj# *output) |
| 780 | { |
| 781 | /* TODO: How about GRN_NOT_FOUND? */ |
| 782 | grn_rccxx . . $ grn_rc# rc = GRN_INVALID_ARGUMENTcxx . . $ GRN_INVALID_ARGUMENT.; |
| 783 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 784 | grn_jacxx . . $ grn_ja# *values = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.; |
| 785 | grn_idcxx . . $ grn_id# cache_id; |
| 786 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *entry; |
| 787 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *metadata_entry; |
| 788 | |
| 789 | if (key_len == GRN_CACHE_PERSISTENT_ROOT_KEY_LENcxx . . $ `lib/cache.c:91:9`! && |
| 790 | memcmpcxx . . $ memcmp(36f949851efa3055).(key, |
| 791 | GRN_CACHE_PERSISTENT_ROOT_KEYcxx . . $ `lib/cache.c:90:9`!, |
| 792 | GRN_CACHE_PERSISTENT_ROOT_KEY_LENcxx . . $ `lib/cache.c:91:9`!) == 0) { |
| 793 | return rc; |
| 794 | } |
| 795 | |
| 796 | rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, keys->iocxx . . $ _grn_hash#io., cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout.); |
| 797 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 798 | return rc; |
| 799 | } |
| 800 | |
| 801 | /* TODO: How about GRN_NOT_FOUND? */ |
| 802 | rc = GRN_INVALID_ARGUMENTcxx . . $ GRN_INVALID_ARGUMENT.; |
| 803 | |
| 804 | metadata_entry = |
| 805 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 806 | keys, |
| 807 | GRN_CACHE_PERSISTENT_METADATA_IDcxx . . $ `lib/cache.c:93:9`!, |
| 808 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 809 | metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..nfetchescxx . . $ _grn_cache_entry_persistent_metadata#nfetches.++; |
| 810 | |
| 811 | cache_id = grn_hash_getcxx . . $ grn_hash_get(4e868e5367e71b67).(cache->ctxcxx . . $ _grn_cache#ctx., keys, key, key_len, (void **)&entry); |
| 812 | if (cache_id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 813 | goto exit; |
| 814 | } |
| 815 | |
| 816 | if (cache_id != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 817 | if (entry->datacxx . . $ _grn_cache_entry_persistent#data..modified_timecxx . . $ _grn_cache_entry_persistent_data#modified_time..tv_seccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_sec. <= |
| 818 | grn_db_get_last_modifiedcxx . . $ grn_db_get_last_modified(8dd58acc9865e889).(ctx, ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)) { |
| 819 | grn_cache_expire_entry_persistentcxx . . $ grn_cache_expire_entry_persistent(e347e0f90c9aee4e).(cache, entry, cache_id); |
| 820 | goto exit; |
| 821 | } |
| 822 | |
| 823 | rc = GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 824 | if (metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..flagscxx . . $ _grn_cache_entry_persistent_metadata#flags. & GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!) { |
| 825 | const uint8_tcxx . . $ uint8_t# *data; |
| 826 | uint32_tcxx . . $ uint32_t# data_size; |
| 827 | grn_io_wincxx . . $ grn_io_win# iw; |
| 828 | data = grn_ja_refcxx . . $ grn_ja_ref(e22c1a9426972524).(ctx, values, cache_id, &iw, &data_size); |
| 829 | if (data) { |
| 830 | grn_cache_flagscxx . . $ grn_cache_flags# flags = 0; |
| 831 | if (data_size > sizeof(uint8_tcxx . . $ uint8_t#)) { |
| 832 | flags = *data; |
| 833 | data += sizeof(uint8_tcxx . . $ uint8_t#); |
| 834 | data_size -= sizeof(uint8_tcxx . . $ uint8_t#); |
| 835 | } |
| 836 | if (flags & GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!) { |
| 837 | size_t used_size = grn_ctx_trace_log_restorecxx . . $ grn_ctx_trace_log_restore(e2e34019f4a887ab).(ctx, data, data_size); |
| 838 | data += used_size; |
| 839 | data_size -= used_size; |
| 840 | } |
| 841 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, data, data_size); |
| 842 | grn_ja_unrefcxx . . $ grn_ja_unref(2a637fdbe33921a9).(ctx, &iw); |
| 843 | } |
| 844 | } else { |
| 845 | grn_ja_get_valuecxx . . $ grn_ja_get_value(919dbbe2457c096b).(ctx, values, cache_id, output); |
| 846 | } |
| 847 | grn_cache_entry_persistent_delete_linkcxx . . $ grn_cache_entry_persistent_delete_link(b630b05c8bc92cfa).(cache, entry); |
| 848 | { |
| 849 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *head_entry; |
| 850 | head_entry = |
| 851 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 852 | keys, |
| 853 | GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`!, |
| 854 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 855 | grn_cache_entry_persistent_prepend_linkcxx . . $ grn_cache_entry_persistent_prepend_link(6476760daa537107).(cache, |
| 856 | entry, |
| 857 | cache_id, |
| 858 | head_entry, |
| 859 | GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`!); |
| 860 | } |
| 861 | metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..nhitscxx . . $ _grn_cache_entry_persistent_metadata#nhits.++; |
| 862 | } |
| 863 | |
| 864 | exit : |
| 865 | grn_io_unlockcxx . . $ grn_io_unlock(341fd28fcb683921).(ctx, keys->iocxx . . $ _grn_hash#io.); |
| 866 | |
| 867 | return rc; |
| 868 | } |
| 869 | |
| 870 | grn_rccxx . . $ grn_rc# |
| 871 | grn_cache_fetchcxx . . $ grn_cache_fetch(9d5d5d838b51bac8).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 872 | const char *key, uint32_tcxx . . $ uint32_t# key_len, |
| 873 | grn_objcxx . . $ grn_obj# *output) |
| 874 | { |
| 875 | if (!ctx->implcxx . . $ _grn_ctx#impl. || !ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.) { return GRN_INVALID_ARGUMENTcxx . . $ GRN_INVALID_ARGUMENT.; } |
| 876 | |
| 877 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 878 | return grn_cache_fetch_memorycxx . . $ grn_cache_fetch_memory(9d5d5d838b51bac8).(ctx, cache, key, key_len, output); |
| 879 | } else { |
| 880 | return grn_cache_fetch_persistentcxx . . $ grn_cache_fetch_persistent(9d5d5d838b51bac8).(ctx, cache, key, key_len, output); |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | static void |
| 885 | grn_cache_update_memorycxx . . $ grn_cache_update_memory(82f036e906f781c).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 886 | const char *key, uint32_tcxx . . $ uint32_t# key_len, |
| 887 | grn_objcxx . . $ grn_obj# *value) |
| 888 | { |
| 889 | grn_idcxx . . $ grn_id# id; |
| 890 | int added = 0; |
| 891 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *ce; |
| 892 | grn_rccxx . . $ grn_rc# rc = GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 893 | grn_objcxx . . $ grn_obj# *old = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 894 | grn_objcxx . . $ grn_obj# *obj = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 895 | |
| 896 | if (cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries. == 0) { |
| 897 | return; |
| 898 | } |
| 899 | |
| 900 | MUTEX_LOCKcxx . . $ `lib/grn.h:220:11`!(cache->impl.memory.mutex); |
| 901 | obj = grn_obj_opencxx . . $ grn_obj_open(688b82f5c18b4cf9).(cache->ctxcxx . . $ _grn_cache#ctx., GRN_BULKcxx . . $ `include/groonga/groonga.h:868:9`!, 0, GRN_DB_TEXTcxx . . $ GRN_DB_TEXT.); |
| 902 | if (!obj) { |
| 903 | goto exit; |
| 904 | } |
| 905 | grn_cache_flagscxx . . $ grn_cache_flags# flags = 0; |
| 906 | if (grn_ctx_trace_log_is_enabledcxx . . $ grn_ctx_trace_log_is_enabled(6769dd2542d68818).(ctx)) { |
| 907 | flags |= GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!; |
| 908 | } |
| 909 | GRN_UINT8_PUTcxx . . $ `include/groonga/groonga.h:3162:9`!(cache->ctx, obj, flags); |
| 910 | if (flags & GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!) { |
| 911 | grn_ctx_trace_log_dumpcxx . . $ grn_ctx_trace_log_dump(e1cc6b3f92033d3f).(ctx, cache->ctxcxx . . $ _grn_cache#ctx., obj); |
| 912 | } |
| 913 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(cache->ctx, obj, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(value), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(value)); |
| 914 | id = grn_hash_addcxx . . $ grn_hash_add(251a256fc515235e).(cache->ctxcxx . . $ _grn_cache#ctx., cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..hashcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#hash., key, key_len, |
| 915 | (void **)&ce, &added); |
| 916 | if (id) { |
| 917 | if (!added) { |
| 918 | old = ce->valuecxx . . $ _grn_cache_entry_memory#value.; |
| 919 | ce->prevcxx . . $ _grn_cache_entry_memory#prev.->nextcxx . . $ _grn_cache_entry_memory#next. = ce->nextcxx . . $ _grn_cache_entry_memory#next.; |
| 920 | ce->nextcxx . . $ _grn_cache_entry_memory#next.->prevcxx . . $ _grn_cache_entry_memory#prev. = ce->prevcxx . . $ _grn_cache_entry_memory#prev.; |
| 921 | } |
| 922 | ce->idcxx . . $ _grn_cache_entry_memory#id. = id; |
| 923 | ce->valuecxx . . $ _grn_cache_entry_memory#value. = obj; |
| 924 | ce->tvcxx . . $ _grn_cache_entry_memory#tv. = ctx->implcxx . . $ _grn_ctx#impl.->tvcxx . . $ _grn_ctx_impl#tv.; |
| 925 | { |
| 926 | grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *ce0 = |
| 927 | (grn_cache_entry_memorycxx . . $ grn_cache_entry_memory# *)(&(cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory.)); |
| 928 | ce->nextcxx . . $ _grn_cache_entry_memory#next. = ce0->nextcxx . . $ _grn_cache_entry_memory#next.; |
| 929 | ce->prevcxx . . $ _grn_cache_entry_memory#prev. = ce0; |
| 930 | ce0->nextcxx . . $ _grn_cache_entry_memory#next.->prevcxx . . $ _grn_cache_entry_memory#prev. = ce; |
| 931 | ce0->nextcxx . . $ _grn_cache_entry_memory#next. = ce; |
| 932 | } |
| 933 | if (GRN_HASH_SIZEcxx . . $ `lib/grn_hash.h:376:9`!(cache->impl.memory.hash) > |
| 934 | cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..max_nentriescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#max_nentries.) { |
| 935 | grn_cache_expire_entry_memorycxx . . $ grn_cache_expire_entry_memory(330f6164b12adfc4).(cache, cache->implcxx . . $ _grn_cache#impl..memorycxx . . $ _grn_cache#$anonymous_type_0#memory..prevcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_1#prev.); |
| 936 | } |
| 937 | } else { |
| 938 | rc = GRN_NO_MEMORY_AVAILABLEcxx . . $ GRN_NO_MEMORY_AVAILABLE.; |
| 939 | } |
| 940 | exit : |
| 941 | if (rc) { grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(cache->ctxcxx . . $ _grn_cache#ctx., obj); } |
| 942 | if (old) { grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(cache->ctxcxx . . $ _grn_cache#ctx., old); } |
| 943 | MUTEX_UNLOCKcxx . . $ `lib/grn.h:222:11`!(cache->impl.memory.mutex); |
| 944 | } |
| 945 | |
| 946 | static void |
| 947 | grn_cache_update_persistentcxx . . $ grn_cache_update_persistent(82f036e906f781c).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 948 | const char *key, uint32_tcxx . . $ uint32_t# key_len, |
| 949 | grn_objcxx . . $ grn_obj# *value) |
| 950 | { |
| 951 | grn_rccxx . . $ grn_rc# rc; |
| 952 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 953 | grn_jacxx . . $ grn_ja# *values = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..valuescxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#values.; |
| 954 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *metadata_entry; |
| 955 | grn_idcxx . . $ grn_id# cache_id; |
| 956 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *entry; |
| 957 | int added; |
| 958 | |
| 959 | if (key_len == GRN_CACHE_PERSISTENT_ROOT_KEY_LENcxx . . $ `lib/cache.c:91:9`! && |
| 960 | memcmpcxx . . $ memcmp(36f949851efa3055).(key, |
| 961 | GRN_CACHE_PERSISTENT_ROOT_KEYcxx . . $ `lib/cache.c:90:9`!, |
| 962 | GRN_CACHE_PERSISTENT_ROOT_KEY_LENcxx . . $ `lib/cache.c:91:9`!) == 0) { |
| 963 | return; |
| 964 | } |
| 965 | |
| 966 | if (key_len == GRN_CACHE_PERSISTENT_METADATA_KEY_LENcxx . . $ `lib/cache.c:95:9`! && |
| 967 | memcmpcxx . . $ memcmp(36f949851efa3055).(key, |
| 968 | GRN_CACHE_PERSISTENT_METADATA_KEYcxx . . $ `lib/cache.c:94:9`!, |
| 969 | GRN_CACHE_PERSISTENT_METADATA_KEY_LENcxx . . $ `lib/cache.c:95:9`!) == 0) { |
| 970 | return; |
| 971 | } |
| 972 | |
| 973 | rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, keys->iocxx . . $ _grn_hash#io., cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout.); |
| 974 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 975 | return; |
| 976 | } |
| 977 | |
| 978 | metadata_entry = |
| 979 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 980 | keys, |
| 981 | GRN_CACHE_PERSISTENT_METADATA_IDcxx . . $ `lib/cache.c:93:9`!, |
| 982 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 983 | if (metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries. == 0) { |
| 984 | goto exit; |
| 985 | } |
| 986 | |
| 987 | cache_id = grn_hash_addcxx . . $ grn_hash_add(251a256fc515235e).(cache->ctxcxx . . $ _grn_cache#ctx., keys, key, key_len, (void **)&entry, |
| 988 | &added); |
| 989 | if (cache_id) { |
| 990 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *head_entry; |
| 991 | |
| 992 | if (!added) { |
| 993 | grn_cache_entry_persistent_delete_linkcxx . . $ grn_cache_entry_persistent_delete_link(b630b05c8bc92cfa).(cache, entry); |
| 994 | } |
| 995 | entry->datacxx . . $ _grn_cache_entry_persistent#data..modified_timecxx . . $ _grn_cache_entry_persistent_data#modified_time. = ctx->implcxx . . $ _grn_ctx#impl.->tvcxx . . $ _grn_ctx_impl#tv.; |
| 996 | |
| 997 | if (metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..flagscxx . . $ _grn_cache_entry_persistent_metadata#flags. & GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!) { |
| 998 | grn_objcxx . . $ grn_obj# data; |
| 999 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&data, 0); |
| 1000 | grn_cache_flagscxx . . $ grn_cache_flags# flags = 0; |
| 1001 | if (grn_ctx_trace_log_is_enabledcxx . . $ grn_ctx_trace_log_is_enabled(6769dd2542d68818).(ctx)) { |
| 1002 | flags |= GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!; |
| 1003 | } |
| 1004 | GRN_UINT8_PUTcxx . . $ `include/groonga/groonga.h:3162:9`!(cache->ctx, &data, flags); |
| 1005 | if (flags & GRN_CACHE_FLAG_WITH_TRACE_LOGcxx . . $ `lib/cache.c:32:9`!) { |
| 1006 | grn_ctx_trace_log_dumpcxx . . $ grn_ctx_trace_log_dump(e1cc6b3f92033d3f).(ctx, cache->ctxcxx . . $ _grn_cache#ctx., &data); |
| 1007 | } |
| 1008 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(cache->ctx, &data, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(value), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(value)); |
| 1009 | grn_ja_putcxx . . $ grn_ja_put(35c973a3630485be).(cache->ctxcxx . . $ _grn_cache#ctx., |
| 1010 | values, |
| 1011 | cache_id, |
| 1012 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&data), |
| 1013 | (uint32_tcxx . . $ uint32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&data), |
| 1014 | GRN_OBJ_SETcxx . . $ `include/groonga/groonga.h:1466:9`!, |
| 1015 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 1016 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(cache->ctx, &data); |
| 1017 | } else { |
| 1018 | grn_ja_putcxx . . $ grn_ja_put(35c973a3630485be).(cache->ctxcxx . . $ _grn_cache#ctx., |
| 1019 | values, |
| 1020 | cache_id, |
| 1021 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(value), |
| 1022 | (uint32_tcxx . . $ uint32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(value), |
| 1023 | GRN_OBJ_SETcxx . . $ `include/groonga/groonga.h:1466:9`!, |
| 1024 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 1025 | } |
| 1026 | |
| 1027 | head_entry = |
| 1028 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 1029 | keys, |
| 1030 | GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`!, |
| 1031 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 1032 | grn_cache_entry_persistent_prepend_linkcxx . . $ grn_cache_entry_persistent_prepend_link(6476760daa537107).(cache, |
| 1033 | entry, |
| 1034 | cache_id, |
| 1035 | head_entry, |
| 1036 | GRN_CACHE_PERSISTENT_ROOT_IDcxx . . $ `lib/cache.c:89:9`!); |
| 1037 | if (GRN_HASH_SIZEcxx . . $ `lib/grn_hash.h:376:9`!(keys) > metadata_entry->metadatacxx . . $ _grn_cache_entry_persistent#metadata..max_nentriescxx . . $ _grn_cache_entry_persistent_metadata#max_nentries.) { |
| 1038 | grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *tail_entry; |
| 1039 | tail_entry = |
| 1040 | (grn_cache_entry_persistentcxx . . $ grn_cache_entry_persistent# *)grn_hash_get_value_cxx . . $ grn_hash_get_value_(9e5907222c08364c).(ctx, |
| 1041 | keys, |
| 1042 | head_entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev., |
| 1043 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 1044 | grn_cache_expire_entry_persistentcxx . . $ grn_cache_expire_entry_persistent(e347e0f90c9aee4e).(cache, |
| 1045 | tail_entry, |
| 1046 | head_entry->datacxx . . $ _grn_cache_entry_persistent#data..prevcxx . . $ _grn_cache_entry_persistent_data#prev.); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | exit : |
| 1051 | grn_io_unlockcxx . . $ grn_io_unlock(341fd28fcb683921).(ctx, keys->iocxx . . $ _grn_hash#io.); |
| 1052 | } |
| 1053 | |
| 1054 | void |
| 1055 | grn_cache_updatecxx . . $ grn_cache_update(82f036e906f781c).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_cachecxx . . $ grn_cache# *cache, |
| 1056 | const char *key, uint32_tcxx . . $ uint32_t# key_len, grn_objcxx . . $ grn_obj# *value) |
| 1057 | { |
| 1058 | if (!ctx->implcxx . . $ _grn_ctx#impl.) { return; } |
| 1059 | |
| 1060 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 1061 | grn_cache_update_memorycxx . . $ grn_cache_update_memory(82f036e906f781c).(ctx, cache, key, key_len, value); |
| 1062 | } else { |
| 1063 | grn_cache_update_persistentcxx . . $ grn_cache_update_persistent(82f036e906f781c).(ctx, cache, key, key_len, value); |
| 1064 | } |
| 1065 | } |
| 1066 | |
| 1067 | static void |
| 1068 | grn_cache_expire_memorycxx . . $ grn_cache_expire_memory(c205dd1ff4316349).(grn_cachecxx . . $ grn_cache# *cache, uint32_tcxx . . $ uint32_t# size) |
| 1069 | { |
| 1070 | MUTEX_LOCKcxx . . $ `lib/grn.h:220:11`!(cache->impl.memory.mutex); |
| 1071 | grn_cache_expire_memory_without_lockcxx . . $ grn_cache_expire_memory_without_lock(c205dd1ff4316349).(cache, size); |
| 1072 | MUTEX_UNLOCKcxx . . $ `lib/grn.h:222:11`!(cache->impl.memory.mutex); |
| 1073 | } |
| 1074 | |
| 1075 | static void |
| 1076 | grn_cache_expire_persistentcxx . . $ grn_cache_expire_persistent(c205dd1ff4316349).(grn_cachecxx . . $ grn_cache# *cache, uint32_tcxx . . $ uint32_t# size) |
| 1077 | { |
| 1078 | grn_rccxx . . $ grn_rc# rc; |
| 1079 | grn_ctxcxx . . $ grn_ctx# *ctx = cache->ctxcxx . . $ _grn_cache#ctx.; |
| 1080 | grn_hashcxx . . $ grn_hash# *keys = cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..keyscxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#keys.; |
| 1081 | |
| 1082 | rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, keys->iocxx . . $ _grn_hash#io., cache->implcxx . . $ _grn_cache#impl..persistentcxx . . $ _grn_cache#$anonymous_type_0#persistent..timeoutcxx . . $ _grn_cache#$anonymous_type_0#$anonymous_type_2#timeout.); |
| 1083 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 1084 | return; |
| 1085 | } |
| 1086 | |
| 1087 | grn_cache_expire_persistent_without_lockcxx . . $ grn_cache_expire_persistent_without_lock(c205dd1ff4316349).(cache, size); |
| 1088 | |
| 1089 | grn_io_unlockcxx . . $ grn_io_unlock(341fd28fcb683921).(ctx, keys->iocxx . . $ _grn_hash#io.); |
| 1090 | } |
| 1091 | |
| 1092 | void |
| 1093 | grn_cache_expirecxx . . $ grn_cache_expire(c205dd1ff4316349).(grn_cachecxx . . $ grn_cache# *cache, uint32_tcxx . . $ uint32_t# size) |
| 1094 | { |
| 1095 | if (cache->is_memorycxx . . $ _grn_cache#is_memory.) { |
| 1096 | grn_cache_expire_memorycxx . . $ grn_cache_expire_memory(c205dd1ff4316349).(cache, size); |
| 1097 | } else { |
| 1098 | grn_cache_expire_persistentcxx . . $ grn_cache_expire_persistent(c205dd1ff4316349).(cache, size); |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | void |
| 1103 | grn_cache_fincxx . . $ grn_cache_fin(49f6e7a06ebc5aa8).(void) |
| 1104 | { |
| 1105 | grn_ctxcxx . . $ grn_ctx# *ctx = &grn_cache_ctxcxx . . $ grn_cache_ctx.; |
| 1106 | |
| 1107 | grn_cache_current_setcxx . . $ grn_cache_current_set(f6beb3535a4b847).(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 1108 | |
| 1109 | if (grn_cache_defaultcxx . . $ grn_cache_default.) { |
| 1110 | grn_cache_closecxx . . $ grn_cache_close(f6beb3535a4b847).(ctx, grn_cache_defaultcxx . . $ grn_cache_default.); |
| 1111 | grn_cache_defaultcxx . . $ grn_cache_default. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 1112 | } |
| 1113 | |
| 1114 | grn_ctx_fincxx . . $ grn_ctx_fin(2b4fa601bf4f1e5b).(ctx); |
| 1115 | } |