rroonga 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +5 -0
- data/Gemfile +20 -0
- data/Rakefile +187 -0
- data/doc/text/news.textile +10 -2
- data/doc/text/tutorial.textile +0 -2
- data/ext/groonga/extconf.rb +7 -1
- data/ext/groonga/rb-grn-accessor.c +11 -11
- data/ext/groonga/rb-grn-array.c +25 -25
- data/ext/groonga/rb-grn-column.c +106 -106
- data/ext/groonga/rb-grn-context.c +121 -121
- data/ext/groonga/rb-grn-database.c +78 -78
- data/ext/groonga/rb-grn-double-array-trie.c +92 -92
- data/ext/groonga/rb-grn-encoding-support.c +1 -1
- data/ext/groonga/rb-grn-encoding.c +28 -28
- data/ext/groonga/rb-grn-exception.c +9 -9
- data/ext/groonga/rb-grn-expression-builder.c +6 -6
- data/ext/groonga/rb-grn-expression.c +87 -87
- data/ext/groonga/rb-grn-fix-size-column.c +12 -12
- data/ext/groonga/rb-grn-geo-point.c +2 -2
- data/ext/groonga/rb-grn-hash.c +38 -38
- data/ext/groonga/rb-grn-index-column.c +191 -191
- data/ext/groonga/rb-grn-index-cursor.c +29 -29
- data/ext/groonga/rb-grn-logger.c +36 -36
- data/ext/groonga/rb-grn-normalizer.c +10 -10
- data/ext/groonga/rb-grn-patricia-trie.c +196 -196
- data/ext/groonga/rb-grn-plugin.c +5 -5
- data/ext/groonga/rb-grn-posting.c +2 -2
- data/ext/groonga/rb-grn-procedure.c +2 -2
- data/ext/groonga/rb-grn-query-logger.c +1 -1
- data/ext/groonga/rb-grn-record.c +1 -1
- data/ext/groonga/rb-grn-snippet.c +14 -14
- data/ext/groonga/rb-grn-table-cursor-key-support.c +4 -4
- data/ext/groonga/rb-grn-table-cursor.c +52 -52
- data/ext/groonga/rb-grn-table-key-support.c +209 -209
- data/ext/groonga/rb-grn-type.c +18 -18
- data/ext/groonga/rb-grn-utils.c +332 -314
- data/ext/groonga/rb-grn-variable-size-column.c +34 -34
- data/ext/groonga/rb-grn-variable.c +2 -2
- data/ext/groonga/rb-grn.h +240 -232
- data/ext/groonga/rb-groonga.c +10 -10
- data/rroonga-build.rb +7 -0
- data/rroonga.gemspec +1 -1
- data/test/test-hash.rb +4 -4
- data/test/test-index-column.rb +271 -257
- data/test/test-table-key-support.rb +78 -0
- data/test/test-table.rb +78 -51
- metadata +195 -164
- checksums.yaml +0 -7
@@ -23,7 +23,7 @@ VALUE rb_cGrnPosting;
|
|
23
23
|
|
24
24
|
VALUE
|
25
25
|
rb_grn_posting_new (grn_posting *posting, grn_id term_id,
|
26
|
-
|
26
|
+
VALUE rb_table, VALUE rb_lexicon)
|
27
27
|
{
|
28
28
|
VALUE parameters;
|
29
29
|
|
@@ -46,7 +46,7 @@ rb_grn_posting_new (grn_posting *posting, grn_id term_id,
|
|
46
46
|
rb_hash_aset(parameters, ID2SYM(rb_intern("lexicon")), rb_lexicon);
|
47
47
|
|
48
48
|
return rb_funcall(rb_cGrnPosting, rb_intern("new"), 1,
|
49
|
-
|
49
|
+
parameters);
|
50
50
|
}
|
51
51
|
|
52
52
|
void
|
@@ -26,7 +26,7 @@ grn_obj *
|
|
26
26
|
rb_grn_procedure_from_ruby_object (VALUE object)
|
27
27
|
{
|
28
28
|
if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnProcedure))) {
|
29
|
-
|
29
|
+
rb_raise(rb_eTypeError, "not a groonga procedure");
|
30
30
|
}
|
31
31
|
|
32
32
|
return RVAL2GRNOBJECT(object, NULL);
|
@@ -34,7 +34,7 @@ rb_grn_procedure_from_ruby_object (VALUE object)
|
|
34
34
|
|
35
35
|
VALUE
|
36
36
|
rb_grn_procedure_to_ruby_object (grn_ctx *context, grn_obj *procedure,
|
37
|
-
|
37
|
+
grn_bool owner)
|
38
38
|
{
|
39
39
|
return GRNOBJECT2RVAL(rb_cGrnProcedure, context, procedure, owner);
|
40
40
|
}
|
data/ext/groonga/rb-grn-record.c
CHANGED
@@ -30,28 +30,28 @@ VALUE rb_cGrnSnippet;
|
|
30
30
|
|
31
31
|
void
|
32
32
|
rb_grn_snippet_finalizer (grn_ctx *context, grn_obj *object,
|
33
|
-
|
33
|
+
RbGrnSnippet *rb_grn_snippet)
|
34
34
|
{
|
35
35
|
rb_grn_context_unregister_floating_object(RB_GRN_OBJECT(rb_grn_snippet));
|
36
36
|
}
|
37
37
|
|
38
38
|
void
|
39
39
|
rb_grn_snippet_bind (RbGrnSnippet *rb_grn_snippet,
|
40
|
-
|
40
|
+
grn_ctx *context, grn_obj *snippet)
|
41
41
|
{
|
42
42
|
}
|
43
43
|
|
44
44
|
void
|
45
45
|
rb_grn_snippet_deconstruct (RbGrnSnippet *rb_grn_snippet,
|
46
|
-
|
47
|
-
|
46
|
+
grn_obj **snippet,
|
47
|
+
grn_ctx **context)
|
48
48
|
{
|
49
49
|
RbGrnObject *rb_grn_object;
|
50
50
|
|
51
51
|
rb_grn_object = RB_GRN_OBJECT(rb_grn_snippet);
|
52
52
|
rb_grn_object_deconstruct(rb_grn_object, snippet, context,
|
53
|
-
|
54
|
-
|
53
|
+
NULL, NULL,
|
54
|
+
NULL, NULL);
|
55
55
|
}
|
56
56
|
|
57
57
|
/*
|
@@ -112,10 +112,10 @@ rb_grn_snippet_initialize (int argc, VALUE *argv, VALUE self)
|
|
112
112
|
|
113
113
|
context = rb_grn_context_ensure(&rb_context);
|
114
114
|
if (!grn_ctx_db(context)) {
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
rb_raise(rb_eArgError,
|
116
|
+
"Groonga::Context should be associated with a database by "
|
117
|
+
"Groonga::Database#open or #create: %s",
|
118
|
+
rb_grn_inspect(rb_context));
|
119
119
|
}
|
120
120
|
|
121
121
|
if (RVAL2CBOOL(rb_normalize))
|
@@ -234,9 +234,9 @@ rb_grn_snippet_execute (VALUE self, VALUE rb_string)
|
|
234
234
|
rb_grn_snippet_deconstruct(SELF(self), &snippet, &context);
|
235
235
|
|
236
236
|
if (TYPE(rb_string) != T_STRING) {
|
237
|
-
|
238
|
-
|
239
|
-
|
237
|
+
rb_raise(rb_eGrnInvalidArgument,
|
238
|
+
"snippet text must be String: <%s>",
|
239
|
+
rb_grn_inspect(rb_string));
|
240
240
|
}
|
241
241
|
|
242
242
|
#ifdef HAVE_RUBY_ENCODING_H
|
@@ -257,7 +257,7 @@ rb_grn_snippet_execute (VALUE self, VALUE rb_string)
|
|
257
257
|
unsigned result_length;
|
258
258
|
|
259
259
|
rc = grn_snip_get_result(context, (grn_snip *)snippet,
|
260
|
-
|
260
|
+
i, result, &result_length);
|
261
261
|
rb_grn_rc_check(rc, self);
|
262
262
|
rb_result = rb_grn_context_rb_string_new(context, result, result_length);
|
263
263
|
rb_ary_push(rb_results, rb_result);
|
@@ -44,13 +44,13 @@ rb_grn_table_cursor_get_key (VALUE self)
|
|
44
44
|
grn_table_cursor *cursor;
|
45
45
|
|
46
46
|
rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
|
47
|
-
|
47
|
+
NULL, NULL, NULL, NULL);
|
48
48
|
if (context && cursor) {
|
49
49
|
void *key;
|
50
50
|
int key_size;
|
51
|
-
|
51
|
+
grn_obj *table;
|
52
52
|
|
53
|
-
|
53
|
+
table = grn_table_cursor_table(context, cursor);
|
54
54
|
key_size = grn_table_cursor_get_key(context, cursor, &key);
|
55
55
|
rb_key = GRNKEY2RVAL(context, key, key_size, table, self);
|
56
56
|
}
|
@@ -62,7 +62,7 @@ void
|
|
62
62
|
rb_grn_init_table_cursor_key_support (VALUE mGrn)
|
63
63
|
{
|
64
64
|
rb_mGrnTableCursorKeySupport =
|
65
|
-
|
65
|
+
rb_define_module_under(rb_cGrnTableCursor, "KeySupport");
|
66
66
|
|
67
67
|
rb_define_method(rb_mGrnTableCursorKeySupport, "key",
|
68
68
|
rb_grn_table_cursor_get_key, 0);
|
@@ -35,38 +35,38 @@ rb_grn_table_cursor_from_ruby_object (VALUE object, grn_ctx **context)
|
|
35
35
|
grn_table_cursor *table_cursor;
|
36
36
|
|
37
37
|
if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnTableCursor))) {
|
38
|
-
|
38
|
+
rb_raise(rb_eTypeError, "not a groonga table cursor");
|
39
39
|
}
|
40
40
|
|
41
41
|
rb_grn_table_cursor_deconstruct(SELF(object), &table_cursor, NULL,
|
42
|
-
|
43
|
-
|
42
|
+
NULL, NULL,
|
43
|
+
NULL, NULL);
|
44
44
|
return table_cursor;
|
45
45
|
}
|
46
46
|
|
47
47
|
VALUE
|
48
48
|
rb_grn_table_cursor_to_ruby_object (VALUE klass, grn_ctx *context,
|
49
|
-
|
50
|
-
|
49
|
+
grn_table_cursor *cursor,
|
50
|
+
grn_bool owner)
|
51
51
|
{
|
52
52
|
return GRNOBJECT2RVAL(klass, context, cursor, owner);
|
53
53
|
}
|
54
54
|
|
55
55
|
void
|
56
56
|
rb_grn_table_cursor_deconstruct (RbGrnTableCursor *rb_grn_table_cursor,
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
grn_table_cursor **cursor,
|
58
|
+
grn_ctx **context,
|
59
|
+
grn_id *domain_id,
|
60
|
+
grn_obj **domain,
|
61
|
+
grn_id *range_id,
|
62
|
+
grn_obj **range)
|
63
63
|
{
|
64
64
|
RbGrnObject *rb_grn_object;
|
65
65
|
|
66
66
|
rb_grn_object = RB_GRN_OBJECT(rb_grn_table_cursor);
|
67
67
|
rb_grn_object_deconstruct(rb_grn_object, cursor, context,
|
68
|
-
|
69
|
-
|
68
|
+
domain_id, domain,
|
69
|
+
range_id, range);
|
70
70
|
}
|
71
71
|
|
72
72
|
int
|
@@ -75,17 +75,17 @@ rb_grn_table_cursor_order_to_flag (VALUE rb_order)
|
|
75
75
|
int flag = 0;
|
76
76
|
|
77
77
|
if (NIL_P(rb_order) ||
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
rb_grn_equal_option(rb_order, "asc") ||
|
79
|
+
rb_grn_equal_option(rb_order, "ascending")) {
|
80
|
+
flag |= GRN_CURSOR_ASCENDING;
|
81
81
|
} else if (rb_grn_equal_option(rb_order, "desc") ||
|
82
|
-
|
83
|
-
|
82
|
+
rb_grn_equal_option(rb_order, "descending")) {
|
83
|
+
flag |= GRN_CURSOR_DESCENDING;
|
84
84
|
} else {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
rb_raise(rb_eArgError,
|
86
|
+
"order should be one of "
|
87
|
+
"[:asc, :ascending, :desc, :descending]: %s",
|
88
|
+
rb_grn_inspect(rb_order));
|
89
89
|
}
|
90
90
|
|
91
91
|
return flag;
|
@@ -93,32 +93,32 @@ rb_grn_table_cursor_order_to_flag (VALUE rb_order)
|
|
93
93
|
|
94
94
|
int
|
95
95
|
rb_grn_table_cursor_order_by_to_flag (unsigned char table_type,
|
96
|
-
|
97
|
-
|
96
|
+
VALUE rb_table,
|
97
|
+
VALUE rb_order_by)
|
98
98
|
{
|
99
99
|
int flag = 0;
|
100
100
|
|
101
101
|
if (NIL_P(rb_order_by)) {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
102
|
+
if (table_type == GRN_TABLE_PAT_KEY) {
|
103
|
+
flag |= GRN_CURSOR_BY_KEY;
|
104
|
+
} else {
|
105
|
+
flag |= GRN_CURSOR_BY_ID;
|
106
|
+
}
|
107
107
|
} else if (rb_grn_equal_option(rb_order_by, "id")) {
|
108
|
-
|
108
|
+
flag |= GRN_CURSOR_BY_ID;
|
109
109
|
} else if (rb_grn_equal_option(rb_order_by, "key")) {
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
110
|
+
if (table_type != GRN_TABLE_PAT_KEY) {
|
111
|
+
rb_raise(rb_eArgError,
|
112
|
+
"order_by => :key is available "
|
113
|
+
"only for Groonga::PatriciaTrie: %s",
|
114
|
+
rb_grn_inspect(rb_table));
|
115
|
+
}
|
116
|
+
flag |= GRN_CURSOR_BY_KEY;
|
117
117
|
} else {
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
rb_raise(rb_eArgError,
|
119
|
+
"order_by should be one of [:id%s]: %s",
|
120
|
+
table_type == GRN_TABLE_PAT_KEY ? ", :key" : "",
|
121
|
+
rb_grn_inspect(rb_order_by));
|
122
122
|
}
|
123
123
|
|
124
124
|
return flag;
|
@@ -138,7 +138,7 @@ rb_grn_table_cursor_get_value (VALUE self)
|
|
138
138
|
VALUE rb_value = Qnil;
|
139
139
|
|
140
140
|
rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
|
141
|
-
|
141
|
+
NULL, NULL, NULL, NULL);
|
142
142
|
if (context && cursor) {
|
143
143
|
int n;
|
144
144
|
void *value;
|
@@ -163,14 +163,14 @@ rb_grn_table_cursor_set_value (VALUE self, VALUE value)
|
|
163
163
|
grn_table_cursor *cursor;
|
164
164
|
|
165
165
|
rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
|
166
|
-
|
166
|
+
NULL, NULL, NULL, NULL);
|
167
167
|
if (context && cursor) {
|
168
168
|
grn_rc rc;
|
169
169
|
|
170
170
|
rc = grn_table_cursor_set_value(context,
|
171
171
|
cursor,
|
172
172
|
StringValuePtr(value),
|
173
|
-
|
173
|
+
GRN_OBJ_SET);
|
174
174
|
rb_grn_rc_check(rc, self);
|
175
175
|
}
|
176
176
|
|
@@ -189,7 +189,7 @@ rb_grn_table_cursor_delete (VALUE self)
|
|
189
189
|
grn_table_cursor *cursor;
|
190
190
|
|
191
191
|
rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
|
192
|
-
|
192
|
+
NULL, NULL, NULL, NULL);
|
193
193
|
if (context && cursor) {
|
194
194
|
grn_rc rc;
|
195
195
|
|
@@ -214,14 +214,14 @@ rb_grn_table_cursor_next (VALUE self)
|
|
214
214
|
grn_table_cursor *cursor;
|
215
215
|
|
216
216
|
rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
|
217
|
-
|
217
|
+
NULL, NULL, NULL, NULL);
|
218
218
|
if (context && cursor) {
|
219
219
|
grn_id record_id;
|
220
220
|
|
221
221
|
record_id = grn_table_cursor_next(context, cursor);
|
222
222
|
if (record_id != GRN_ID_NIL) /* FIXME: use grn_table_cursor_table */
|
223
223
|
rb_record = rb_grn_record_new(rb_iv_get(self, "@table"),
|
224
|
-
|
224
|
+
record_id, Qnil);
|
225
225
|
}
|
226
226
|
|
227
227
|
return rb_record;
|
@@ -243,13 +243,13 @@ rb_grn_table_cursor_each (VALUE self)
|
|
243
243
|
RETURN_ENUMERATOR(self, 0, NULL);
|
244
244
|
|
245
245
|
rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
|
246
|
-
|
246
|
+
NULL, NULL, NULL, NULL);
|
247
247
|
|
248
248
|
if (context && cursor) {
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
249
|
+
while ((record_id = grn_table_cursor_next(context, cursor))) {
|
250
|
+
rb_yield(rb_grn_record_new(rb_iv_get(self, "@table"),
|
251
|
+
record_id, Qnil));
|
252
|
+
}
|
253
253
|
}
|
254
254
|
|
255
255
|
return Qnil;
|