| 1 | /* |
| 2 | Copyright (C) 2011-2018 Brazil |
| 3 | Copyright (C) 2018-2026 Sutou Kouhei <[email protected]> |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include "grn.h"cxx . . $ `<file>/lib/grn.h`/ |
| 21 | #include <sys/types.h> |
| 22 | #include <sys/stat.h> |
| 23 | #include <cstring> |
| 24 | #include <sstream> |
| 25 | #include <new> |
| 26 | #include "grn_ctx_impl.h"cxx . . $ `<file>/lib/grn_ctx_impl.h`/ |
| 27 | #include "grn_str.h"cxx . . $ `<file>/lib/grn_str.h`/ |
| 28 | #include "grn_io.h"cxx . . $ `<file>/lib/grn_io.h`/ |
| 29 | #include "grn_dat.h"cxx . . $ `<file>/lib/grn_dat.h`/ |
| 30 | #include "grn_normalizer.h"cxx . . $ `<file>/lib/grn_normalizer.h`/ |
| 31 | #include "grn_obj.h"cxx . . $ `<file>/lib/grn_obj.h`/ |
| 32 | #include "grn_util.h"cxx . . $ `<file>/lib/grn_util.h`/ |
| 33 | #include "grn_wal.h"cxx . . $ `<file>/lib/grn_wal.h`/ |
| 34 | |
| 35 | #include "dat/trie.hpp"cxx . . $ `<file>/lib/dat/trie.hpp`/ |
| 36 | #include "dat/cursor-factory.hpp"cxx . . $ `<file>/lib/dat/cursor-factory.hpp`/ |
| 37 | |
| 38 | namespacecxx . . $ `$anonymous_namespace_lib/dat.cpp`/ { |
| 39 | |
| 40 | const uint32_tcxx . . $ uint32_t# FILE_ID_LENGTHcxx . . $ `$anonymous_namespace_lib/dat.cpp`/FILE_ID_LENGTH. = 3; |
| 41 | |
| 42 | class CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# { |
| 43 | public: |
| 44 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(49f6e7a06ebc5aa8).() : lock_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#lock_.(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!) {} |
| 45 | explicit CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(4f83bfebf4bb9c8b).(grn_critical_sectioncxx . . $ grn_critical_section# *lock) : lock_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#lock_.(lock) |
| 46 | { |
| 47 | CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(*lock_); |
| 48 | } |
| 49 | ~cxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#`~CriticalSection`(ced63f7c635d850d).CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#() { leavecxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#leave(49f6e7a06ebc5aa8).(); } |
| 50 | |
| 51 | void |
| 52 | entercxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#enter(4f83bfebf4bb9c8b).(grn_critical_sectioncxx . . $ grn_critical_section# *lock) |
| 53 | { |
| 54 | leavecxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#leave(49f6e7a06ebc5aa8).(); |
| 55 | lock_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#lock_. = lock; |
| 56 | } |
| 57 | void |
| 58 | leavecxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#leave(49f6e7a06ebc5aa8).() |
| 59 | { |
| 60 | if (lock_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#lock_. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!) { |
| 61 | CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(*lock_); |
| 62 | lock_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#lock_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | private: |
| 67 | grn_critical_sectioncxx . . $ grn_critical_section# *lock_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#lock_.; |
| 68 | |
| 69 | // Disallows copy and assignment. |
| 70 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(8ae4e9064adfddc7).(const CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# &); |
| 71 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# & |
| 72 | operatorcxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#`operator=`(c7e284962c2f669e).=(const CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# &); |
| 73 | }; |
| 74 | |
| 75 | static inline int |
| 76 | grn_dat_namecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_name(c21018f0b7f786f0).(grn_ctx *ctx, grn_dat *dat, char *buffer, int buffer_size) |
| 77 | { |
| 78 | int name_size; |
| 79 | |
| 80 | if (DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(dat)->id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 81 | grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(buffer, buffer_size, "(anonymous)"); |
| 82 | name_size = strlen(buffer); |
| 83 | } else { |
| 84 | name_size = grn_obj_name(ctx, (grn_obj *)dat, buffer, buffer_size); |
| 85 | } |
| 86 | |
| 87 | return name_size; |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | grn_dat_remove_file() removes a file specified by `path' and then returns |
| 92 | true on success, false on failure. Note that grn_dat_remove_file() does not |
| 93 | change `ctx->rc'. |
| 94 | */ |
| 95 | bool |
| 96 | grn_dat_remove_filecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_remove_file(445bcde47c288915).(grn_ctx *ctx, const char *path) |
| 97 | { |
| 98 | struct stat stat; |
| 99 | |
| 100 | if (::stat(path, &stat) == -1) { |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | if (grn_unlinkcxx . . $ `include/groonga/portability.h:88:11`!(path) == -1) { |
| 105 | const char *system_message = grn_strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 106 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 107 | GRN_LOG_WARNING, |
| 108 | "[dat][remove-file] failed to remove path: %s: <%s>", |
| 109 | system_message, |
| 110 | path); |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_INFO, "[dat][remove-file] removed: <%s>", path); |
| 115 | return true; |
| 116 | } |
| 117 | |
| 118 | grn_rc |
| 119 | grn_dat_translate_error_codecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_translate_error_code(620446ddef249864).(grncxx . . $ grn/::datcxx . . $ grn/dat/::ErrorCodecxx . . $ grn/dat/ErrorCode# error_code) |
| 120 | { |
| 121 | switch (error_code) { |
| 122 | case grncxx . . $ grn/::datcxx . . $ grn/dat/::PARAM_ERRORcxx . . $ grn/dat/PARAM_ERROR.: |
| 123 | { |
| 124 | return GRN_INVALID_ARGUMENT; |
| 125 | } |
| 126 | case grncxx . . $ grn/::datcxx . . $ grn/dat/::IO_ERRORcxx . . $ grn/dat/IO_ERROR.: |
| 127 | { |
| 128 | return GRN_INPUT_OUTPUT_ERROR; |
| 129 | } |
| 130 | case grncxx . . $ grn/::datcxx . . $ grn/dat/::FORMAT_ERRORcxx . . $ grn/dat/FORMAT_ERROR.: |
| 131 | { |
| 132 | return GRN_INVALID_FORMAT; |
| 133 | } |
| 134 | case grncxx . . $ grn/::datcxx . . $ grn/dat/::MEMORY_ERRORcxx . . $ grn/dat/MEMORY_ERROR.: |
| 135 | { |
| 136 | return GRN_NO_MEMORY_AVAILABLE; |
| 137 | } |
| 138 | case grncxx . . $ grn/::datcxx . . $ grn/dat/::SIZE_ERRORcxx . . $ grn/dat/SIZE_ERROR.: |
| 139 | case grncxx . . $ grn/::datcxx . . $ grn/dat/::UNEXPECTED_ERRORcxx . . $ grn/dat/UNEXPECTED_ERROR.: |
| 140 | { |
| 141 | return GRN_UNKNOWN_ERROR; |
| 142 | } |
| 143 | case grncxx . . $ grn/::datcxx . . $ grn/dat/::STATUS_ERRORcxx . . $ grn/dat/STATUS_ERROR.: |
| 144 | { |
| 145 | return GRN_FILE_CORRUPT; |
| 146 | } |
| 147 | default: |
| 148 | { |
| 149 | return GRN_UNKNOWN_ERROR; |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | void |
| 155 | grn_dat_initcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_init(e79ecd4e4b1242ae).(grn_ctx *ctx, grn_dat *dat) |
| 156 | { |
| 157 | GRN_DB_OBJ_SET_TYPEcxx . . $ `lib/grn_ctx.h:195:9`!(dat, GRN_TABLE_DAT_KEYcxx . . $ `include/groonga/groonga.h:897:9`!); |
| 158 | dat->iocxx . . $ _grn_dat#io. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 159 | dat->headercxx . . $ _grn_dat#header. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 160 | dat->file_idcxx . . $ _grn_dat#file_id. = 0; |
| 161 | dat->encodingcxx . . $ _grn_dat#encoding. = GRN_ENC_DEFAULT; |
| 162 | dat->triecxx . . $ _grn_dat#trie. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 163 | dat->old_triecxx . . $ _grn_dat#old_trie. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 164 | grn_table_module_init(ctx, &(dat->tokenizercxx . . $ _grn_dat#tokenizer.), GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 165 | grn_table_modules_init(ctx, &(dat->normalizerscxx . . $ _grn_dat#normalizers.)); |
| 166 | grn_table_modules_init(ctx, &(dat->token_filterscxx . . $ _grn_dat#token_filters.)); |
| 167 | GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&(dat->token_filter_procs), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 168 | grn_table_modules_init(ctx, &(dat->extractorscxx . . $ _grn_dat#extractors.)); |
| 169 | CRITICAL_SECTION_INITcxx . . $ `lib/grn.h:226:11`!(dat->lock); |
| 170 | dat->is_dirtycxx . . $ _grn_dat#is_dirty. = false; |
| 171 | } |
| 172 | |
| 173 | static void |
| 174 | grn_dat_close_token_filterscxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_close_token_filters(e79ecd4e4b1242ae).(grn_ctx *ctx, grn_dat *dat) |
| 175 | { |
| 176 | grn_table_modules_fin(ctx, &(dat->token_filterscxx . . $ _grn_dat#token_filters.)); |
| 177 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(dat->token_filter_procs)); |
| 178 | } |
| 179 | |
| 180 | void |
| 181 | grn_dat_fincxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_fin(e79ecd4e4b1242ae).(grn_ctx *ctx, grn_dat *dat) |
| 182 | { |
| 183 | CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(dat->lock); |
| 184 | delete static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->old_triecxx . . $ _grn_dat#old_trie.); |
| 185 | delete static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 186 | dat->old_triecxx . . $ _grn_dat#old_trie. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 187 | dat->triecxx . . $ _grn_dat#trie. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 188 | if (dat->iocxx . . $ _grn_dat#io.) { |
| 189 | if (dat->is_dirtycxx . . $ _grn_dat#is_dirty.) { |
| 190 | uint32_tcxx . . $ uint32_t# n_dirty_opens; |
| 191 | GRN_ATOMIC_ADD_EXcxx . . $ `lib/grn.h:420:11`!(&(dat->header->n_dirty_opens), -1, n_dirty_opens); |
| 192 | } |
| 193 | grn_io_close(ctx, dat->iocxx . . $ _grn_dat#io.); |
| 194 | dat->iocxx . . $ _grn_dat#io. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 195 | } |
| 196 | grn_table_module_fin(ctx, &(dat->tokenizercxx . . $ _grn_dat#tokenizer.)); |
| 197 | grn_table_modules_fin(ctx, &(dat->normalizerscxx . . $ _grn_dat#normalizers.)); |
| 198 | grn_dat_close_token_filterscxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_close_token_filters(e79ecd4e4b1242ae).(ctx, dat); |
| 199 | grn_table_modules_fin(ctx, &(dat->extractorscxx . . $ _grn_dat#extractors.)); |
| 200 | } |
| 201 | |
| 202 | /* |
| 203 | grn_dat_generate_trie_path() generates the path from `base_path' and |
| 204 | `file_id'. The generated path is stored in `trie_path'. |
| 205 | */ |
| 206 | void |
| 207 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(const char *base_path, |
| 208 | char *trie_path, |
| 209 | uint32_tcxx . . $ uint32_t# file_id) |
| 210 | { |
| 211 | if (!base_path || !base_path[0]) { |
| 212 | trie_path[0] = '\0'; |
| 213 | return; |
| 214 | } |
| 215 | const size_t len = stdcxx . . $ std/::strlen(base_path); |
| 216 | grn_memcpycxx . . $ `include/groonga/portability.h:30:13`!(trie_path, base_path, len); |
| 217 | trie_path[len] = '.'; |
| 218 | grn_itoh(file_id % (1U << (4 * FILE_ID_LENGTHcxx . . $ `$anonymous_namespace_lib/dat.cpp`/FILE_ID_LENGTH.)), |
| 219 | trie_path + len + 1, |
| 220 | FILE_ID_LENGTHcxx . . $ `$anonymous_namespace_lib/dat.cpp`/FILE_ID_LENGTH.); |
| 221 | trie_path[len + 1 + FILE_ID_LENGTHcxx . . $ `$anonymous_namespace_lib/dat.cpp`/FILE_ID_LENGTH.] = '\0'; |
| 222 | } |
| 223 | |
| 224 | bool |
| 225 | grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(grn_ctx *ctx, grn_dat *dat) |
| 226 | { |
| 227 | if (!dat) { |
| 228 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "dat is null"); |
| 229 | return false; |
| 230 | } |
| 231 | |
| 232 | const uint32_tcxx . . $ uint32_t# file_id = dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.; |
| 233 | if (!file_id || (dat->triecxx . . $ _grn_dat#trie. && (file_id <= dat->file_idcxx . . $ _grn_dat#file_id.))) { |
| 234 | /* |
| 235 | There is no need to open file when no trie file is available or the |
| 236 | current trie file is the latest one. |
| 237 | */ |
| 238 | return true; |
| 239 | } |
| 240 | |
| 241 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# critical_sectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(4f83bfebf4bb9c8b).(&dat->lockcxx . . $ _grn_dat#lock.); |
| 242 | |
| 243 | if (dat->triecxx . . $ _grn_dat#trie. && (file_id <= dat->file_idcxx . . $ _grn_dat#file_id.)) { |
| 244 | /* |
| 245 | There is no need to open file if the latest file has been opened by |
| 246 | another thread. |
| 247 | */ |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 252 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), trie_path, file_id); |
| 253 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 254 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const old_trie = |
| 255 | static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->old_triecxx . . $ _grn_dat#old_trie.); |
| 256 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const new_trie = new (stdcxx . . $ std/::nothrowcxx . . $ std/nothrow.) grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie#; |
| 257 | if (!new_trie) { |
| 258 | MERRcxx . . $ `lib/grn_error.h:158:9`!("new grn::dat::Trie failed"); |
| 259 | return false; |
| 260 | } |
| 261 | |
| 262 | if (trie_path[0] == '\0') { |
| 263 | try { |
| 264 | new_trie->createcxx . . $ grn/dat/Trie#create(effadf6d9e160e1f).(trie_path); |
| 265 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 266 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 267 | "grn::dat::Trie::create failed: %s", |
| 268 | ex.what()); |
| 269 | delete new_trie; |
| 270 | return false; |
| 271 | } |
| 272 | } else { |
| 273 | try { |
| 274 | new_trie->opencxx . . $ grn/dat/Trie#open(85c52e162fed56f9).(trie_path); |
| 275 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 276 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 277 | "grn::dat::Trie::open failed: %s", |
| 278 | ex.what()); |
| 279 | delete new_trie; |
| 280 | return false; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | dat->old_triecxx . . $ _grn_dat#old_trie. = trie; |
| 285 | dat->triecxx . . $ _grn_dat#trie. = new_trie; |
| 286 | dat->file_idcxx . . $ _grn_dat#file_id. = file_id; |
| 287 | |
| 288 | critical_section.leavecxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#leave(49f6e7a06ebc5aa8).(); |
| 289 | |
| 290 | delete old_trie; |
| 291 | if (file_id >= 3) { |
| 292 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), trie_path, file_id - 2); |
| 293 | grn_dat_remove_filecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_remove_file(445bcde47c288915).(ctx, trie_path); |
| 294 | } |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | bool |
| 299 | grn_dat_rebuild_triecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_rebuild_trie(80a67896fab8adf8).(grn_ctx *ctx, grn_dat *dat) |
| 300 | { |
| 301 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 302 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const new_trie = new (stdcxx . . $ std/::nothrowcxx . . $ std/nothrow.) grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie#; |
| 303 | if (!new_trie) { |
| 304 | MERRcxx . . $ `lib/grn_error.h:158:9`!("new grn::dat::Trie failed"); |
| 305 | return false; |
| 306 | } |
| 307 | |
| 308 | const uint32_tcxx . . $ uint32_t# file_id = dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.; |
| 309 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 310 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), trie_path, file_id + 1); |
| 311 | |
| 312 | for (uint64_tcxx . . $ uint64_t# file_size = trie->file_sizecxx . . $ grn/dat/Trie#file_size(fe4d2d262d4164a8).() * 2;; file_size *= 2) { |
| 313 | try { |
| 314 | new_trie->createcxx . . $ grn/dat/Trie#create(f9e26080e2580924).(*trie, trie_path, file_size); |
| 315 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::SizeErrorcxx . . $ grn/dat/SizeError# &) { |
| 316 | continue; |
| 317 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 318 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 319 | "grn::dat::Trie::open failed: %s", |
| 320 | ex.what()); |
| 321 | delete new_trie; |
| 322 | return false; |
| 323 | } |
| 324 | break; |
| 325 | } |
| 326 | |
| 327 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const old_trie = |
| 328 | static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->old_triecxx . . $ _grn_dat#old_trie.); |
| 329 | dat->old_triecxx . . $ _grn_dat#old_trie. = dat->triecxx . . $ _grn_dat#trie.; |
| 330 | dat->triecxx . . $ _grn_dat#trie. = new_trie; |
| 331 | dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id. = dat->file_idcxx . . $ _grn_dat#file_id. = file_id + 1; |
| 332 | |
| 333 | delete old_trie; |
| 334 | if (file_id >= 2) { |
| 335 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 336 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), trie_path, file_id - 1); |
| 337 | grn_dat_remove_filecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_remove_file(445bcde47c288915).(ctx, trie_path); |
| 338 | } |
| 339 | return true; |
| 340 | } |
| 341 | |
| 342 | grn_id |
| 343 | grn_dat_add_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_add_internal(4a06744752b4ca7e).(grn_ctx *ctx, |
| 344 | grn_dat *dat, |
| 345 | const void *key, |
| 346 | unsigned int key_size, |
| 347 | int *added) |
| 348 | { |
| 349 | if (!dat->triecxx . . $ _grn_dat#trie.) { |
| 350 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 351 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), trie_path, 1); |
| 352 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const new_trie = new (stdcxx . . $ std/::nothrowcxx . . $ std/nothrow.) grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie#; |
| 353 | if (!new_trie) { |
| 354 | MERRcxx . . $ `lib/grn_error.h:158:9`!("new grn::dat::Trie failed"); |
| 355 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 356 | } |
| 357 | try { |
| 358 | new_trie->createcxx . . $ grn/dat/Trie#create(effadf6d9e160e1f).(trie_path); |
| 359 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 360 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 361 | "grn::dat::Trie::create failed: %s", |
| 362 | ex.what()); |
| 363 | delete new_trie; |
| 364 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 365 | } |
| 366 | dat->triecxx . . $ _grn_dat#trie. = new_trie; |
| 367 | dat->file_idcxx . . $ _grn_dat#file_id. = dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id. = 1; |
| 368 | } |
| 369 | |
| 370 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 371 | try { |
| 372 | grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_pos; |
| 373 | const bool res = trie->insertcxx . . $ grn/dat/Trie#insert(ae4305a9e007baab).(key, key_size, &key_pos); |
| 374 | if (added) { |
| 375 | *added = res ? 1 : 0; |
| 376 | } |
| 377 | return trie->get_keycxx . . $ grn/dat/Trie#get_key(ac1ad672cda84f14).(key_pos).idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).(); |
| 378 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::SizeErrorcxx . . $ grn/dat/SizeError# &) { |
| 379 | if (!grn_dat_rebuild_triecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_rebuild_trie(80a67896fab8adf8).(ctx, dat)) { |
| 380 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 381 | } |
| 382 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const new_trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 383 | grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_pos; |
| 384 | const bool res = new_trie->insertcxx . . $ grn/dat/Trie#insert(ae4305a9e007baab).(key, key_size, &key_pos); |
| 385 | if (added) { |
| 386 | *added = res ? 1 : 0; |
| 387 | } |
| 388 | return new_trie->get_keycxx . . $ grn/dat/Trie#get_key(ac1ad672cda84f14).(key_pos).idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).(); |
| 389 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 390 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 391 | "grn::dat::Trie::insert failed: %s", |
| 392 | ex.what()); |
| 393 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | grn_rc |
| 398 | grn_dat_delete_by_id_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_delete_by_id_internal(97bd2e456bacf171).(grn_ctx *ctx, grn_dat *dat, grn_id id) |
| 399 | { |
| 400 | try { |
| 401 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 402 | if (!trie->removecxx . . $ grn/dat/Trie#remove(dfa6e707f7696010).(id)) { |
| 403 | return GRN_INVALID_ARGUMENT; |
| 404 | } |
| 405 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 406 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 407 | "grn::dat::Trie::remove failed: %s", |
| 408 | ex.what()); |
| 409 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 410 | } |
| 411 | return GRN_SUCCESS; |
| 412 | } |
| 413 | |
| 414 | grn_rc |
| 415 | grn_dat_delete_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_delete_internal(50cab4fc2376a3ac).(grn_ctx *ctx, |
| 416 | grn_dat *dat, |
| 417 | const void *key, |
| 418 | unsigned int key_size) |
| 419 | { |
| 420 | try { |
| 421 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 422 | if (!trie->removecxx . . $ grn/dat/Trie#remove(d56749dd304d51d2).(key, key_size)) { |
| 423 | return GRN_INVALID_ARGUMENT; |
| 424 | } |
| 425 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 426 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 427 | "grn::dat::Trie::remove failed: %s", |
| 428 | ex.what()); |
| 429 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 430 | } |
| 431 | return GRN_SUCCESS; |
| 432 | } |
| 433 | |
| 434 | grn_rc |
| 435 | grn_dat_update_by_id_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_update_by_id_internal(fc3962e251224b9e).(grn_ctx *ctx, |
| 436 | grn_dat *dat, |
| 437 | grn_id src_key_id, |
| 438 | const void *dest_key, |
| 439 | unsigned int dest_key_size) |
| 440 | { |
| 441 | try { |
| 442 | try { |
| 443 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 444 | if (!trie->updatecxx . . $ grn/dat/Trie#update(79b99470cec845e1).(src_key_id, dest_key, dest_key_size)) { |
| 445 | return GRN_INVALID_ARGUMENT; |
| 446 | } |
| 447 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::SizeErrorcxx . . $ grn/dat/SizeError# &) { |
| 448 | if (!grn_dat_rebuild_triecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_rebuild_trie(80a67896fab8adf8).(ctx, dat)) { |
| 449 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 450 | } |
| 451 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 452 | if (!trie->updatecxx . . $ grn/dat/Trie#update(79b99470cec845e1).(src_key_id, dest_key, dest_key_size)) { |
| 453 | return GRN_INVALID_ARGUMENT; |
| 454 | } |
| 455 | } |
| 456 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 457 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 458 | "grn::dat::Trie::update failed: %s", |
| 459 | ex.what()); |
| 460 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 461 | } |
| 462 | return GRN_SUCCESS; |
| 463 | } |
| 464 | |
| 465 | grn_rc |
| 466 | grn_dat_update_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_update_internal(79e345af04dd0233).(grn_ctx *ctx, |
| 467 | grn_dat *dat, |
| 468 | const void *src_key, |
| 469 | unsigned int src_key_size, |
| 470 | const void *dest_key, |
| 471 | unsigned int dest_key_size) |
| 472 | { |
| 473 | try { |
| 474 | try { |
| 475 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 476 | if (!trie->updatecxx . . $ grn/dat/Trie#update(f81369781b5607b4).(src_key, src_key_size, dest_key, dest_key_size)) { |
| 477 | return GRN_INVALID_ARGUMENT; |
| 478 | } |
| 479 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::SizeErrorcxx . . $ grn/dat/SizeError# &) { |
| 480 | if (!grn_dat_rebuild_triecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_rebuild_trie(80a67896fab8adf8).(ctx, dat)) { |
| 481 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 482 | } |
| 483 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 484 | if (!trie->updatecxx . . $ grn/dat/Trie#update(f81369781b5607b4).(src_key, src_key_size, dest_key, dest_key_size)) { |
| 485 | return GRN_INVALID_ARGUMENT; |
| 486 | } |
| 487 | } |
| 488 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 489 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 490 | "grn::dat::Trie::update failed: %s", |
| 491 | ex.what()); |
| 492 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 493 | } |
| 494 | return GRN_SUCCESS; |
| 495 | } |
| 496 | |
| 497 | void |
| 498 | grn_dat_cursor_initcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_cursor_init(92ac03129a489a03).(grn_ctx *, grn_dat_cursor *cursor) |
| 499 | { |
| 500 | GRN_DB_OBJ_SET_TYPEcxx . . $ `lib/grn_ctx.h:195:9`!(cursor, GRN_CURSOR_TABLE_DAT_KEYcxx . . $ `include/groonga/groonga.h:887:9`!); |
| 501 | cursor->datcxx . . $ _grn_dat_cursor#dat. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 502 | cursor->cursorcxx . . $ _grn_dat_cursor#cursor. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 503 | cursor->keycxx . . $ _grn_dat_cursor#key. = &grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key#::invalid_keycxx . . $ grn/dat/Key#invalid_key(741ea5814372790).(); |
| 504 | cursor->curr_reccxx . . $ _grn_dat_cursor#curr_rec. = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 505 | } |
| 506 | |
| 507 | void |
| 508 | grn_dat_cursor_fincxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_cursor_fin(92ac03129a489a03).(grn_ctx *, grn_dat_cursor *cursor) |
| 509 | { |
| 510 | delete static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Cursorcxx . . $ grn/dat/Cursor# *>(cursor->cursorcxx . . $ _grn_dat_cursor#cursor.); |
| 511 | cursor->datcxx . . $ _grn_dat_cursor#dat. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 512 | cursor->cursorcxx . . $ _grn_dat_cursor#cursor. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 513 | cursor->keycxx . . $ _grn_dat_cursor#key. = &grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key#::invalid_keycxx . . $ grn/dat/Key#invalid_key(741ea5814372790).(); |
| 514 | cursor->curr_reccxx . . $ _grn_dat_cursor#curr_rec. = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 515 | } |
| 516 | |
| 517 | void |
| 518 | grn_dat_wal_set_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_wal_set_wal_id(f12c088a05d7846a).(grn_ctx *, grn_dat *dat, uint64_tcxx . . $ uint64_t# id) |
| 519 | { |
| 520 | dat->headercxx . . $ _grn_dat#header.->wal_idcxx . . $ grn_dat_header#wal_id. = id; |
| 521 | } |
| 522 | |
| 523 | class WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# { |
| 524 | private: |
| 525 | struct Usedcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used# { |
| 526 | bool record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#record_id.; |
| 527 | bool keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#key.; |
| 528 | bool new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#new_key.; |
| 529 | }; |
| 530 | |
| 531 | public: |
| 532 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#WALRecorder(b15d84ac2a300338).(grn_ctx *ctx, grn_dat *dat, const char *tag) |
| 533 | : ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_.(ctx), |
| 534 | dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.(dat), |
| 535 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_.(tag), |
| 536 | wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_.(0), |
| 537 | eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event.(GRN_WAL_EVENT_NIL), |
| 538 | record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id.(GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!), |
| 539 | keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key.(nullptr), |
| 540 | key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size.(0) |
| 541 | { |
| 542 | } |
| 543 | |
| 544 | grn_rc |
| 545 | recordcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record(d5bb96df31a8101).() |
| 546 | { |
| 547 | if (GRN_CTX_GET_WAL_ROLEcxx . . $ `lib/grn_ctx_impl.h:233:9`!(ctx_) == GRN_WAL_ROLE_NONE) { |
| 548 | return GRN_SUCCESS; |
| 549 | } |
| 550 | if (!dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.->iocxx . . $ _grn_dat#io.) { |
| 551 | return GRN_SUCCESS; |
| 552 | } |
| 553 | if (dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.->iocxx . . $ _grn_dat#io.->pathcxx . . $ _grn_io#path.[0] == '\0') { |
| 554 | return GRN_SUCCESS; |
| 555 | } |
| 556 | |
| 557 | grn_rc rc = GRN_SUCCESS; |
| 558 | const char *usage = ""; |
| 559 | Usedcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used# used; |
| 560 | |
| 561 | switch (eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event.) { |
| 562 | case GRN_WAL_EVENT_ADD_ENTRY: |
| 563 | usage = "adding entry"; |
| 564 | rc = record_add_entrycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_add_entry(1c6bb06064ae019c).(used); |
| 565 | break; |
| 566 | case GRN_WAL_EVENT_DELETE_ENTRY: |
| 567 | usage = "deleting entry"; |
| 568 | rc = record_delete_entrycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_delete_entry(1c6bb06064ae019c).(used); |
| 569 | break; |
| 570 | case GRN_WAL_EVENT_UPDATE_ENTRY: |
| 571 | usage = "updating entry"; |
| 572 | rc = record_update_entrycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_update_entry(1c6bb06064ae019c).(used); |
| 573 | break; |
| 574 | default: |
| 575 | usage = "not implemented event"; |
| 576 | rc = GRN_FUNCTION_NOT_IMPLEMENTED; |
| 577 | break; |
| 578 | } |
| 579 | |
| 580 | if (rc != GRN_SUCCESS) { |
| 581 | auto details = format_detailscxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#format_details(a667cdb4152121f1).(used); |
| 582 | grn_obj_set_error(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_., |
| 583 | reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.), |
| 584 | rc, |
| 585 | record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id., |
| 586 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_., |
| 587 | "failed to add WAL entry for %s: %s", |
| 588 | usage, |
| 589 | details.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 590 | } |
| 591 | |
| 592 | return rc; |
| 593 | } |
| 594 | |
| 595 | void |
| 596 | apply_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#apply_wal_id(49f6e7a06ebc5aa8).() |
| 597 | { |
| 598 | grn_dat_wal_set_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_wal_set_wal_id(f12c088a05d7846a).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_., dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_., wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_.); |
| 599 | } |
| 600 | |
| 601 | private: |
| 602 | grn_ctx *ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_.; |
| 603 | grn_dat *dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.; |
| 604 | const char *tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_.; |
| 605 | uint64_tcxx . . $ uint64_t# wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_.; |
| 606 | |
| 607 | public: |
| 608 | grn_wal_event eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event.; |
| 609 | grn_id record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id.; |
| 610 | const void *keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key.; |
| 611 | size_t key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size.; |
| 612 | const void *new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key.; |
| 613 | size_t new_key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key_size.; |
| 614 | |
| 615 | private: |
| 616 | // Disallows copy and assignment. |
| 617 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#WALRecorder(38b49d415ff9c169).(const WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# &); |
| 618 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# & |
| 619 | operatorcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#`operator=`(d1b93260c37f12c9).=(const WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# &); |
| 620 | |
| 621 | grn_rc |
| 622 | record_add_entrycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_add_entry(1c6bb06064ae019c).(Usedcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used# &used) |
| 623 | { |
| 624 | used.keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#key. = true; |
| 625 | return grn_wal_add_entry(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_., |
| 626 | reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.), |
| 627 | false, |
| 628 | &wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_., |
| 629 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_., |
| 630 | |
| 631 | GRN_WAL_KEY_EVENT, |
| 632 | GRN_WAL_VALUE_EVENT, |
| 633 | eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event., |
| 634 | |
| 635 | GRN_WAL_KEY_KEY, |
| 636 | GRN_WAL_VALUE_BINARY, |
| 637 | keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key., |
| 638 | key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size., |
| 639 | |
| 640 | GRN_WAL_KEY_END); |
| 641 | } |
| 642 | |
| 643 | grn_rc |
| 644 | record_delete_entrycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_delete_entry(1c6bb06064ae019c).(Usedcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used# &used) |
| 645 | { |
| 646 | if (record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id. == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 647 | used.keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#key. = true; |
| 648 | return grn_wal_add_entry(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_., |
| 649 | reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.), |
| 650 | false, |
| 651 | &wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_., |
| 652 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_., |
| 653 | |
| 654 | GRN_WAL_KEY_EVENT, |
| 655 | GRN_WAL_VALUE_EVENT, |
| 656 | eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event., |
| 657 | |
| 658 | GRN_WAL_KEY_KEY, |
| 659 | GRN_WAL_VALUE_BINARY, |
| 660 | keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key., |
| 661 | key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size., |
| 662 | |
| 663 | GRN_WAL_KEY_END); |
| 664 | } else { |
| 665 | used.record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#record_id. = true; |
| 666 | return grn_wal_add_entry(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_., |
| 667 | reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.), |
| 668 | false, |
| 669 | &wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_., |
| 670 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_., |
| 671 | |
| 672 | GRN_WAL_KEY_EVENT, |
| 673 | GRN_WAL_VALUE_EVENT, |
| 674 | eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event., |
| 675 | |
| 676 | GRN_WAL_KEY_RECORD_ID, |
| 677 | GRN_WAL_VALUE_RECORD_ID, |
| 678 | record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id., |
| 679 | |
| 680 | GRN_WAL_KEY_END); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | grn_rc |
| 685 | record_update_entrycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_update_entry(1c6bb06064ae019c).(Usedcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used# &used) |
| 686 | { |
| 687 | if (record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id. == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 688 | used.keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#key. = true; |
| 689 | used.new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#new_key. = true; |
| 690 | return grn_wal_add_entry(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_., |
| 691 | reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.), |
| 692 | false, |
| 693 | &wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_., |
| 694 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_., |
| 695 | |
| 696 | GRN_WAL_KEY_EVENT, |
| 697 | GRN_WAL_VALUE_EVENT, |
| 698 | eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event., |
| 699 | |
| 700 | GRN_WAL_KEY_KEY, |
| 701 | GRN_WAL_VALUE_BINARY, |
| 702 | keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key., |
| 703 | key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size., |
| 704 | |
| 705 | GRN_WAL_KEY_NEW_KEY, |
| 706 | GRN_WAL_VALUE_BINARY, |
| 707 | new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key., |
| 708 | new_key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key_size., |
| 709 | |
| 710 | GRN_WAL_KEY_END); |
| 711 | } else { |
| 712 | used.record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#record_id. = true; |
| 713 | used.new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#new_key. = true; |
| 714 | return grn_wal_add_entry(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#ctx_., |
| 715 | reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#dat_.), |
| 716 | false, |
| 717 | &wal_id_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#wal_id_., |
| 718 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#tag_., |
| 719 | |
| 720 | GRN_WAL_KEY_EVENT, |
| 721 | GRN_WAL_VALUE_EVENT, |
| 722 | eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event., |
| 723 | |
| 724 | GRN_WAL_KEY_RECORD_ID, |
| 725 | GRN_WAL_VALUE_RECORD_ID, |
| 726 | record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id., |
| 727 | |
| 728 | GRN_WAL_KEY_NEW_KEY, |
| 729 | GRN_WAL_VALUE_BINARY, |
| 730 | new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key., |
| 731 | new_key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key_size., |
| 732 | |
| 733 | GRN_WAL_KEY_END); |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | stdcxx . . $ std/::stringcxx . . $ std/string# |
| 738 | format_detailscxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#format_details(a667cdb4152121f1).(const Usedcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used# &used) |
| 739 | { |
| 740 | stdcxx . . $ std/::ostringstreamcxx . . $ std/ostringstream# detailscxx . . $ std/__cxx11/basic_ostringstream#basic_ostringstream(49f6e7a06ebc5aa8).; |
| 741 | details <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "event:" <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "<" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). grn_wal_event_to_string(eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event.) |
| 742 | <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "> "; |
| 743 | if (used.record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#record_id.) { |
| 744 | details <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "record-id:" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 745 | } |
| 746 | if (used.keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#key.) { |
| 747 | details <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "key-size:" <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 748 | } |
| 749 | if (used.new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#Used#new_key.) { |
| 750 | details <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "new-key-size:" <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). new_key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key_size. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " "; |
| 751 | } |
| 752 | return details.strcxx . . $ std/__cxx11/basic_ostringstream#str(d33e1a6fd36255f7).(); |
| 753 | } |
| 754 | }; |
| 755 | |
| 756 | class WALRecoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer# { |
| 757 | public: |
| 758 | WALRecoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#WALRecoverer(e79ecd4e4b1242ae).(grn_ctx *ctx, grn_dat *dat) |
| 759 | : ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.(ctx), |
| 760 | dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.(dat), |
| 761 | wal_error_tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#wal_error_tag_.("[dat]"), |
| 762 | tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#tag_.("[dat][wal][recover]") |
| 763 | { |
| 764 | } |
| 765 | |
| 766 | grn_rc |
| 767 | recovercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#recover(d5bb96df31a8101).() |
| 768 | { |
| 769 | if (ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 770 | return ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc.; |
| 771 | } |
| 772 | |
| 773 | auto reader = |
| 774 | grn_wal_reader_open(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.), tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#tag_.); |
| 775 | if (ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 776 | return ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc.; |
| 777 | } |
| 778 | |
| 779 | bool need_flush = false; |
| 780 | if (grn_io_is_locked(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.->iocxx . . $ _grn_dat#io.)) { |
| 781 | grn_io_clear_lock(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.->iocxx . . $ _grn_dat#io.); |
| 782 | need_flush = true; |
| 783 | } |
| 784 | |
| 785 | if (grn_dat_is_changing(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.)) { |
| 786 | grn_dat_clear_status_flags(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.); |
| 787 | need_flush = true; |
| 788 | } |
| 789 | |
| 790 | if (reader) { |
| 791 | while (true) { |
| 792 | grn_wal_reader_entry entry = {}; |
| 793 | grn_rc rc = grn_wal_reader_read_entry(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., reader, &entry); |
| 794 | if (rc != GRN_SUCCESS) { |
| 795 | break; |
| 796 | } |
| 797 | switch (entry.event) { |
| 798 | case GRN_WAL_EVENT_ADD_ENTRY: |
| 799 | grn_dat_add_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_add_internal(4a06744752b4ca7e).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., |
| 800 | dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_., |
| 801 | entry.key.content.binary.data, |
| 802 | entry.key.content.binary.size, |
| 803 | nullptr); |
| 804 | break; |
| 805 | case GRN_WAL_EVENT_DELETE_ENTRY: |
| 806 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.)) { |
| 807 | break; |
| 808 | } |
| 809 | if (entry.record_id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 810 | grn_dat_delete_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_delete_internal(50cab4fc2376a3ac).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., |
| 811 | dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_., |
| 812 | entry.key.content.binary.data, |
| 813 | entry.key.content.binary.size); |
| 814 | } else { |
| 815 | grn_dat_delete_by_id_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_delete_by_id_internal(97bd2e456bacf171).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_., entry.record_id); |
| 816 | } |
| 817 | break; |
| 818 | case GRN_WAL_EVENT_UPDATE_ENTRY: |
| 819 | if (entry.record_id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 820 | grn_dat_update_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_update_internal(79e345af04dd0233).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., |
| 821 | dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_., |
| 822 | entry.key.content.binary.data, |
| 823 | entry.key.content.binary.size, |
| 824 | entry.new_key.content.binary.data, |
| 825 | entry.new_key.content.binary.size); |
| 826 | } else { |
| 827 | grn_dat_update_by_id_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_update_by_id_internal(fc3962e251224b9e).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., |
| 828 | dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_., |
| 829 | entry.record_id, |
| 830 | entry.new_key.content.binary.data, |
| 831 | entry.new_key.content.binary.size); |
| 832 | } |
| 833 | break; |
| 834 | default: |
| 835 | grn_wal_set_recover_error(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., |
| 836 | GRN_FUNCTION_NOT_IMPLEMENTED, |
| 837 | reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.), |
| 838 | &entry, |
| 839 | wal_error_tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#wal_error_tag_., |
| 840 | "not implemented yet"); |
| 841 | break; |
| 842 | } |
| 843 | if (ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 844 | break; |
| 845 | } |
| 846 | grn_dat_wal_set_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_wal_set_wal_id(f12c088a05d7846a).(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_., entry.id); |
| 847 | need_flush = true; |
| 848 | } |
| 849 | grn_wal_reader_close(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., reader); |
| 850 | } |
| 851 | |
| 852 | if (ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 853 | auto ctx = ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.; |
| 854 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(dat_); |
| 855 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx_, |
| 856 | GRN_LOG_NOTICE, |
| 857 | "%s repair broken double array trie: <%.*s>(%u)", |
| 858 | tag_, |
| 859 | name_size, |
| 860 | name, |
| 861 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(dat_)->id); |
| 862 | grn_rc repair_rc = grn_dat_repair(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.); |
| 863 | if (repair_rc == GRN_SUCCESS) { |
| 864 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx_); |
| 865 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx_, |
| 866 | GRN_LOG_NOTICE, |
| 867 | "%s succeeded to repair broken double array trie: <%.*s>(%u)", |
| 868 | tag_, |
| 869 | name_size, |
| 870 | name, |
| 871 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(dat_)->id); |
| 872 | need_flush = true; |
| 873 | } else { |
| 874 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx_, |
| 875 | GRN_LOG_ERROR, |
| 876 | "%s failed to recover double array trie: <%.*s>(%u): %s", |
| 877 | tag_, |
| 878 | name_size, |
| 879 | name, |
| 880 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(dat_)->id, |
| 881 | ctx->errbuf); |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | if (need_flush && ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 886 | grn_obj_touch(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 887 | grn_obj_flush(ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_., reinterpret_cast<grn_obj *>(dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.)); |
| 888 | } |
| 889 | |
| 890 | return ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc.; |
| 891 | } |
| 892 | |
| 893 | private: |
| 894 | grn_ctx *ctx_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#ctx_.; |
| 895 | grn_dat *dat_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#dat_.; |
| 896 | const char *wal_error_tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#wal_error_tag_.; |
| 897 | const char *tag_cxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#tag_.; |
| 898 | |
| 899 | // Disallows copy and assignment. |
| 900 | WALRecoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#WALRecoverer(6d95b934bfc4282c).(const WALRecoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer# &); |
| 901 | WALRecoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer# & |
| 902 | operatorcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#`operator=`(41119aab5bbb2e93).=(const WALRecoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer# &); |
| 903 | }; |
| 904 | |
| 905 | } // namespace |
| 906 | |
| 907 | extern "C" { |
| 908 | |
| 909 | grn_dat * |
| 910 | grn_dat_create( |
| 911 | grn_ctx *ctx, const char *path, uint32_tcxx . . $ uint32_t#, uint32_tcxx . . $ uint32_t#, uint32_tcxx . . $ uint32_t# flags) |
| 912 | { |
| 913 | if (path) { |
| 914 | if (path[0] == '\0') { |
| 915 | path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 916 | } else if (stdcxx . . $ std/::strlen(path) >= (PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! - (FILE_ID_LENGTHcxx . . $ `$anonymous_namespace_lib/dat.cpp`/FILE_ID_LENGTH. + 1))) { |
| 917 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_FILENAME_TOO_LONG, "too long path"); |
| 918 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | grn_dat *const dat = static_cast<grn_dat *>(GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(grn_dat))); |
| 923 | if (!dat) { |
| 924 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 925 | } |
| 926 | grn_dat_initcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_init(e79ecd4e4b1242ae).(ctx, dat); |
| 927 | |
| 928 | dat->iocxx . . $ _grn_dat#io. = grn_io_create(ctx, |
| 929 | path, |
| 930 | sizeof(struct grn_dat_headercxx . . $ grn_dat_header#), |
| 931 | 4096, |
| 932 | 0, |
| 933 | GRN_IO_AUTO, |
| 934 | GRN_IO_EXPIRE_SEGMENTcxx . . $ `lib/grn_io.h:195:9`!); |
| 935 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 936 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(dat); |
| 937 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 938 | } |
| 939 | grn_io_set_type(dat->iocxx . . $ _grn_dat#io., GRN_TABLE_DAT_KEYcxx . . $ `include/groonga/groonga.h:897:9`!); |
| 940 | |
| 941 | dat->headercxx . . $ _grn_dat#header. = static_cast<struct grn_dat_headercxx . . $ grn_dat_header# *>(grn_io_header(dat->iocxx . . $ _grn_dat#io.)); |
| 942 | if (!dat->headercxx . . $ _grn_dat#header.) { |
| 943 | grn_dat_fincxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_fin(e79ecd4e4b1242ae).(ctx, dat); |
| 944 | grn_dat_remove_filecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_remove_file(445bcde47c288915).(ctx, path); |
| 945 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(dat); |
| 946 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 947 | } |
| 948 | const grn_encoding encoding = |
| 949 | (ctx->encodingcxx . . $ _grn_ctx#encoding. != GRN_ENC_DEFAULT) ? ctx->encodingcxx . . $ _grn_ctx#encoding. : grn_gctx.encodingcxx . . $ _grn_ctx#encoding.; |
| 950 | dat->headercxx . . $ _grn_dat#header.->flagscxx . . $ grn_dat_header#flags. = flags; |
| 951 | dat->headercxx . . $ _grn_dat#header.->encodingcxx . . $ grn_dat_header#encoding. = encoding; |
| 952 | dat->headercxx . . $ _grn_dat#header.->tokenizercxx . . $ grn_dat_header#tokenizer. = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 953 | dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id. = 0; |
| 954 | if (dat->headercxx . . $ _grn_dat#header.->flagscxx . . $ grn_dat_header#flags. & GRN_OBJ_KEY_NORMALIZEcxx . . $ `include/groonga/groonga.h:718:9`!) { |
| 955 | dat->headercxx . . $ _grn_dat#header.->flagscxx . . $ grn_dat_header#flags. &= ~GRN_OBJ_KEY_NORMALIZEcxx . . $ `include/groonga/groonga.h:718:9`!; |
| 956 | dat->headercxx . . $ _grn_dat#header.->normalizercxx . . $ grn_dat_header#normalizer. = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 957 | grn_obj *normalizer = grn_ctx_get(ctx, GRN_NORMALIZER_AUTO_NAMEcxx . . $ `lib/grn_normalizer.h:32:9`!, -1); |
| 958 | grn_table_modules_add(ctx, &(dat->normalizerscxx . . $ _grn_dat#normalizers.), normalizer); |
| 959 | } else { |
| 960 | dat->headercxx . . $ _grn_dat#header.->normalizercxx . . $ grn_dat_header#normalizer. = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 961 | } |
| 962 | dat->headercxx . . $ _grn_dat#header.->n_dirty_openscxx . . $ grn_dat_header#n_dirty_opens. = 0; |
| 963 | dat->headercxx . . $ _grn_dat#header.->wal_idcxx . . $ grn_dat_header#wal_id. = 0; |
| 964 | dat->encodingcxx . . $ _grn_dat#encoding. = encoding; |
| 965 | |
| 966 | dat->objcxx . . $ _grn_dat#obj..header.flags = dat->headercxx . . $ _grn_dat#header.->flagscxx . . $ grn_dat_header#flags.; |
| 967 | |
| 968 | return dat; |
| 969 | } |
| 970 | |
| 971 | grn_dat * |
| 972 | grn_dat_open(grn_ctx *ctx, const char *path) |
| 973 | { |
| 974 | if (path && (stdcxx . . $ std/::strlen(path) >= (PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! - (FILE_ID_LENGTHcxx . . $ `$anonymous_namespace_lib/dat.cpp`/FILE_ID_LENGTH. + 1)))) { |
| 975 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_FILENAME_TOO_LONG, "too long path"); |
| 976 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 977 | } |
| 978 | |
| 979 | grn_dat *const dat = static_cast<grn_dat *>(GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(grn_dat))); |
| 980 | if (!dat) { |
| 981 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 982 | } |
| 983 | |
| 984 | grn_dat_initcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_init(e79ecd4e4b1242ae).(ctx, dat); |
| 985 | dat->iocxx . . $ _grn_dat#io. = grn_io_open(ctx, path, GRN_IO_AUTO); |
| 986 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 987 | // Don't reset rc by grn_dat_fin(). |
| 988 | grn_rc rc = ctx->rccxx . . $ _grn_ctx#rc.; |
| 989 | grn_dat_fincxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_fin(e79ecd4e4b1242ae).(ctx, dat); |
| 990 | ctx->rccxx . . $ _grn_ctx#rc. = rc; |
| 991 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(dat); |
| 992 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 993 | } |
| 994 | |
| 995 | dat->headercxx . . $ _grn_dat#header. = (struct grn_dat_headercxx . . $ grn_dat_header# *)grn_io_header(dat->iocxx . . $ _grn_dat#io.); |
| 996 | if (!dat->headercxx . . $ _grn_dat#header.) { |
| 997 | grn_dat_fincxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_fin(e79ecd4e4b1242ae).(ctx, dat); |
| 998 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(dat); |
| 999 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1000 | } |
| 1001 | dat->file_idcxx . . $ _grn_dat#file_id. = dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.; |
| 1002 | dat->encodingcxx . . $ _grn_dat#encoding. = dat->headercxx . . $ _grn_dat#header.->encodingcxx . . $ grn_dat_header#encoding.; |
| 1003 | if (dat->headercxx . . $ _grn_dat#header.->tokenizercxx . . $ grn_dat_header#tokenizer. != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 1004 | grn_table_module_set_proc(ctx, |
| 1005 | &(dat->tokenizercxx . . $ _grn_dat#tokenizer.), |
| 1006 | grn_ctx_at(ctx, dat->headercxx . . $ _grn_dat#header.->tokenizercxx . . $ grn_dat_header#tokenizer.)); |
| 1007 | } |
| 1008 | if (dat->headercxx . . $ _grn_dat#header.->flagscxx . . $ grn_dat_header#flags. & GRN_OBJ_KEY_NORMALIZEcxx . . $ `include/groonga/groonga.h:718:9`!) { |
| 1009 | dat->headercxx . . $ _grn_dat#header.->flagscxx . . $ grn_dat_header#flags. &= ~GRN_OBJ_KEY_NORMALIZEcxx . . $ `include/groonga/groonga.h:718:9`!; |
| 1010 | dat->headercxx . . $ _grn_dat#header.->normalizercxx . . $ grn_dat_header#normalizer. = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1011 | grn_obj *normalizer = grn_ctx_get(ctx, GRN_NORMALIZER_AUTO_NAMEcxx . . $ `lib/grn_normalizer.h:32:9`!, -1); |
| 1012 | grn_table_modules_add(ctx, &(dat->normalizerscxx . . $ _grn_dat#normalizers.), normalizer); |
| 1013 | } else if (dat->headercxx . . $ _grn_dat#header.->normalizercxx . . $ grn_dat_header#normalizer. != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 1014 | grn_obj *normalizer = grn_ctx_at(ctx, dat->headercxx . . $ _grn_dat#header.->normalizercxx . . $ grn_dat_header#normalizer.); |
| 1015 | grn_table_modules_add(ctx, &(dat->normalizerscxx . . $ _grn_dat#normalizers.), normalizer); |
| 1016 | } |
| 1017 | dat->objcxx . . $ _grn_dat#obj..header.flags = dat->headercxx . . $ _grn_dat#header.->flagscxx . . $ grn_dat_header#flags.; |
| 1018 | return dat; |
| 1019 | } |
| 1020 | |
| 1021 | grn_rc |
| 1022 | grn_dat_close(grn_ctx *ctx, grn_dat *dat) |
| 1023 | { |
| 1024 | if (dat) { |
| 1025 | if (dat->iocxx . . $ _grn_dat#io.->pathcxx . . $ _grn_io#path.[0] != '\0' && |
| 1026 | GRN_CTX_GET_WAL_ROLEcxx . . $ `lib/grn_ctx_impl.h:233:9`!(ctx) == GRN_WAL_ROLE_PRIMARY) { |
| 1027 | grn_obj_flush(ctx, reinterpret_cast<grn_obj *>(dat)); |
| 1028 | } |
| 1029 | grn_dat_fincxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_fin(e79ecd4e4b1242ae).(ctx, dat); |
| 1030 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(dat); |
| 1031 | } |
| 1032 | return GRN_SUCCESS; |
| 1033 | } |
| 1034 | |
| 1035 | grn_rc |
| 1036 | grn_dat_remove(grn_ctx *ctx, const char *path) |
| 1037 | { |
| 1038 | if (!path) { |
| 1039 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "path is null"); |
| 1040 | return GRN_INVALID_ARGUMENT; |
| 1041 | } |
| 1042 | |
| 1043 | grn_dat *const dat = grn_dat_open(ctx, path); |
| 1044 | if (!dat) { |
| 1045 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1046 | } |
| 1047 | const uint32_tcxx . . $ uint32_t# file_id = dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.; |
| 1048 | grn_dat_close(ctx, dat); |
| 1049 | |
| 1050 | /* |
| 1051 | grn_dat_remove() tries to remove (file_id + 1)th trie file because |
| 1052 | grn::dat::Trie::create() might leave an incomplete file on failure. |
| 1053 | */ |
| 1054 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 1055 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(path, trie_path, file_id + 1); |
| 1056 | grn_dat_remove_filecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_remove_file(445bcde47c288915).(ctx, trie_path); |
| 1057 | for (uint32_tcxx . . $ uint32_t# i = file_id; i > 0; --i) { |
| 1058 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(path, trie_path, i); |
| 1059 | if (!grn_dat_remove_filecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_remove_file(445bcde47c288915).(ctx, trie_path)) { |
| 1060 | break; |
| 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | /* |
| 1065 | grn_io_remove() reports an error when it fails to remove `path'. |
| 1066 | */ |
| 1067 | grn_rc wal_rc = grn_wal_remove(ctx, path, "[dat]"); |
| 1068 | grn_rc io_rc = grn_io_remove(ctx, path); |
| 1069 | grn_rc rc = wal_rc; |
| 1070 | if (rc == GRN_SUCCESS) { |
| 1071 | rc = io_rc; |
| 1072 | } |
| 1073 | return rc; |
| 1074 | } |
| 1075 | |
| 1076 | grn_id |
| 1077 | grn_dat_get( |
| 1078 | grn_ctx *ctx, grn_dat *dat, const void *key, unsigned int key_size, void **) |
| 1079 | { |
| 1080 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1081 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1082 | } |
| 1083 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = |
| 1084 | static_cast<const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1085 | if (!trie) { |
| 1086 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1087 | } |
| 1088 | grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_pos; |
| 1089 | try { |
| 1090 | if (trie->searchcxx . . $ grn/dat/Trie#search(7a1a0c33e94d66be).(key, key_size, &key_pos)) { |
| 1091 | return trie->get_keycxx . . $ grn/dat/Trie#get_key(ac1ad672cda84f14).(key_pos).idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).(); |
| 1092 | } |
| 1093 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1094 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 1095 | "grn::dat::Trie::search failed: %s", |
| 1096 | ex.what()); |
| 1097 | } |
| 1098 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1099 | } |
| 1100 | |
| 1101 | grn_id |
| 1102 | grn_dat_add(grn_ctx *ctx, |
| 1103 | grn_dat *dat, |
| 1104 | const void *key, |
| 1105 | unsigned int key_size, |
| 1106 | void **, |
| 1107 | int *added) |
| 1108 | { |
| 1109 | if (!key_size) { |
| 1110 | char name[GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!]; |
| 1111 | int name_size; |
| 1112 | name_size = grn_dat_namecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_name(c21018f0b7f786f0).(ctx, dat, name, GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!); |
| 1113 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, |
| 1114 | "[dat] key size must not zero: <%.*s>", |
| 1115 | name_size, |
| 1116 | name); |
| 1117 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1118 | } else if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1119 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1120 | } |
| 1121 | |
| 1122 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# recordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#WALRecorder(b15d84ac2a300338).(ctx, dat, "[dat][add]"); |
| 1123 | recorder.eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event. = GRN_WAL_EVENT_ADD_ENTRY; |
| 1124 | recorder.keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key. = key; |
| 1125 | recorder.key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size. = key_size; |
| 1126 | if (recorder.recordcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record(d5bb96df31a8101).() != GRN_SUCCESS) { |
| 1127 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1128 | } |
| 1129 | |
| 1130 | grn_id id = grn_dat_add_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_add_internal(4a06744752b4ca7e).(ctx, dat, key, key_size, added); |
| 1131 | if (id != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 1132 | recorder.apply_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#apply_wal_id(49f6e7a06ebc5aa8).(); |
| 1133 | } |
| 1134 | return id; |
| 1135 | } |
| 1136 | |
| 1137 | int |
| 1138 | grn_dat_get_key( |
| 1139 | grn_ctx *ctx, grn_dat *dat, grn_id id, void *keybuf, int bufsize) |
| 1140 | { |
| 1141 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1142 | return 0; |
| 1143 | } |
| 1144 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = |
| 1145 | static_cast<const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1146 | if (!trie) { |
| 1147 | return 0; |
| 1148 | } |
| 1149 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key = trie->ith_keycxx . . $ grn/dat/Trie#ith_key(ac1ad672cda84f14).(id); |
| 1150 | if (!key.is_validcxx . . $ grn/dat/Key#is_valid(50ce9a9e25b4a850).()) { |
| 1151 | return 0; |
| 1152 | } |
| 1153 | if (keybuf && (bufsize >= (int)key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).())) { |
| 1154 | grn_memcpycxx . . $ `include/groonga/portability.h:30:13`!(keybuf, key.ptr(), key.length()); |
| 1155 | } |
| 1156 | return (int)key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1157 | } |
| 1158 | |
| 1159 | int |
| 1160 | grn_dat_get_key2(grn_ctx *ctx, grn_dat *dat, grn_id id, grn_obj *bulk) |
| 1161 | { |
| 1162 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1163 | return 0; |
| 1164 | } |
| 1165 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = |
| 1166 | static_cast<const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1167 | if (!trie) { |
| 1168 | return 0; |
| 1169 | } |
| 1170 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key = trie->ith_keycxx . . $ grn/dat/Trie#ith_key(ac1ad672cda84f14).(id); |
| 1171 | if (!key.is_validcxx . . $ grn/dat/Key#is_valid(50ce9a9e25b4a850).()) { |
| 1172 | return 0; |
| 1173 | } |
| 1174 | if (bulk->headercxx . . $ _grn_obj#header..impl_flags & GRN_OBJ_REFERcxx . . $ `include/groonga/groonga.h:935:9`!) { |
| 1175 | bulk->ucxx . . $ _grn_obj#u..bcxx . . $ _grn_obj#$anonymous_type_0#b..headcxx . . $ _grn_obj#$anonymous_type_0#$anonymous_type_1#head. = static_cast<char *>(const_cast<void *>(key.ptrcxx . . $ grn/dat/Key#ptr(3a8ef3fdc6e817ef).())); |
| 1176 | bulk->ucxx . . $ _grn_obj#u..bcxx . . $ _grn_obj#$anonymous_type_0#b..currcxx . . $ _grn_obj#$anonymous_type_0#$anonymous_type_1#curr. = bulk->ucxx . . $ _grn_obj#u..bcxx . . $ _grn_obj#$anonymous_type_0#b..headcxx . . $ _grn_obj#$anonymous_type_0#$anonymous_type_1#head. + key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1177 | } else { |
| 1178 | grn_bulk_write(ctx, |
| 1179 | bulk, |
| 1180 | static_cast<const char *>(key.ptrcxx . . $ grn/dat/Key#ptr(3a8ef3fdc6e817ef).()), |
| 1181 | key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).()); |
| 1182 | } |
| 1183 | return (int)key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1184 | } |
| 1185 | |
| 1186 | grn_rc |
| 1187 | grn_dat_delete_by_id(grn_ctx *ctx, |
| 1188 | grn_dat *dat, |
| 1189 | grn_id id, |
| 1190 | grn_table_delete_optarg *optarg) |
| 1191 | { |
| 1192 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1193 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1194 | } else if (!dat->triecxx . . $ _grn_dat#trie. || (id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!)) { |
| 1195 | return GRN_INVALID_ARGUMENT; |
| 1196 | } |
| 1197 | |
| 1198 | if (optarg && optarg->funccxx . . $ _grn_table_delete_optarg#func.) { |
| 1199 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1200 | if (!trie->ith_entrycxx . . $ grn/dat/Trie#ith_entry(4fe644a8fcf4134d).(id).is_validcxx . . $ grn/dat/Entry#is_valid(50ce9a9e25b4a850).()) { |
| 1201 | return GRN_INVALID_ARGUMENT; |
| 1202 | } else if (!optarg->funccxx . . $ _grn_table_delete_optarg#func.(ctx, |
| 1203 | reinterpret_cast<grn_obj *>(dat), |
| 1204 | id, |
| 1205 | optarg->func_argcxx . . $ _grn_table_delete_optarg#func_arg.)) { |
| 1206 | return GRN_SUCCESS; |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# recordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#WALRecorder(b15d84ac2a300338).(ctx, dat, "[dat][delete][id]"); |
| 1211 | recorder.eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event. = GRN_WAL_EVENT_DELETE_ENTRY; |
| 1212 | recorder.record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id. = id; |
| 1213 | auto rc = recorder.recordcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record(d5bb96df31a8101).(); |
| 1214 | if (rc != GRN_SUCCESS) { |
| 1215 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1216 | } |
| 1217 | rc = grn_dat_delete_by_id_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_delete_by_id_internal(97bd2e456bacf171).(ctx, dat, id); |
| 1218 | if (rc == GRN_SUCCESS) { |
| 1219 | recorder.apply_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#apply_wal_id(49f6e7a06ebc5aa8).(); |
| 1220 | } |
| 1221 | return rc; |
| 1222 | } |
| 1223 | |
| 1224 | grn_rc |
| 1225 | grn_dat_delete(grn_ctx *ctx, |
| 1226 | grn_dat *dat, |
| 1227 | const void *key, |
| 1228 | unsigned int key_size, |
| 1229 | grn_table_delete_optarg *optarg) |
| 1230 | { |
| 1231 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1232 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1233 | } else if (!dat->triecxx . . $ _grn_dat#trie. || !key || !key_size) { |
| 1234 | return GRN_INVALID_ARGUMENT; |
| 1235 | } |
| 1236 | |
| 1237 | if (optarg && optarg->funccxx . . $ _grn_table_delete_optarg#func.) { |
| 1238 | try { |
| 1239 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = |
| 1240 | static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1241 | grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_pos; |
| 1242 | if (!trie->searchcxx . . $ grn/dat/Trie#search(7a1a0c33e94d66be).(key, key_size, &key_pos)) { |
| 1243 | return GRN_INVALID_ARGUMENT; |
| 1244 | } else if (!optarg->funccxx . . $ _grn_table_delete_optarg#func.(ctx, |
| 1245 | reinterpret_cast<grn_obj *>(dat), |
| 1246 | trie->get_keycxx . . $ grn/dat/Trie#get_key(ac1ad672cda84f14).(key_pos).idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).(), |
| 1247 | optarg->func_argcxx . . $ _grn_table_delete_optarg#func_arg.)) { |
| 1248 | return GRN_SUCCESS; |
| 1249 | } |
| 1250 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1251 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 1252 | "grn::dat::Trie::search failed: %s", |
| 1253 | ex.what()); |
| 1254 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# recordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#WALRecorder(b15d84ac2a300338).(ctx, dat, "[dat][delete][key]"); |
| 1259 | recorder.eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event. = GRN_WAL_EVENT_DELETE_ENTRY; |
| 1260 | recorder.keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key. = key; |
| 1261 | recorder.key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size. = key_size; |
| 1262 | auto rc = recorder.recordcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record(d5bb96df31a8101).(); |
| 1263 | if (rc != GRN_SUCCESS) { |
| 1264 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1265 | } |
| 1266 | rc = grn_dat_delete_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_delete_internal(50cab4fc2376a3ac).(ctx, dat, key, key_size); |
| 1267 | if (rc == GRN_SUCCESS) { |
| 1268 | recorder.apply_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#apply_wal_id(49f6e7a06ebc5aa8).(); |
| 1269 | } |
| 1270 | return rc; |
| 1271 | } |
| 1272 | |
| 1273 | grn_rc |
| 1274 | grn_dat_update_by_id(grn_ctx *ctx, |
| 1275 | grn_dat *dat, |
| 1276 | grn_id src_key_id, |
| 1277 | const void *dest_key, |
| 1278 | unsigned int dest_key_size) |
| 1279 | { |
| 1280 | if (!dest_key_size) { |
| 1281 | return GRN_INVALID_ARGUMENT; |
| 1282 | } else if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1283 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1284 | } else if (!dat->triecxx . . $ _grn_dat#trie.) { |
| 1285 | return GRN_INVALID_ARGUMENT; |
| 1286 | } |
| 1287 | |
| 1288 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# recordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#WALRecorder(b15d84ac2a300338).(ctx, dat, "[dat][update][id]"); |
| 1289 | recorder.eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event. = GRN_WAL_EVENT_UPDATE_ENTRY; |
| 1290 | recorder.record_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record_id. = src_key_id; |
| 1291 | recorder.new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key. = dest_key; |
| 1292 | recorder.new_key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key_size. = dest_key_size; |
| 1293 | auto rc = recorder.recordcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record(d5bb96df31a8101).(); |
| 1294 | if (rc != GRN_SUCCESS) { |
| 1295 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1296 | } |
| 1297 | rc = grn_dat_update_by_id_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_update_by_id_internal(fc3962e251224b9e).(ctx, |
| 1298 | dat, |
| 1299 | src_key_id, |
| 1300 | dest_key, |
| 1301 | dest_key_size); |
| 1302 | if (rc == GRN_SUCCESS) { |
| 1303 | recorder.apply_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#apply_wal_id(49f6e7a06ebc5aa8).(); |
| 1304 | } |
| 1305 | return rc; |
| 1306 | } |
| 1307 | |
| 1308 | grn_rc |
| 1309 | grn_dat_update(grn_ctx *ctx, |
| 1310 | grn_dat *dat, |
| 1311 | const void *src_key, |
| 1312 | unsigned int src_key_size, |
| 1313 | const void *dest_key, |
| 1314 | unsigned int dest_key_size) |
| 1315 | { |
| 1316 | if (!dest_key_size) { |
| 1317 | return GRN_INVALID_ARGUMENT; |
| 1318 | } else if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1319 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1320 | } else if (!dat->triecxx . . $ _grn_dat#trie.) { |
| 1321 | return GRN_INVALID_ARGUMENT; |
| 1322 | } |
| 1323 | |
| 1324 | WALRecordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder# recordercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#WALRecorder(b15d84ac2a300338).(ctx, dat, "[dat][update][key]"); |
| 1325 | recorder.eventcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#event. = GRN_WAL_EVENT_UPDATE_ENTRY; |
| 1326 | recorder.keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key. = src_key; |
| 1327 | recorder.key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#key_size. = src_key_size; |
| 1328 | recorder.new_keycxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key. = dest_key; |
| 1329 | recorder.new_key_sizecxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#new_key_size. = dest_key_size; |
| 1330 | auto rc = recorder.recordcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#record(d5bb96df31a8101).(); |
| 1331 | if (rc != GRN_SUCCESS) { |
| 1332 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1333 | } |
| 1334 | rc = grn_dat_update_internalcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_update_internal(79e345af04dd0233).(ctx, |
| 1335 | dat, |
| 1336 | src_key, |
| 1337 | src_key_size, |
| 1338 | dest_key, |
| 1339 | dest_key_size); |
| 1340 | if (rc == GRN_SUCCESS) { |
| 1341 | recorder.apply_wal_idcxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecorder#apply_wal_id(49f6e7a06ebc5aa8).(); |
| 1342 | } |
| 1343 | return rc; |
| 1344 | } |
| 1345 | |
| 1346 | int |
| 1347 | grn_dat_scan(grn_ctx *ctx, |
| 1348 | grn_dat *dat, |
| 1349 | const char *str, |
| 1350 | unsigned int str_size, |
| 1351 | grn_dat_scan_hit *scan_hits, |
| 1352 | unsigned int max_num_scan_hits, |
| 1353 | const char **str_rest) |
| 1354 | { |
| 1355 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat) || !str || |
| 1356 | !(dat->objcxx . . $ _grn_dat#obj..header.flags & GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`!) || !scan_hits) { |
| 1357 | if (str_rest) { |
| 1358 | *str_rest = str; |
| 1359 | } |
| 1360 | return -1; |
| 1361 | } |
| 1362 | |
| 1363 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1364 | if (!trie) { |
| 1365 | if (str_rest) { |
| 1366 | *str_rest = str + str_size; |
| 1367 | } |
| 1368 | return 0; |
| 1369 | } |
| 1370 | |
| 1371 | if (!max_num_scan_hits || !str_size) { |
| 1372 | if (str_rest) { |
| 1373 | *str_rest = str; |
| 1374 | } |
| 1375 | return 0; |
| 1376 | } |
| 1377 | |
| 1378 | unsigned int num_scan_hits = 0; |
| 1379 | try { |
| 1380 | if (GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(&(dat->normalizers)) > 0) { |
| 1381 | int flags = GRN_STRING_WITH_CHECKScxx . . $ `include/groonga/string.h:54:9`!; |
| 1382 | grn_obj *const normalized_string = |
| 1383 | grn_string_open(ctx, |
| 1384 | str, |
| 1385 | str_size, |
| 1386 | reinterpret_cast<grn_obj *>(dat), |
| 1387 | flags); |
| 1388 | if (!normalized_string) { |
| 1389 | if (str_rest) { |
| 1390 | *str_rest = str; |
| 1391 | } |
| 1392 | return -1; |
| 1393 | } |
| 1394 | grn_string_get_normalized(ctx, normalized_string, &str, &str_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 1395 | const short *checks = grn_string_get_checks(ctx, normalized_string); |
| 1396 | unsigned int offset = 0; |
| 1397 | while (str_size) { |
| 1398 | if (*checks) { |
| 1399 | grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_pos; |
| 1400 | if (trie->lcp_searchcxx . . $ grn/dat/Trie#lcp_search(7a1a0c33e94d66be).(str, str_size, &key_pos)) { |
| 1401 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key = trie->get_keycxx . . $ grn/dat/Trie#get_key(ac1ad672cda84f14).(key_pos); |
| 1402 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_length = key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1403 | if ((key_length == str_size) || (checks[key_length])) { |
| 1404 | unsigned int length = 0; |
| 1405 | for (grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# i = 0; i < key_length; ++i) { |
| 1406 | if (checks[i] > 0) { |
| 1407 | length += checks[i]; |
| 1408 | } |
| 1409 | } |
| 1410 | scan_hits[num_scan_hits].id = key.idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).(); |
| 1411 | scan_hits[num_scan_hits].offset = offset; |
| 1412 | scan_hits[num_scan_hits].length = length; |
| 1413 | offset += length; |
| 1414 | str += key_length; |
| 1415 | str_size -= key_length; |
| 1416 | checks += key_length; |
| 1417 | if (++num_scan_hits >= max_num_scan_hits) { |
| 1418 | break; |
| 1419 | } |
| 1420 | continue; |
| 1421 | } |
| 1422 | } |
| 1423 | if (*checks > 0) { |
| 1424 | offset += *checks; |
| 1425 | } |
| 1426 | } |
| 1427 | ++str; |
| 1428 | --str_size; |
| 1429 | ++checks; |
| 1430 | } |
| 1431 | if (str_rest) { |
| 1432 | grn_string_get_original(ctx, normalized_string, str_rest, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 1433 | *str_rest += offset; |
| 1434 | } |
| 1435 | grn_obj_close(ctx, normalized_string); |
| 1436 | } else { |
| 1437 | const char *const begin = str; |
| 1438 | while (str_size) { |
| 1439 | grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_pos; |
| 1440 | if (trie->lcp_searchcxx . . $ grn/dat/Trie#lcp_search(7a1a0c33e94d66be).(str, str_size, &key_pos)) { |
| 1441 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key = trie->get_keycxx . . $ grn/dat/Trie#get_key(ac1ad672cda84f14).(key_pos); |
| 1442 | scan_hits[num_scan_hits].id = key.idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).(); |
| 1443 | scan_hits[num_scan_hits].offset = str - begin; |
| 1444 | scan_hits[num_scan_hits].length = key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1445 | str += key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1446 | str_size -= key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1447 | if (++num_scan_hits >= max_num_scan_hits) { |
| 1448 | break; |
| 1449 | } |
| 1450 | } else { |
| 1451 | const int char_length = grn_charlen(ctx, str, str + str_size); |
| 1452 | if (char_length) { |
| 1453 | str += char_length; |
| 1454 | str_size -= char_length; |
| 1455 | } else { |
| 1456 | ++str; |
| 1457 | --str_size; |
| 1458 | } |
| 1459 | } |
| 1460 | } |
| 1461 | if (str_rest) { |
| 1462 | *str_rest = str; |
| 1463 | } |
| 1464 | } |
| 1465 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1466 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 1467 | "grn::dat::lcp_search failed: %s", |
| 1468 | ex.what()); |
| 1469 | if (str_rest) { |
| 1470 | *str_rest = str; |
| 1471 | } |
| 1472 | return -1; |
| 1473 | } |
| 1474 | return static_cast<int>(num_scan_hits); |
| 1475 | } |
| 1476 | |
| 1477 | grn_id |
| 1478 | grn_dat_lcp_search(grn_ctx *ctx, |
| 1479 | grn_dat *dat, |
| 1480 | const void *key, |
| 1481 | unsigned int key_size) |
| 1482 | { |
| 1483 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat) || !key || |
| 1484 | !(dat->objcxx . . $ _grn_dat#obj..header.flags & GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`!)) { |
| 1485 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1486 | } |
| 1487 | |
| 1488 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1489 | if (!trie) { |
| 1490 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1491 | } |
| 1492 | |
| 1493 | try { |
| 1494 | grncxx . . $ grn/::datcxx . . $ grn/dat/::UInt32cxx . . $ grn/dat/UInt32# key_pos; |
| 1495 | if (!trie->lcp_searchcxx . . $ grn/dat/Trie#lcp_search(7a1a0c33e94d66be).(key, key_size, &key_pos)) { |
| 1496 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1497 | } |
| 1498 | return trie->get_keycxx . . $ grn/dat/Trie#get_key(ac1ad672cda84f14).(key_pos).idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).(); |
| 1499 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1500 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 1501 | "grn::dat::PrefixCursor::open failed: %s", |
| 1502 | ex.what()); |
| 1503 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1504 | } |
| 1505 | } |
| 1506 | |
| 1507 | unsigned int |
| 1508 | grn_dat_size(grn_ctx *ctx, grn_dat *dat) |
| 1509 | { |
| 1510 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1511 | return 0; |
| 1512 | } |
| 1513 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = |
| 1514 | static_cast<const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1515 | if (trie) { |
| 1516 | return trie->num_keyscxx . . $ grn/dat/Trie#num_keys(ddd8539a2fcdd4ce).(); |
| 1517 | } |
| 1518 | return 0; |
| 1519 | } |
| 1520 | |
| 1521 | grn_dat_cursor * |
| 1522 | grn_dat_cursor_open(grn_ctx *ctx, |
| 1523 | grn_dat *dat, |
| 1524 | const void *min, |
| 1525 | unsigned int min_size, |
| 1526 | const void *max, |
| 1527 | unsigned int max_size, |
| 1528 | int offset, |
| 1529 | int limit, |
| 1530 | int flags) |
| 1531 | { |
| 1532 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1533 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1534 | } |
| 1535 | |
| 1536 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1537 | if (!trie) { |
| 1538 | grn_dat_cursor *const dc = |
| 1539 | static_cast<grn_dat_cursor *>(GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(grn_dat_cursor))); |
| 1540 | if (dc) { |
| 1541 | grn_dat_cursor_initcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_cursor_init(92ac03129a489a03).(ctx, dc); |
| 1542 | } |
| 1543 | return dc; |
| 1544 | } |
| 1545 | |
| 1546 | grn_dat_cursor *const dc = |
| 1547 | static_cast<grn_dat_cursor *>(GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(grn_dat_cursor))); |
| 1548 | if (!dc) { |
| 1549 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1550 | } |
| 1551 | grn_dat_cursor_initcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_cursor_init(92ac03129a489a03).(ctx, dc); |
| 1552 | |
| 1553 | try { |
| 1554 | if ((flags & GRN_CURSOR_BY_IDcxx . . $ `include/groonga/table.h:280:9`!) != 0) { |
| 1555 | dc->cursorcxx . . $ _grn_dat_cursor#cursor. = grncxx . . $ grn/::datcxx . . $ grn/dat/::CursorFactorycxx . . $ grn/dat/CursorFactory#::opencxx . . $ grn/dat/CursorFactory#open(60734bb5c370655a).( |
| 1556 | *trie, |
| 1557 | min, |
| 1558 | min_size, |
| 1559 | max, |
| 1560 | max_size, |
| 1561 | offset, |
| 1562 | limit, |
| 1563 | grncxx . . $ grn/::datcxx . . $ grn/dat/::ID_RANGE_CURSORcxx . . $ grn/dat/ID_RANGE_CURSOR. | |
| 1564 | ((flags & GRN_CURSOR_DESCENDINGcxx . . $ `include/groonga/table.h:274:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::DESCENDING_CURSORcxx . . $ grn/dat/DESCENDING_CURSOR. : 0) | |
| 1565 | ((flags & GRN_CURSOR_GTcxx . . $ `include/groonga/table.h:276:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::EXCEPT_LOWER_BOUNDcxx . . $ grn/dat/EXCEPT_LOWER_BOUND. : 0) | |
| 1566 | ((flags & GRN_CURSOR_LTcxx . . $ `include/groonga/table.h:278:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::EXCEPT_UPPER_BOUNDcxx . . $ grn/dat/EXCEPT_UPPER_BOUND. : 0)); |
| 1567 | } else if ((flags & GRN_CURSOR_PREFIXcxx . . $ `include/groonga/table.h:281:9`!) != 0) { |
| 1568 | if (max && max_size) { |
| 1569 | if ((dat->objcxx . . $ _grn_dat#obj..header.flags & GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`!) != 0) { |
| 1570 | dc->cursorcxx . . $ _grn_dat_cursor#cursor. = grncxx . . $ grn/::datcxx . . $ grn/dat/::CursorFactorycxx . . $ grn/dat/CursorFactory#::opencxx . . $ grn/dat/CursorFactory#open(60734bb5c370655a).( |
| 1571 | *trie, |
| 1572 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 1573 | min_size, |
| 1574 | max, |
| 1575 | max_size, |
| 1576 | offset, |
| 1577 | limit, |
| 1578 | grncxx . . $ grn/::datcxx . . $ grn/dat/::PREFIX_CURSORcxx . . $ grn/dat/PREFIX_CURSOR. | grncxx . . $ grn/::datcxx . . $ grn/dat/::DESCENDING_CURSORcxx . . $ grn/dat/DESCENDING_CURSOR.); |
| 1579 | } else { |
| 1580 | // TODO: near |
| 1581 | } |
| 1582 | } else if (min && min_size) { |
| 1583 | if ((flags & GRN_CURSOR_RKcxx . . $ `include/groonga/table.h:283:9`!) != 0) { |
| 1584 | // TODO: rk search |
| 1585 | } else { |
| 1586 | dc->cursorcxx . . $ _grn_dat_cursor#cursor. = grncxx . . $ grn/::datcxx . . $ grn/dat/::CursorFactorycxx . . $ grn/dat/CursorFactory#::opencxx . . $ grn/dat/CursorFactory#open(60734bb5c370655a).( |
| 1587 | *trie, |
| 1588 | min, |
| 1589 | min_size, |
| 1590 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 1591 | 0, |
| 1592 | offset, |
| 1593 | limit, |
| 1594 | grncxx . . $ grn/::datcxx . . $ grn/dat/::PREDICTIVE_CURSORcxx . . $ grn/dat/PREDICTIVE_CURSOR. | |
| 1595 | ((flags & GRN_CURSOR_DESCENDINGcxx . . $ `include/groonga/table.h:274:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::DESCENDING_CURSORcxx . . $ grn/dat/DESCENDING_CURSOR. |
| 1596 | : 0) | |
| 1597 | ((flags & GRN_CURSOR_GTcxx . . $ `include/groonga/table.h:276:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::EXCEPT_EXACT_MATCHcxx . . $ grn/dat/EXCEPT_EXACT_MATCH. : 0)); |
| 1598 | } |
| 1599 | } |
| 1600 | } else { |
| 1601 | dc->cursorcxx . . $ _grn_dat_cursor#cursor. = grncxx . . $ grn/::datcxx . . $ grn/dat/::CursorFactorycxx . . $ grn/dat/CursorFactory#::opencxx . . $ grn/dat/CursorFactory#open(60734bb5c370655a).( |
| 1602 | *trie, |
| 1603 | min, |
| 1604 | min_size, |
| 1605 | max, |
| 1606 | max_size, |
| 1607 | offset, |
| 1608 | limit, |
| 1609 | grncxx . . $ grn/::datcxx . . $ grn/dat/::KEY_RANGE_CURSORcxx . . $ grn/dat/KEY_RANGE_CURSOR. | |
| 1610 | ((flags & GRN_CURSOR_DESCENDINGcxx . . $ `include/groonga/table.h:274:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::DESCENDING_CURSORcxx . . $ grn/dat/DESCENDING_CURSOR. : 0) | |
| 1611 | ((flags & GRN_CURSOR_GTcxx . . $ `include/groonga/table.h:276:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::EXCEPT_LOWER_BOUNDcxx . . $ grn/dat/EXCEPT_LOWER_BOUND. : 0) | |
| 1612 | ((flags & GRN_CURSOR_LTcxx . . $ `include/groonga/table.h:278:9`!) ? grncxx . . $ grn/::datcxx . . $ grn/dat/::EXCEPT_UPPER_BOUNDcxx . . $ grn/dat/EXCEPT_UPPER_BOUND. : 0)); |
| 1613 | } |
| 1614 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1615 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 1616 | "grn::dat::CursorFactory::open failed: %s", |
| 1617 | ex.what()); |
| 1618 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(dc); |
| 1619 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1620 | } |
| 1621 | if (!dc->cursorcxx . . $ _grn_dat_cursor#cursor.) { |
| 1622 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "unsupported query"); |
| 1623 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(dc); |
| 1624 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1625 | } |
| 1626 | dc->datcxx . . $ _grn_dat_cursor#dat. = dat; |
| 1627 | return dc; |
| 1628 | } |
| 1629 | |
| 1630 | grn_id |
| 1631 | grn_dat_cursor_next(grn_ctx *ctx, grn_dat_cursor *c) |
| 1632 | { |
| 1633 | if (!c || !c->cursorcxx . . $ _grn_dat_cursor#cursor.) { |
| 1634 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1635 | } |
| 1636 | try { |
| 1637 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Cursorcxx . . $ grn/dat/Cursor# *const cursor = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Cursorcxx . . $ grn/dat/Cursor# *>(c->cursorcxx . . $ _grn_dat_cursor#cursor.); |
| 1638 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key = cursor->nextcxx . . $ grn/dat/Cursor#next(741ea5814372790).(); |
| 1639 | c->keycxx . . $ _grn_dat_cursor#key. = &key; |
| 1640 | c->curr_reccxx . . $ _grn_dat_cursor#curr_rec. = key.is_validcxx . . $ grn/dat/Key#is_valid(50ce9a9e25b4a850).() ? key.idcxx . . $ grn/dat/Key#id(ddd8539a2fcdd4ce).() : GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1641 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1642 | ERRcxx . . $ `lib/grn_error.h:156:9`!(grn_dat_translate_error_code(ex.code()), |
| 1643 | "grn::dat::Cursor::next failed: %s", |
| 1644 | ex.what()); |
| 1645 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1646 | } |
| 1647 | return c->curr_reccxx . . $ _grn_dat_cursor#curr_rec.; |
| 1648 | } |
| 1649 | |
| 1650 | void |
| 1651 | grn_dat_cursor_close(grn_ctx *ctx, grn_dat_cursor *c) |
| 1652 | { |
| 1653 | if (c) { |
| 1654 | grn_dat_cursor_fincxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_cursor_fin(92ac03129a489a03).(ctx, c); |
| 1655 | GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(c); |
| 1656 | } |
| 1657 | } |
| 1658 | |
| 1659 | int |
| 1660 | grn_dat_cursor_get_key(grn_ctx *ctx, grn_dat_cursor *c, const void **key) |
| 1661 | { |
| 1662 | if (c) { |
| 1663 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key_ref = *static_cast<const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# *>(c->keycxx . . $ _grn_dat_cursor#key.); |
| 1664 | if (key_ref.is_validcxx . . $ grn/dat/Key#is_valid(50ce9a9e25b4a850).()) { |
| 1665 | *key = key_ref.ptrcxx . . $ grn/dat/Key#ptr(3a8ef3fdc6e817ef).(); |
| 1666 | return (int)key_ref.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1667 | } |
| 1668 | } |
| 1669 | return 0; |
| 1670 | } |
| 1671 | |
| 1672 | grn_rc |
| 1673 | grn_dat_cursor_delete(grn_ctx *ctx, |
| 1674 | grn_dat_cursor *c, |
| 1675 | grn_table_delete_optarg *optarg) |
| 1676 | { |
| 1677 | if (!c || !c->cursorcxx . . $ _grn_dat_cursor#cursor.) { |
| 1678 | return GRN_INVALID_ARGUMENT; |
| 1679 | } |
| 1680 | return grn_dat_delete_by_id(ctx, c->datcxx . . $ _grn_dat_cursor#dat., c->curr_reccxx . . $ _grn_dat_cursor#curr_rec., optarg); |
| 1681 | } |
| 1682 | |
| 1683 | size_t |
| 1684 | grn_dat_cursor_get_max_n_records(grn_ctx *ctx, grn_dat_cursor *c) |
| 1685 | { |
| 1686 | if (!c || !c->cursorcxx . . $ _grn_dat_cursor#cursor.) { |
| 1687 | return 0; |
| 1688 | } |
| 1689 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Cursorcxx . . $ grn/dat/Cursor# *const cursor = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Cursorcxx . . $ grn/dat/Cursor# *>(c->cursorcxx . . $ _grn_dat_cursor#cursor.); |
| 1690 | size_t max_n_records = cursor->limitcxx . . $ grn/dat/Cursor#limit(ddd8539a2fcdd4ce).(); |
| 1691 | if (max_n_records == grncxx . . $ grn/::datcxx . . $ grn/dat/::MAX_UINT32cxx . . $ grn/dat/MAX_UINT32.) { |
| 1692 | return grn_dat_size(ctx, c->datcxx . . $ _grn_dat_cursor#dat.); |
| 1693 | } else { |
| 1694 | return max_n_records; |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | grn_id |
| 1699 | grn_dat_curr_id(grn_ctx *ctx, grn_dat *dat) |
| 1700 | { |
| 1701 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1702 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1703 | } |
| 1704 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1705 | if (trie) { |
| 1706 | return trie->max_key_idcxx . . $ grn/dat/Trie#max_key_id(ddd8539a2fcdd4ce).(); |
| 1707 | } |
| 1708 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1709 | } |
| 1710 | |
| 1711 | grn_rc |
| 1712 | grn_dat_truncate(grn_ctx *ctx, grn_dat *dat) |
| 1713 | { |
| 1714 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1715 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1716 | } |
| 1717 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = |
| 1718 | static_cast<const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1719 | if (!trie || !trie->max_key_idcxx . . $ grn/dat/Trie#max_key_id(ddd8539a2fcdd4ce).()) { |
| 1720 | return GRN_SUCCESS; |
| 1721 | } |
| 1722 | |
| 1723 | stdcxx . . $ std/::stringcxx . . $ std/string# pathcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).(grn_io_path(dat->iocxx . . $ _grn_dat#io.)); |
| 1724 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 1725 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(path.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), trie_path, dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id. + 1); |
| 1726 | try { |
| 1727 | grncxx . . $ grn/dat/Trie#Trie(49f6e7a06ebc5aa8).::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie#().createcxx . . $ grn/dat/Trie#create(effadf6d9e160e1f).(trie_path); |
| 1728 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1729 | const grn_rc error_code = grn_dat_translate_error_codecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_translate_error_code(620446ddef249864).(ex.codecxx . . $ grn/dat/Exception#code(c161794fcc47bf61).()); |
| 1730 | ERRcxx . . $ `lib/grn_error.h:156:9`!(error_code, "grn::dat::Trie::create failed: %s", ex.what()); |
| 1731 | return error_code; |
| 1732 | } |
| 1733 | ++dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.; |
| 1734 | if (!path.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { |
| 1735 | grn_wal_remove(ctx, path.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), "[dat]"); |
| 1736 | } |
| 1737 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1738 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1739 | } |
| 1740 | return GRN_SUCCESS; |
| 1741 | } |
| 1742 | |
| 1743 | const char * |
| 1744 | _grn_dat_key(grn_ctx *ctx, grn_dat *dat, grn_id id, uint32_tcxx . . $ uint32_t# *key_size) |
| 1745 | { |
| 1746 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1747 | *key_size = 0; |
| 1748 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1749 | } |
| 1750 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1751 | if (!trie) { |
| 1752 | *key_size = 0; |
| 1753 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1754 | } |
| 1755 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key = trie->ith_keycxx . . $ grn/dat/Trie#ith_key(ac1ad672cda84f14).(id); |
| 1756 | if (!key.is_validcxx . . $ grn/dat/Key#is_valid(50ce9a9e25b4a850).()) { |
| 1757 | *key_size = 0; |
| 1758 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 1759 | } |
| 1760 | *key_size = key.lengthcxx . . $ grn/dat/Key#length(ddd8539a2fcdd4ce).(); |
| 1761 | return static_cast<const char *>(key.ptrcxx . . $ grn/dat/Key#ptr(3a8ef3fdc6e817ef).()); |
| 1762 | } |
| 1763 | |
| 1764 | grn_id |
| 1765 | grn_dat_next(grn_ctx *ctx, grn_dat *dat, grn_id id) |
| 1766 | { |
| 1767 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1768 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1769 | } |
| 1770 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1771 | if (!trie) { |
| 1772 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1773 | } |
| 1774 | while (id < trie->max_key_idcxx . . $ grn/dat/Trie#max_key_id(ddd8539a2fcdd4ce).()) { |
| 1775 | if (trie->ith_keycxx . . $ grn/dat/Trie#ith_key(ac1ad672cda84f14).(++id).is_validcxx . . $ grn/dat/Key#is_valid(50ce9a9e25b4a850).()) { |
| 1776 | return id; |
| 1777 | } |
| 1778 | } |
| 1779 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1780 | } |
| 1781 | |
| 1782 | grn_id |
| 1783 | grn_dat_at(grn_ctx *ctx, grn_dat *dat, grn_id id) |
| 1784 | { |
| 1785 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1786 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1787 | } |
| 1788 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1789 | if (!trie) { |
| 1790 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1791 | } |
| 1792 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Keycxx . . $ grn/dat/Key# &key = trie->ith_keycxx . . $ grn/dat/Trie#ith_key(ac1ad672cda84f14).(id); |
| 1793 | if (!key.is_validcxx . . $ grn/dat/Key#is_valid(50ce9a9e25b4a850).()) { |
| 1794 | return GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 1795 | } |
| 1796 | return id; |
| 1797 | } |
| 1798 | |
| 1799 | bool |
| 1800 | grn_dat_is_changing(grn_ctx *ctx, grn_dat *dat) |
| 1801 | { |
| 1802 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1803 | return false; |
| 1804 | } |
| 1805 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1806 | if (!trie) { |
| 1807 | return false; |
| 1808 | } |
| 1809 | return trie->is_changingcxx . . $ grn/dat/Trie#is_changing(c9857a73d68e59ba).(); |
| 1810 | } |
| 1811 | |
| 1812 | grn_rc |
| 1813 | grn_dat_clear_status_flags(grn_ctx *ctx, grn_dat *dat) |
| 1814 | { |
| 1815 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1816 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1817 | } |
| 1818 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1819 | if (!trie) { |
| 1820 | return GRN_INVALID_ARGUMENT; |
| 1821 | } |
| 1822 | trie->clear_status_flagscxx . . $ grn/dat/Trie#clear_status_flags(49f6e7a06ebc5aa8).(); |
| 1823 | return GRN_SUCCESS; |
| 1824 | } |
| 1825 | |
| 1826 | grn_rc |
| 1827 | grn_dat_repair(grn_ctx *ctx, grn_dat *dat) |
| 1828 | { |
| 1829 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1830 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1831 | } |
| 1832 | const grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1833 | if (!trie) { |
| 1834 | return GRN_INVALID_ARGUMENT; |
| 1835 | } |
| 1836 | |
| 1837 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 1838 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), |
| 1839 | trie_path, |
| 1840 | dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id. + 1); |
| 1841 | try { |
| 1842 | grncxx . . $ grn/dat/Trie#Trie(49f6e7a06ebc5aa8).::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie#().repaircxx . . $ grn/dat/Trie#repair(747e891cfe89c583).(*trie, trie_path); |
| 1843 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1844 | const grn_rc error_code = grn_dat_translate_error_codecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_translate_error_code(620446ddef249864).(ex.codecxx . . $ grn/dat/Exception#code(c161794fcc47bf61).()); |
| 1845 | ERRcxx . . $ `lib/grn_error.h:156:9`!(error_code, "grn::dat::Trie::create failed: %s", ex.what()); |
| 1846 | return error_code; |
| 1847 | } |
| 1848 | ++dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.; |
| 1849 | if (!grn_dat_open_trie_if_neededcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_open_trie_if_needed(80a67896fab8adf8).(ctx, dat)) { |
| 1850 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 1851 | } |
| 1852 | return GRN_SUCCESS; |
| 1853 | } |
| 1854 | |
| 1855 | grn_rc |
| 1856 | grn_dat_flush(grn_ctx *ctx, grn_dat *dat) |
| 1857 | { |
| 1858 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 1859 | return GRN_SUCCESS; |
| 1860 | } |
| 1861 | |
| 1862 | grn_rc rc = grn_io_flush(ctx, dat->iocxx . . $ _grn_dat#io.); |
| 1863 | if (rc != GRN_SUCCESS) { |
| 1864 | return rc; |
| 1865 | } |
| 1866 | |
| 1867 | if (dat->triecxx . . $ _grn_dat#trie.) { |
| 1868 | grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *const trie = static_cast<grncxx . . $ grn/::datcxx . . $ grn/dat/::Triecxx . . $ grn/dat/Trie# *>(dat->triecxx . . $ _grn_dat#trie.); |
| 1869 | try { |
| 1870 | trie->flushcxx . . $ grn/dat/Trie#flush(49f6e7a06ebc5aa8).(); |
| 1871 | } catch (const grncxx . . $ grn/::datcxx . . $ grn/dat/::Exceptioncxx . . $ grn/dat/Exception# &ex) { |
| 1872 | const grn_rc error_code = grn_dat_translate_error_codecxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_translate_error_code(620446ddef249864).(ex.codecxx . . $ grn/dat/Exception#code(c161794fcc47bf61).()); |
| 1873 | if (error_code == GRN_INPUT_OUTPUT_ERROR) { |
| 1874 | SERRcxx . . $ `lib/grn_error.h:411:11`!("grn::dat::Trie::flush failed: %s", ex.what()); |
| 1875 | } else { |
| 1876 | ERRcxx . . $ `lib/grn_error.h:156:9`!(error_code, "grn::dat::Trie::flush failed: %s", ex.what()); |
| 1877 | } |
| 1878 | return error_code; |
| 1879 | } |
| 1880 | } |
| 1881 | |
| 1882 | return GRN_SUCCESS; |
| 1883 | } |
| 1884 | |
| 1885 | grn_rc |
| 1886 | grn_dat_dirty(grn_ctx *ctx, grn_dat *dat) |
| 1887 | { |
| 1888 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 1889 | return GRN_SUCCESS; |
| 1890 | } |
| 1891 | |
| 1892 | grn_rc rc = GRN_SUCCESS; |
| 1893 | |
| 1894 | { |
| 1895 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# critical_sectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(4f83bfebf4bb9c8b).(&dat->lockcxx . . $ _grn_dat#lock.); |
| 1896 | if (!dat->is_dirtycxx . . $ _grn_dat#is_dirty.) { |
| 1897 | uint32_tcxx . . $ uint32_t# n_dirty_opens; |
| 1898 | dat->is_dirtycxx . . $ _grn_dat#is_dirty. = true; |
| 1899 | GRN_ATOMIC_ADD_EXcxx . . $ `lib/grn.h:420:11`!(&(dat->header->n_dirty_opens), 1, n_dirty_opens); |
| 1900 | rc = grn_io_flush(ctx, dat->iocxx . . $ _grn_dat#io.); |
| 1901 | } |
| 1902 | } |
| 1903 | |
| 1904 | return rc; |
| 1905 | } |
| 1906 | |
| 1907 | bool |
| 1908 | grn_dat_is_dirty(grn_ctx *ctx, grn_dat *dat) |
| 1909 | { |
| 1910 | if (!dat->headercxx . . $ _grn_dat#header.) { |
| 1911 | return false; |
| 1912 | } |
| 1913 | |
| 1914 | return dat->headercxx . . $ _grn_dat#header.->n_dirty_openscxx . . $ grn_dat_header#n_dirty_opens. > 0; |
| 1915 | } |
| 1916 | |
| 1917 | grn_rc |
| 1918 | grn_dat_clean(grn_ctx *ctx, grn_dat *dat) |
| 1919 | { |
| 1920 | grn_rc rc = GRN_SUCCESS; |
| 1921 | |
| 1922 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 1923 | return rc; |
| 1924 | } |
| 1925 | |
| 1926 | { |
| 1927 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# critical_sectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(4f83bfebf4bb9c8b).(&dat->lockcxx . . $ _grn_dat#lock.); |
| 1928 | if (dat->is_dirtycxx . . $ _grn_dat#is_dirty.) { |
| 1929 | uint32_tcxx . . $ uint32_t# n_dirty_opens; |
| 1930 | dat->is_dirtycxx . . $ _grn_dat#is_dirty. = false; |
| 1931 | GRN_ATOMIC_ADD_EXcxx . . $ `lib/grn.h:420:11`!(&(dat->header->n_dirty_opens), -1, n_dirty_opens); |
| 1932 | rc = grn_io_flush(ctx, dat->iocxx . . $ _grn_dat#io.); |
| 1933 | } |
| 1934 | } |
| 1935 | |
| 1936 | return rc; |
| 1937 | } |
| 1938 | |
| 1939 | grn_rc |
| 1940 | grn_dat_clear_dirty(grn_ctx *ctx, grn_dat *dat) |
| 1941 | { |
| 1942 | grn_rc rc = GRN_SUCCESS; |
| 1943 | |
| 1944 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 1945 | return rc; |
| 1946 | } |
| 1947 | |
| 1948 | { |
| 1949 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# critical_sectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(4f83bfebf4bb9c8b).(&dat->lockcxx . . $ _grn_dat#lock.); |
| 1950 | dat->is_dirtycxx . . $ _grn_dat#is_dirty. = false; |
| 1951 | dat->headercxx . . $ _grn_dat#header.->n_dirty_openscxx . . $ grn_dat_header#n_dirty_opens. = 0; |
| 1952 | rc = grn_io_flush(ctx, dat->iocxx . . $ _grn_dat#io.); |
| 1953 | } |
| 1954 | |
| 1955 | return rc; |
| 1956 | } |
| 1957 | |
| 1958 | bool |
| 1959 | grn_dat_is_corrupt(grn_ctx *ctx, grn_dat *dat) |
| 1960 | { |
| 1961 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 1962 | return false; |
| 1963 | } |
| 1964 | |
| 1965 | { |
| 1966 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# critical_sectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(4f83bfebf4bb9c8b).(&dat->lockcxx . . $ _grn_dat#lock.); |
| 1967 | |
| 1968 | if (grn_io_is_corrupt(ctx, dat->iocxx . . $ _grn_dat#io.)) { |
| 1969 | return true; |
| 1970 | } |
| 1971 | |
| 1972 | if (dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id. == 0) { |
| 1973 | return false; |
| 1974 | } |
| 1975 | |
| 1976 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 1977 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), |
| 1978 | trie_path, |
| 1979 | dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.); |
| 1980 | struct stat stat; |
| 1981 | if (::stat(trie_path, &stat) != 0) { |
| 1982 | SERRcxx . . $ `lib/grn_error.h:411:11`!("[dat][corrupt] used path doesn't exist: <%s>", trie_path); |
| 1983 | return true; |
| 1984 | } |
| 1985 | } |
| 1986 | |
| 1987 | return false; |
| 1988 | } |
| 1989 | |
| 1990 | size_t |
| 1991 | grn_dat_get_disk_usage(grn_ctx *ctx, grn_dat *dat) |
| 1992 | { |
| 1993 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 1994 | return 0; |
| 1995 | } |
| 1996 | |
| 1997 | { |
| 1998 | CriticalSectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection# critical_sectioncxx . . $ `$anonymous_namespace_lib/dat.cpp`/CriticalSection#CriticalSection(4f83bfebf4bb9c8b).(&dat->lockcxx . . $ _grn_dat#lock.); |
| 1999 | size_t usage; |
| 2000 | |
| 2001 | usage = grn_io_get_disk_usage(ctx, dat->iocxx . . $ _grn_dat#io.); |
| 2002 | |
| 2003 | if (dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id. == 0) { |
| 2004 | return usage; |
| 2005 | } |
| 2006 | |
| 2007 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 2008 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), |
| 2009 | trie_path, |
| 2010 | dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.); |
| 2011 | struct stat stat; |
| 2012 | if (::stat(trie_path, &stat) == 0) { |
| 2013 | usage += stat.st_size; |
| 2014 | } |
| 2015 | |
| 2016 | return usage; |
| 2017 | } |
| 2018 | } |
| 2019 | |
| 2020 | grn_rc |
| 2021 | grn_dat_wal_recover(grn_ctx *ctx, grn_dat *dat) |
| 2022 | { |
| 2023 | WALRecoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer# recoverercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#WALRecoverer(e79ecd4e4b1242ae).(ctx, dat); |
| 2024 | return recoverer.recovercxx . . $ `$anonymous_namespace_lib/dat.cpp`/WALRecoverer#recover(d5bb96df31a8101).(); |
| 2025 | } |
| 2026 | |
| 2027 | grn_rc |
| 2028 | grn_dat_warm(grn_ctx *ctx, grn_dat *dat) |
| 2029 | { |
| 2030 | if (!dat->iocxx . . $ _grn_dat#io.) { |
| 2031 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 2032 | } |
| 2033 | |
| 2034 | grn_rc rc = grn_io_warm(ctx, dat->iocxx . . $ _grn_dat#io.); |
| 2035 | if (rc != GRN_SUCCESS) { |
| 2036 | return rc; |
| 2037 | } |
| 2038 | |
| 2039 | for (uint32_tcxx . . $ uint32_t# i = 1; i <= dat->headercxx . . $ _grn_dat#header.->file_idcxx . . $ grn_dat_header#file_id.; ++i) { |
| 2040 | char trie_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 2041 | grn_dat_generate_trie_pathcxx . . $ `$anonymous_namespace_lib/dat.cpp`/grn_dat_generate_trie_path(c194a158e5e34a1c).(grn_io_path(dat->iocxx . . $ _grn_dat#io.), trie_path, i); |
| 2042 | struct stat stat; |
| 2043 | if (::stat(trie_path, &stat) != 0) { |
| 2044 | continue; |
| 2045 | } |
| 2046 | if (!grn_io_warm_path(ctx, dat->iocxx . . $ _grn_dat#io., trie_path)) { |
| 2047 | rc = ctx->rccxx . . $ _grn_ctx#rc.; |
| 2048 | break; |
| 2049 | } |
| 2050 | } |
| 2051 | |
| 2052 | return rc; |
| 2053 | } |
| 2054 | |
| 2055 | } // extern "C" |