1 /*
2   Copyright(C) 2009-2017  Brazil
3   Copyright(C) 2018-2021  Sutou Kouhei <kou@clear-code.com>
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 module groonga_d.column;
20 
21 
22 private static import groonga_d.groonga;
23 
24 extern(C):
25 nothrow @nogc:
26 
27 extern struct _grn_column_cache;
28 alias grn_column_cache = _grn_column_cache;
29 
30 enum GRN_COLUMN_NAME_ID = "_id";
31 enum GRN_COLUMN_NAME_ID_LEN = .GRN_COLUMN_NAME_ID.length;
32 enum GRN_COLUMN_NAME_KEY = "_key";
33 enum GRN_COLUMN_NAME_KEY_LEN = .GRN_COLUMN_NAME_KEY.length;
34 enum GRN_COLUMN_NAME_VALUE = "_value";
35 enum GRN_COLUMN_NAME_VALUE_LEN = .GRN_COLUMN_NAME_VALUE.length;
36 enum GRN_COLUMN_NAME_SCORE = "_score";
37 enum GRN_COLUMN_NAME_SCORE_LEN = .GRN_COLUMN_NAME_SCORE.length;
38 enum GRN_COLUMN_NAME_NSUBRECS = "_nsubrecs";
39 enum GRN_COLUMN_NAME_NSUBRECS_LEN = .GRN_COLUMN_NAME_NSUBRECS.length;
40 enum GRN_COLUMN_NAME_MAX = "_max";
41 enum GRN_COLUMN_NAME_MAX_LEN = .GRN_COLUMN_NAME_MAX.length;
42 enum GRN_COLUMN_NAME_MIN = "_min";
43 enum GRN_COLUMN_NAME_MIN_LEN = .GRN_COLUMN_NAME_MIN.length;
44 enum GRN_COLUMN_NAME_SUM = "_sum";
45 enum GRN_COLUMN_NAME_SUM_LEN = .GRN_COLUMN_NAME_SUM.length;
46 /* Deprecated since 10.0.4. Use GRN_COLUMN_NAME_MEAN instead. */
47 enum GRN_COLUMN_NAME_AVG = "_avg";
48 enum GRN_COLUMN_NAME_AVG_LEN = .GRN_COLUMN_NAME_AVG.length;
49 enum GRN_COLUMN_NAME_MEAN = "_mean";
50 enum GRN_COLUMN_NAME_MEAN_LEN = .GRN_COLUMN_NAME_MEAN.length;
51 
52 //GRN_API
53 groonga_d.groonga.grn_obj* grn_column_create(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* table, const (char)* name, uint name_size, const (char)* path, groonga_d.groonga.grn_column_flags flags, groonga_d.groonga.grn_obj* type);
54 
55 //GRN_API
56 groonga_d.groonga.grn_obj* grn_column_create_similar(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* table, const (char)* name, uint name_size, const (char)* path, groonga_d.groonga.grn_obj* base_column);
57 
58 pragma(inline, true)
59 bool GRN_COLUMN_OPEN_OR_CREATE(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* table, const (char)* name, uint name_size, const (char)* path, uint flags, groonga_d.groonga.grn_obj* type, groonga_d.groonga.grn_obj* column)
60 
61 	do
62 	{
63 		return ((column = groonga_d.groonga.grn_obj_column(ctx, table, name, name_size)) != null) || ((column = grn_column_create(ctx, table, name, name_size, path, flags, type)) != null);
64 	}
65 
66 //GRN_API
67 groonga_d.groonga.grn_rc grn_column_index_update(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* column, groonga_d.groonga.grn_id id, uint section, groonga_d.groonga.grn_obj* oldvalue, groonga_d.groonga.grn_obj* newvalue);
68 
69 //GRN_API
70 groonga_d.groonga.grn_obj* grn_column_table(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* column);
71 
72 //GRN_API
73 groonga_d.groonga.grn_rc grn_column_truncate(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* column);
74 
75 //GRN_API
76 groonga_d.groonga.grn_column_flags grn_column_get_flags(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* column);
77 
78 //GRN_API
79 grn_column_cache* grn_column_cache_open(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* column);
80 
81 //GRN_API
82 void grn_column_cache_close(groonga_d.groonga.grn_ctx* ctx, grn_column_cache* cache);
83 
84 //GRN_API
85 void* grn_column_cache_ref(groonga_d.groonga.grn_ctx* ctx, grn_column_cache* cache, groonga_d.groonga.grn_id id, size_t* value_size);
86 
87 //GRN_API
88 groonga_d.groonga.grn_rc grn_column_copy(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* from, groonga_d.groonga.grn_obj* to);