1 | /* -*- c-basic-offset: 2 -*- */ |
2 | /* |
3 | Copyright(C) 2016 Brazil |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License version 2.1 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with this library; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | */ |
18 | |
19 | #include "grn_ctx.h" |
20 | |
21 | grn_rc |
22 | grn_dump_table_create_flags(grn_ctx *ctx, |
23 | grn_table_flags flags, |
24 | grn_obj *buffer) |
25 | { |
26 | GRN_API_ENTER; |
27 | |
28 | switch (flags & GRN_OBJ_TABLE_TYPE_MASK) { |
29 | case GRN_OBJ_TABLE_HASH_KEY: |
30 | GRN_TEXT_PUTS(ctx, buffer, "TABLE_HASH_KEY" ); |
31 | break; |
32 | case GRN_OBJ_TABLE_PAT_KEY: |
33 | GRN_TEXT_PUTS(ctx, buffer, "TABLE_PAT_KEY" ); |
34 | break; |
35 | case GRN_OBJ_TABLE_DAT_KEY: |
36 | GRN_TEXT_PUTS(ctx, buffer, "TABLE_DAT_KEY" ); |
37 | break; |
38 | case GRN_OBJ_TABLE_NO_KEY: |
39 | GRN_TEXT_PUTS(ctx, buffer, "TABLE_NO_KEY" ); |
40 | break; |
41 | } |
42 | if (flags & GRN_OBJ_KEY_LARGE) { |
43 | GRN_TEXT_PUTS(ctx, buffer, "|KEY_LARGE" ); |
44 | } |
45 | if (flags & GRN_OBJ_KEY_WITH_SIS) { |
46 | GRN_TEXT_PUTS(ctx, buffer, "|KEY_WITH_SIS" ); |
47 | } |
48 | if (flags & GRN_OBJ_KEY_NORMALIZE) { |
49 | GRN_TEXT_PUTS(ctx, buffer, "|KEY_NORMALIZE" ); |
50 | } |
51 | if (flags & GRN_OBJ_PERSISTENT) { |
52 | GRN_TEXT_PUTS(ctx, buffer, "|PERSISTENT" ); |
53 | } |
54 | |
55 | GRN_API_RETURN(ctx->rc); |
56 | } |
57 | |
58 | grn_rc |
59 | grn_dump_column_create_flags(grn_ctx *ctx, |
60 | grn_column_flags flags, |
61 | grn_obj *buffer) |
62 | { |
63 | GRN_API_ENTER; |
64 | |
65 | switch (flags & GRN_OBJ_COLUMN_TYPE_MASK) { |
66 | case GRN_OBJ_COLUMN_SCALAR: |
67 | GRN_TEXT_PUTS(ctx, buffer, "COLUMN_SCALAR" ); |
68 | break; |
69 | case GRN_OBJ_COLUMN_VECTOR: |
70 | GRN_TEXT_PUTS(ctx, buffer, "COLUMN_VECTOR" ); |
71 | if (flags & GRN_OBJ_WITH_WEIGHT) { |
72 | GRN_TEXT_PUTS(ctx, buffer, "|WITH_WEIGHT" ); |
73 | } |
74 | break; |
75 | case GRN_OBJ_COLUMN_INDEX: |
76 | GRN_TEXT_PUTS(ctx, buffer, "COLUMN_INDEX" ); |
77 | if (flags & GRN_OBJ_WITH_SECTION) { |
78 | GRN_TEXT_PUTS(ctx, buffer, "|WITH_SECTION" ); |
79 | } |
80 | if (flags & GRN_OBJ_WITH_WEIGHT) { |
81 | GRN_TEXT_PUTS(ctx, buffer, "|WITH_WEIGHT" ); |
82 | } |
83 | if (flags & GRN_OBJ_WITH_POSITION) { |
84 | GRN_TEXT_PUTS(ctx, buffer, "|WITH_POSITION" ); |
85 | } |
86 | if (flags & GRN_OBJ_INDEX_SMALL) { |
87 | GRN_TEXT_PUTS(ctx, buffer, "|INDEX_SMALL" ); |
88 | } |
89 | if (flags & GRN_OBJ_INDEX_MEDIUM) { |
90 | GRN_TEXT_PUTS(ctx, buffer, "|INDEX_MEDIUM" ); |
91 | } |
92 | break; |
93 | } |
94 | switch (flags & GRN_OBJ_COMPRESS_MASK) { |
95 | case GRN_OBJ_COMPRESS_NONE: |
96 | break; |
97 | case GRN_OBJ_COMPRESS_ZLIB: |
98 | GRN_TEXT_PUTS(ctx, buffer, "|COMPRESS_ZLIB" ); |
99 | break; |
100 | case GRN_OBJ_COMPRESS_LZ4: |
101 | GRN_TEXT_PUTS(ctx, buffer, "|COMPRESS_LZ4" ); |
102 | break; |
103 | case GRN_OBJ_COMPRESS_ZSTD: |
104 | GRN_TEXT_PUTS(ctx, buffer, "|COMPRESS_ZSTD" ); |
105 | break; |
106 | } |
107 | if (flags & GRN_OBJ_PERSISTENT) { |
108 | GRN_TEXT_PUTS(ctx, buffer, "|PERSISTENT" ); |
109 | } |
110 | |
111 | GRN_API_RETURN(ctx->rc); |
112 | } |
113 | |