1 /* 2 Copyright(C) 2009-2016 Brazil 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, write to the Free Software 16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 module groonga_d.dat; 19 20 21 private static import groonga_d.groonga; 22 23 extern(C): 24 nothrow @nogc: 25 26 extern struct _grn_dat; 27 extern struct _grn_dat_cursor; 28 29 alias grn_dat = _grn_dat; 30 alias grn_dat_cursor = _grn_dat_cursor; 31 alias grn_dat_scan_hit = groonga_d.groonga._grn_table_scan_hit; 32 33 //GRN_API 34 int grn_dat_scan(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, const (char)* str, uint str_size, grn_dat_scan_hit* scan_hits, uint max_num_scan_hits, const (char)** str_rest); 35 36 //GRN_API 37 uint grn_dat_lcp_search(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, const (void)* key, uint key_size); 38 39 //GRN_API 40 grn_dat* grn_dat_create(groonga_d.groonga.grn_ctx* ctx, const (char)* path, uint key_size, uint value_size, uint flags); 41 42 //GRN_API 43 grn_dat* grn_dat_open(groonga_d.groonga.grn_ctx* ctx, const (char)* path); 44 45 //GRN_API 46 groonga_d.groonga.grn_rc grn_dat_close(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat); 47 48 //GRN_API 49 groonga_d.groonga.grn_rc grn_dat_remove(groonga_d.groonga.grn_ctx* ctx, const (char)* path); 50 51 //GRN_API 52 uint grn_dat_get(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, const (void)* key, uint key_size, void** value); 53 54 //GRN_API 55 uint grn_dat_add(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, const (void)* key, uint key_size, void** value, int* added); 56 57 //GRN_API 58 int grn_dat_get_key(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, uint id, void* keybuf, int bufsize); 59 60 //GRN_API 61 int grn_dat_get_key2(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, uint id, groonga_d.groonga.grn_obj* bulk); 62 63 //GRN_API 64 groonga_d.groonga.grn_rc grn_dat_delete_by_id(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, uint id, groonga_d.groonga.grn_table_delete_optarg* optarg); 65 66 //GRN_API 67 groonga_d.groonga.grn_rc grn_dat_delete(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, const (void)* key, uint key_size, groonga_d.groonga.grn_table_delete_optarg* optarg); 68 69 //GRN_API 70 groonga_d.groonga.grn_rc grn_dat_update_by_id(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, uint src_key_id, const (void)* dest_key, uint dest_key_size); 71 72 //GRN_API 73 groonga_d.groonga.grn_rc grn_dat_update(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, const (void)* src_key, uint src_key_size, const (void)* dest_key, uint dest_key_size); 74 75 //GRN_API 76 uint grn_dat_size(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat); 77 78 //GRN_API 79 grn_dat_cursor* grn_dat_cursor_open(groonga_d.groonga.grn_ctx* ctx, grn_dat* dat, const (void)* min, uint min_size, const (void)* max, uint max_size, int offset, int limit, int flags); 80 81 //GRN_API 82 uint grn_dat_cursor_next(groonga_d.groonga.grn_ctx* ctx, grn_dat_cursor* c); 83 84 //GRN_API 85 void grn_dat_cursor_close(groonga_d.groonga.grn_ctx* ctx, grn_dat_cursor* c); 86 87 //GRN_API 88 int grn_dat_cursor_get_key(groonga_d.groonga.grn_ctx* ctx, grn_dat_cursor* c, const (void)** key); 89 90 //GRN_API 91 groonga_d.groonga.grn_rc grn_dat_cursor_delete(groonga_d.groonga.grn_ctx* ctx, grn_dat_cursor* c, groonga_d.groonga.grn_table_delete_optarg* optarg); 92 93 /+ 94 #define GRN_DAT_EACH(ctx, dat, id, key, key_size, block) grn_dat_cursor *_sc = grn_dat_cursor_open(ctx, dat, null, 0, null, 0, 0, -1, 0); if (_sc) { uint id; uint *_ks = (key_size); if (_ks) { while ((id = grn_dat_cursor_next(ctx, _sc))) { int _ks_raw = grn_dat_cursor_get_key(ctx, _sc, (const void **)(key)); *(_ks) = cast(uint)(_ks_raw); block } } else { while ((id = grn_dat_cursor_next(ctx, _sc))) { grn_dat_cursor_get_key(ctx, _sc, (const void **)(key)); block } } grn_dat_cursor_close(ctx, _sc); } 95 +/