groonga 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS.ja.rdoc +11 -0
- data/NEWS.rdoc +11 -0
- data/README.ja.rdoc +4 -3
- data/README.rdoc +4 -3
- data/Rakefile +1 -1
- data/TUTORIAL.ja.rdoc +168 -44
- data/benchmark/common.rb +49 -0
- data/benchmark/read-write-small-many-items.rb +156 -0
- data/benchmark/write-small-many-items.rb +145 -0
- data/example/bookmark.rb +68 -20
- data/ext/rb-grn-array-cursor.c +8 -0
- data/ext/rb-grn-array.c +40 -11
- data/ext/rb-grn-column.c +38 -209
- data/ext/rb-grn-context.c +203 -56
- data/ext/rb-grn-database.c +119 -5
- data/ext/rb-grn-encoding-support.c +64 -0
- data/ext/rb-grn-encoding.c +58 -1
- data/ext/rb-grn-fix-size-column.c +220 -0
- data/ext/rb-grn-hash-cursor.c +8 -0
- data/ext/rb-grn-hash.c +244 -2
- data/ext/rb-grn-index-column.c +474 -0
- data/ext/rb-grn-object.c +143 -265
- data/ext/rb-grn-patricia-trie.c +148 -2
- data/ext/rb-grn-query.c +5 -3
- data/ext/rb-grn-record.c +3 -2
- data/ext/rb-grn-snippet.c +5 -3
- data/ext/rb-grn-table-cursor-key-support.c +3 -3
- data/ext/rb-grn-table-cursor.c +106 -112
- data/ext/rb-grn-table-key-support.c +220 -118
- data/ext/rb-grn-table.c +336 -80
- data/ext/rb-grn-type.c +5 -4
- data/ext/rb-grn-utils.c +62 -63
- data/ext/rb-grn.h +215 -14
- data/ext/rb-groonga.c +7 -16
- data/extconf.rb +3 -1
- data/html/favicon.ico +0 -0
- data/html/favicon.xcf +0 -0
- data/html/index.html +1 -7
- data/lib/groonga/record.rb +6 -1
- data/test/groonga-test-utils.rb +1 -0
- data/test/test-array.rb +81 -0
- data/test/test-column.rb +22 -12
- data/test/test-context.rb +1 -29
- data/test/test-database.rb +30 -0
- data/test/test-hash.rb +194 -0
- data/test/test-index-column.rb +57 -0
- data/test/test-patricia-trie.rb +82 -0
- data/test/test-record.rb +10 -10
- data/test/test-table.rb +37 -130
- data/test/test-type.rb +4 -3
- metadata +15 -4
- data/benchmark/small-many-items.rb +0 -175
data/ext/rb-grn-utils.c
CHANGED
@@ -96,10 +96,10 @@ rb_grn_bulk_to_ruby_object_by_range_id (grn_ctx *context, grn_obj *bulk,
|
|
96
96
|
case GRN_DB_VOID:
|
97
97
|
*rb_value = rb_str_new(GRN_BULK_HEAD(bulk), GRN_BULK_VSIZE(bulk));
|
98
98
|
break;
|
99
|
-
case
|
99
|
+
case GRN_DB_INT32:
|
100
100
|
*rb_value = INT2NUM(*((int *)GRN_BULK_HEAD(bulk)));
|
101
101
|
break;
|
102
|
-
case
|
102
|
+
case GRN_DB_UINT32:
|
103
103
|
*rb_value = UINT2NUM(*((int *)GRN_BULK_HEAD(bulk)));
|
104
104
|
break;
|
105
105
|
case GRN_DB_INT64:
|
@@ -148,7 +148,7 @@ rb_grn_bulk_to_ruby_object_by_range_type (grn_ctx *context, grn_obj *bulk,
|
|
148
148
|
if (id == GRN_ID_NIL)
|
149
149
|
*rb_value = Qnil;
|
150
150
|
else
|
151
|
-
*rb_value = rb_grn_record_new(rb_range, id);
|
151
|
+
*rb_value = rb_grn_record_new(rb_range, id, Qnil);
|
152
152
|
}
|
153
153
|
break;
|
154
154
|
default:
|
@@ -172,7 +172,7 @@ rb_grn_bulk_to_ruby_object (grn_ctx *context, grn_obj *bulk,
|
|
172
172
|
return Qnil;
|
173
173
|
|
174
174
|
range_id = bulk->header.domain;
|
175
|
-
range =
|
175
|
+
range = grn_ctx_at(context, range_id);
|
176
176
|
rb_range = GRNOBJECT2RVAL(Qnil, context, range, RB_GRN_FALSE);
|
177
177
|
|
178
178
|
if (rb_grn_bulk_to_ruby_object_by_range_id(context, bulk,
|
@@ -200,66 +200,74 @@ rb_grn_bulk_from_ruby_object (VALUE object, grn_ctx *context, grn_obj *bulk)
|
|
200
200
|
grn_id id_value;
|
201
201
|
grn_obj_flags flags = 0;
|
202
202
|
|
203
|
-
|
203
|
+
switch (TYPE(object)) {
|
204
|
+
case T_NIL:
|
204
205
|
string = NULL;
|
205
206
|
size = 0;
|
206
|
-
|
207
|
+
break;
|
208
|
+
case T_STRING:
|
207
209
|
string = RSTRING_PTR(object);
|
208
210
|
size = RSTRING_LEN(object);
|
209
211
|
flags |= GRN_OBJ_DO_SHALLOW_COPY;
|
210
|
-
|
212
|
+
break;
|
213
|
+
case T_FIXNUM:
|
211
214
|
int32_value = NUM2INT(object);
|
212
215
|
string = (const char *)&int32_value;
|
213
216
|
size = sizeof(int32_value);
|
214
|
-
|
217
|
+
break;
|
218
|
+
case T_BIGNUM:
|
215
219
|
int64_value = NUM2LL(object);
|
216
220
|
string = (const char *)&int64_value;
|
217
221
|
size = sizeof(int64_value);
|
218
|
-
|
222
|
+
break;
|
223
|
+
case T_FLOAT:
|
219
224
|
double_value = NUM2DBL(object);
|
220
225
|
string = (const char *)&double_value;
|
221
226
|
size = sizeof(double_value);
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
227
|
+
break;
|
228
|
+
default:
|
229
|
+
if (RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cTime))) {
|
230
|
+
VALUE sec, usec;
|
231
|
+
|
232
|
+
sec = rb_funcall(object, rb_intern("to_i"), 0);
|
233
|
+
usec = rb_funcall(object, rb_intern("usec"), 0);
|
234
|
+
time_value.tv_sec = NUM2INT(sec);
|
235
|
+
time_value.tv_usec = NUM2INT(usec);
|
236
|
+
string = (const char *)&time_value;
|
237
|
+
size = sizeof(time_value);
|
238
|
+
} else if (RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnObject))) {
|
239
|
+
grn_obj *grn_object;
|
240
|
+
|
241
|
+
grn_object = RVAL2GRNOBJECT(object, &context);
|
242
|
+
id_value = grn_obj_id(context, grn_object);
|
243
|
+
string = (const char *)&id_value;
|
244
|
+
size = sizeof(id_value);
|
245
|
+
} else if (RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnRecord))) {
|
246
|
+
id_value = NUM2UINT(rb_funcall(object, rb_intern("id"), 0));
|
247
|
+
string = (const char *)&id_value;
|
248
|
+
size = sizeof(id_value);
|
249
|
+
} else {
|
250
|
+
rb_raise(rb_eTypeError,
|
251
|
+
"bulked object should be one of "
|
252
|
+
"[nil, String, Integer, Float, Time, Groonga::Object]: %s",
|
253
|
+
rb_grn_inspect(object));
|
254
|
+
}
|
255
|
+
break;
|
247
256
|
}
|
248
257
|
|
249
|
-
if (bulk) {
|
250
|
-
|
251
|
-
} else {
|
252
|
-
bulk = grn_obj_open(context, GRN_BULK, 0, flags);
|
258
|
+
if (!bulk) {
|
259
|
+
bulk = grn_obj_open(context, GRN_BULK, flags, GRN_ID_NIL);
|
253
260
|
rb_grn_context_check(context, object);
|
254
261
|
}
|
255
|
-
|
262
|
+
GRN_TEXT_SET(context, bulk, string, size);
|
256
263
|
|
257
264
|
return bulk;
|
258
265
|
}
|
259
266
|
|
260
267
|
grn_obj *
|
261
268
|
rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
262
|
-
grn_obj *bulk,
|
269
|
+
grn_obj *bulk,
|
270
|
+
grn_id type_id, grn_obj *type)
|
263
271
|
{
|
264
272
|
const char *string;
|
265
273
|
unsigned int size;
|
@@ -271,15 +279,14 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
271
279
|
grn_id range;
|
272
280
|
VALUE rb_type;
|
273
281
|
grn_obj_flags flags = 0;
|
274
|
-
grn_obj *type_object;
|
275
282
|
|
276
|
-
switch (
|
277
|
-
case
|
283
|
+
switch (type_id) {
|
284
|
+
case GRN_DB_INT32:
|
278
285
|
int32_value = NUM2INT(object);
|
279
286
|
string = (const char *)&int32_value;
|
280
287
|
size = sizeof(int32_value);
|
281
288
|
break;
|
282
|
-
case
|
289
|
+
case GRN_DB_UINT32:
|
283
290
|
uint32_value = NUM2UINT(object);
|
284
291
|
string = (const char *)&uint32_value;
|
285
292
|
size = sizeof(uint32_value);
|
@@ -305,7 +312,7 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
305
312
|
case GRN_DB_LONGTEXT:
|
306
313
|
string = StringValuePtr(object);
|
307
314
|
size = RSTRING_LEN(object);
|
308
|
-
range = grn_obj_get_range(context,
|
315
|
+
range = grn_obj_get_range(context, type);
|
309
316
|
if (size > range)
|
310
317
|
rb_raise(rb_eArgError,
|
311
318
|
"string is too large: expected: %u <= %u",
|
@@ -318,8 +325,7 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
318
325
|
case GRN_DB_BIGRAM:
|
319
326
|
case GRN_DB_TRIGRAM:
|
320
327
|
case GRN_DB_MECAB:
|
321
|
-
|
322
|
-
rb_type = GRNOBJECT2RVAL(Qnil, context, type_object, RB_GRN_FALSE);
|
328
|
+
rb_type = GRNOBJECT2RVAL(Qnil, context, type, RB_GRN_FALSE);
|
323
329
|
rb_raise(rb_eArgError,
|
324
330
|
"unbulkable type: %s",
|
325
331
|
rb_grn_inspect(rb_type));
|
@@ -329,13 +335,11 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
329
335
|
break;
|
330
336
|
}
|
331
337
|
|
332
|
-
if (bulk) {
|
333
|
-
GRN_OBJ_INIT(bulk, GRN_BULK, flags);
|
334
|
-
} else {
|
338
|
+
if (!bulk) {
|
335
339
|
bulk = grn_obj_open(context, GRN_BULK, flags, GRN_ID_NIL);
|
336
340
|
rb_grn_context_check(context, object);
|
337
341
|
}
|
338
|
-
|
342
|
+
GRN_TEXT_SET(context, bulk, string, size);
|
339
343
|
|
340
344
|
return bulk;
|
341
345
|
}
|
@@ -376,7 +380,7 @@ rb_grn_vector_from_ruby_object (VALUE object, grn_ctx *context, grn_obj *vector)
|
|
376
380
|
int i, n;
|
377
381
|
|
378
382
|
if (vector)
|
379
|
-
GRN_OBJ_INIT(vector, GRN_VECTOR, 0);
|
383
|
+
GRN_OBJ_INIT(vector, GRN_VECTOR, 0, GRN_ID_NIL);
|
380
384
|
else
|
381
385
|
vector = grn_obj_open(context, GRN_VECTOR, 0, 0);
|
382
386
|
|
@@ -428,7 +432,7 @@ rb_grn_uvector_from_ruby_object (VALUE object, grn_ctx *context,
|
|
428
432
|
int i, n;
|
429
433
|
|
430
434
|
if (uvector)
|
431
|
-
GRN_OBJ_INIT(uvector, GRN_UVECTOR, 0);
|
435
|
+
GRN_OBJ_INIT(uvector, GRN_UVECTOR, 0, GRN_ID_NIL);
|
432
436
|
else
|
433
437
|
uvector = grn_obj_open(context, GRN_UVECTOR, 0, 0);
|
434
438
|
|
@@ -526,8 +530,8 @@ rb_grn_key_to_ruby_object (grn_ctx *context, const void *key, int key_size,
|
|
526
530
|
{
|
527
531
|
grn_obj bulk;
|
528
532
|
|
529
|
-
GRN_OBJ_INIT(&bulk, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY);
|
530
|
-
|
533
|
+
GRN_OBJ_INIT(&bulk, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY, GRN_ID_NIL);
|
534
|
+
GRN_TEXT_SET(context, &bulk, key, key_size);
|
531
535
|
bulk.header.domain = table->header.domain;
|
532
536
|
|
533
537
|
return GRNBULK2RVAL(context, &bulk, related_object);
|
@@ -535,21 +539,17 @@ rb_grn_key_to_ruby_object (grn_ctx *context, const void *key, int key_size,
|
|
535
539
|
|
536
540
|
grn_obj *
|
537
541
|
rb_grn_key_from_ruby_object (VALUE rb_key, grn_ctx *context,
|
538
|
-
grn_obj *key, grn_id domain_id,
|
542
|
+
grn_obj *key, grn_id domain_id, grn_obj *domain,
|
539
543
|
VALUE related_object)
|
540
544
|
{
|
541
|
-
grn_obj *domain = NULL;
|
542
545
|
grn_id id;
|
543
546
|
|
544
|
-
if (domain_id != GRN_ID_NIL)
|
545
|
-
domain = grn_ctx_get(context, domain_id);
|
546
|
-
|
547
547
|
if (!domain)
|
548
548
|
return RVAL2GRNBULK(rb_key, context, key);
|
549
549
|
|
550
550
|
switch (domain->header.type) {
|
551
551
|
case GRN_TYPE:
|
552
|
-
return RVAL2GRNBULK_WITH_TYPE(rb_key, context, key, domain_id);
|
552
|
+
return RVAL2GRNBULK_WITH_TYPE(rb_key, context, key, domain_id, domain);
|
553
553
|
break;
|
554
554
|
case GRN_TABLE_HASH_KEY:
|
555
555
|
case GRN_TABLE_PAT_KEY:
|
@@ -567,8 +567,7 @@ rb_grn_key_from_ruby_object (VALUE rb_key, grn_ctx *context,
|
|
567
567
|
break;
|
568
568
|
}
|
569
569
|
|
570
|
-
|
571
|
-
GRN_BULK_SET(context, key, &id, sizeof(id));
|
570
|
+
GRN_TEXT_SET(context, key, &id, sizeof(id));
|
572
571
|
return key;
|
573
572
|
}
|
574
573
|
|
data/ext/rb-grn.h
CHANGED
@@ -59,7 +59,7 @@ RB_GRN_BEGIN_DECLS
|
|
59
59
|
|
60
60
|
#define RB_GRN_MAJOR_VERSION 0
|
61
61
|
#define RB_GRN_MINOR_VERSION 0
|
62
|
-
#define RB_GRN_MICRO_VERSION
|
62
|
+
#define RB_GRN_MICRO_VERSION 2
|
63
63
|
|
64
64
|
typedef int rb_grn_boolean;
|
65
65
|
#define RB_GRN_FALSE (0)
|
@@ -74,9 +74,74 @@ typedef struct {
|
|
74
74
|
int32_t tv_usec;
|
75
75
|
} grn_timeval;
|
76
76
|
|
77
|
+
#define RB_GRN_OBJECT(object) ((RbGrnObject *)(object))
|
78
|
+
#define RB_GRN_TABLE(object) ((RbGrnTable *)(object))
|
79
|
+
#define RB_GRN_TABLE_CURSOR(object) ((RbGrnTableCursort *)(object))
|
80
|
+
#define RB_GRN_INDEX_COLUMN(object) ((RbGrnIndexColumn *)(object))
|
81
|
+
#define RB_GRN_UNBIND_FUNCTION(function) ((RbGrnUnbindFunction)(function))
|
82
|
+
|
83
|
+
typedef void (*RbGrnUnbindFunction) (void *object);
|
84
|
+
|
85
|
+
typedef struct _RbGrnObject RbGrnObject;
|
86
|
+
struct _RbGrnObject
|
87
|
+
{
|
88
|
+
grn_ctx *context;
|
89
|
+
grn_obj *object;
|
90
|
+
grn_obj *domain;
|
91
|
+
grn_id domain_id;
|
92
|
+
grn_obj *range;
|
93
|
+
grn_id range_id;
|
94
|
+
rb_grn_boolean owner;
|
95
|
+
RbGrnUnbindFunction unbind;
|
96
|
+
};
|
97
|
+
|
98
|
+
typedef struct _RbGrnTable RbGrnTable;
|
99
|
+
struct _RbGrnTable
|
100
|
+
{
|
101
|
+
RbGrnObject parent;
|
102
|
+
grn_obj *value;
|
103
|
+
};
|
104
|
+
|
105
|
+
typedef struct _RbGrnTableKeySupport RbGrnTableKeySupport;
|
106
|
+
struct _RbGrnTableKeySupport
|
107
|
+
{
|
108
|
+
RbGrnTable parent;
|
109
|
+
grn_obj *key;
|
110
|
+
};
|
111
|
+
|
112
|
+
typedef struct _RbGrnColumn RbGrnColumn;
|
113
|
+
struct _RbGrnColumn
|
114
|
+
{
|
115
|
+
RbGrnObject parent;
|
116
|
+
grn_obj *value;
|
117
|
+
};
|
118
|
+
|
119
|
+
typedef struct _RbGrnFixSizeColumn RbGrnFixSizeColumn;
|
120
|
+
struct _RbGrnFixSizeColumn
|
121
|
+
{
|
122
|
+
RbGrnObject parent;
|
123
|
+
grn_obj *value;
|
124
|
+
};
|
125
|
+
|
126
|
+
typedef struct _RbGrnIndexColumn RbGrnIndexColumn;
|
127
|
+
struct _RbGrnIndexColumn
|
128
|
+
{
|
129
|
+
RbGrnObject parent;
|
130
|
+
grn_obj *value;
|
131
|
+
grn_obj *old_value;
|
132
|
+
grn_obj *id_query;
|
133
|
+
grn_obj *string_query;
|
134
|
+
};
|
135
|
+
|
136
|
+
typedef struct _RbGrnTableCursor RbGrnTableCursor;
|
137
|
+
struct _RbGrnTableCursor
|
138
|
+
{
|
139
|
+
RbGrnObject parent;
|
140
|
+
};
|
77
141
|
|
78
142
|
RB_GRN_VAR VALUE rb_eGrnError;
|
79
143
|
RB_GRN_VAR VALUE rb_cGrnObject;
|
144
|
+
RB_GRN_VAR VALUE rb_mGrnEncodingSupport;
|
80
145
|
RB_GRN_VAR VALUE rb_cGrnDatabase;
|
81
146
|
RB_GRN_VAR VALUE rb_cGrnTable;
|
82
147
|
RB_GRN_VAR VALUE rb_mGrnTableKeySupport;
|
@@ -103,6 +168,7 @@ RB_GRN_VAR VALUE rb_cGrnSnippet;
|
|
103
168
|
void rb_grn_init_utils (VALUE mGrn);
|
104
169
|
void rb_grn_init_exception (VALUE mGrn);
|
105
170
|
void rb_grn_init_encoding (VALUE mGrn);
|
171
|
+
void rb_grn_init_encoding_support (VALUE mGrn);
|
106
172
|
void rb_grn_init_context (VALUE mGrn);
|
107
173
|
void rb_grn_init_object (VALUE mGrn);
|
108
174
|
void rb_grn_init_database (VALUE mGrn);
|
@@ -119,6 +185,8 @@ void rb_grn_init_patricia_trie_cursor (VALUE mGrn);
|
|
119
185
|
void rb_grn_init_type (VALUE mGrn);
|
120
186
|
void rb_grn_init_procedure (VALUE mGrn);
|
121
187
|
void rb_grn_init_column (VALUE mGrn);
|
188
|
+
void rb_grn_init_fix_size_column (VALUE mGrn);
|
189
|
+
void rb_grn_init_index_column (VALUE mGrn);
|
122
190
|
void rb_grn_init_accessor (VALUE mGrn);
|
123
191
|
void rb_grn_init_record (VALUE mGrn);
|
124
192
|
void rb_grn_init_query (VALUE mGrn);
|
@@ -130,7 +198,13 @@ const char *rb_grn_rc_to_message (grn_rc rc);
|
|
130
198
|
void rb_grn_rc_check (grn_rc rc,
|
131
199
|
VALUE related_object);
|
132
200
|
|
133
|
-
grn_ctx
|
201
|
+
void rb_grn_context_register (grn_ctx *context,
|
202
|
+
RbGrnObject *object);
|
203
|
+
void rb_grn_context_unregister (grn_ctx *context,
|
204
|
+
RbGrnObject *object);
|
205
|
+
void rb_grn_context_unbind (grn_ctx *context);
|
206
|
+
|
207
|
+
grn_ctx *rb_grn_context_ensure (VALUE *context);
|
134
208
|
VALUE rb_grn_context_get_default (void);
|
135
209
|
VALUE rb_grn_context_to_exception (grn_ctx *context,
|
136
210
|
VALUE related_object);
|
@@ -144,9 +218,24 @@ rb_grn_boolean rb_grn_equal_option (VALUE option,
|
|
144
218
|
const char *key);
|
145
219
|
|
146
220
|
VALUE rb_grn_object_alloc (VALUE klass);
|
147
|
-
void
|
221
|
+
void rb_grn_object_bind (RbGrnObject *rb_grn_object,
|
148
222
|
grn_ctx *context,
|
149
|
-
grn_obj *object
|
223
|
+
grn_obj *object,
|
224
|
+
rb_grn_boolean owner);
|
225
|
+
void rb_grn_object_unbind (RbGrnObject *rb_grn_object);
|
226
|
+
void rb_grn_object_assign (VALUE self,
|
227
|
+
VALUE rb_context,
|
228
|
+
grn_ctx *context,
|
229
|
+
grn_obj *object,
|
230
|
+
rb_grn_boolean owner);
|
231
|
+
void rb_grn_object_deconstruct (RbGrnObject *rb_grn_object,
|
232
|
+
grn_obj **object,
|
233
|
+
grn_ctx **context,
|
234
|
+
grn_id *domain_id,
|
235
|
+
grn_obj **domain,
|
236
|
+
grn_id *range_id,
|
237
|
+
grn_obj **range);
|
238
|
+
|
150
239
|
VALUE rb_grn_object_array_reference (VALUE object,
|
151
240
|
VALUE rb_id);
|
152
241
|
VALUE rb_grn_object_close (VALUE object);
|
@@ -163,16 +252,116 @@ VALUE rb_grn_object_inspect_content (VALUE object,
|
|
163
252
|
VALUE rb_grn_object_inspect_footer (VALUE object,
|
164
253
|
VALUE inspected);
|
165
254
|
|
255
|
+
VALUE rb_grn_table_alloc (VALUE klass);
|
256
|
+
void rb_grn_table_bind (RbGrnTable *rb_grn_table,
|
257
|
+
grn_ctx *context,
|
258
|
+
grn_obj *table_key_support,
|
259
|
+
rb_grn_boolean owner);
|
260
|
+
void rb_grn_table_unbind (RbGrnTable *rb_grn_table);
|
261
|
+
void rb_grn_table_assign (VALUE self,
|
262
|
+
VALUE rb_context,
|
263
|
+
grn_ctx *context,
|
264
|
+
grn_obj *table,
|
265
|
+
rb_grn_boolean owner);
|
266
|
+
void rb_grn_table_deconstruct (RbGrnTable *rb_grn_table,
|
267
|
+
grn_obj **table,
|
268
|
+
grn_ctx **context,
|
269
|
+
grn_id *domain_id,
|
270
|
+
grn_obj **domain,
|
271
|
+
grn_obj **value,
|
272
|
+
grn_id *range_id,
|
273
|
+
grn_obj **range);
|
274
|
+
|
275
|
+
grn_obj *rb_grn_table_open_raw (int argc,
|
276
|
+
VALUE *argv,
|
277
|
+
grn_ctx **context,
|
278
|
+
VALUE *rb_context);
|
166
279
|
VALUE rb_grn_table_s_create (int argc,
|
167
280
|
VALUE *argv,
|
168
281
|
VALUE klass,
|
169
282
|
grn_obj_flags key_store);
|
283
|
+
|
284
|
+
VALUE rb_grn_table_delete (VALUE self,
|
285
|
+
VALUE rb_id);
|
286
|
+
VALUE rb_grn_table_array_reference (VALUE self,
|
287
|
+
VALUE rb_id);
|
288
|
+
VALUE rb_grn_table_array_set (VALUE self,
|
289
|
+
VALUE rb_id,
|
290
|
+
VALUE rb_value);
|
291
|
+
|
170
292
|
grn_ctx *rb_grn_table_cursor_ensure_context (VALUE cursor,
|
171
|
-
VALUE rb_context);
|
293
|
+
VALUE *rb_context);
|
172
294
|
VALUE rb_grn_table_cursor_close (VALUE object);
|
173
295
|
|
296
|
+
VALUE rb_grn_table_key_support_alloc (VALUE klass);
|
297
|
+
void rb_grn_table_key_support_bind (RbGrnTableKeySupport *rb_grn_table_key_support,
|
298
|
+
grn_ctx *context,
|
299
|
+
grn_obj *table_key_support,
|
300
|
+
rb_grn_boolean owner);
|
301
|
+
void rb_grn_table_key_support_unbind (RbGrnTableKeySupport *rb_grn_table_key_support);
|
302
|
+
void rb_grn_table_key_support_assign (VALUE self,
|
303
|
+
VALUE rb_context,
|
304
|
+
grn_ctx *context,
|
305
|
+
grn_obj *table_key_support,
|
306
|
+
rb_grn_boolean owner);
|
307
|
+
void rb_grn_table_key_support_deconstruct (RbGrnTableKeySupport *rb_grn_table_key_support,
|
308
|
+
grn_obj **table_key_support,
|
309
|
+
grn_ctx **context,
|
310
|
+
grn_obj **key,
|
311
|
+
grn_id *domain_id,
|
312
|
+
grn_obj **domain,
|
313
|
+
grn_obj **value,
|
314
|
+
grn_id *range_id,
|
315
|
+
grn_obj **range);
|
316
|
+
grn_id rb_grn_table_key_support_get (VALUE self,
|
317
|
+
VALUE rb_key);
|
318
|
+
|
319
|
+
VALUE rb_grn_fix_size_column_alloc (VALUE klass);
|
320
|
+
void rb_grn_fix_size_column_bind (RbGrnFixSizeColumn *rb_grn_fix_size_column,
|
321
|
+
grn_ctx *context,
|
322
|
+
grn_obj *column_key_support,
|
323
|
+
rb_grn_boolean owner);
|
324
|
+
void rb_grn_fix_size_column_unbind (RbGrnFixSizeColumn *rb_grn_fix_size_column);
|
325
|
+
void rb_grn_fix_size_column_assign (VALUE self,
|
326
|
+
VALUE rb_context,
|
327
|
+
grn_ctx *context,
|
328
|
+
grn_obj *column,
|
329
|
+
rb_grn_boolean owner);
|
330
|
+
void rb_grn_fix_size_column_deconstruct (RbGrnFixSizeColumn *rb_grn_fix_size_column,
|
331
|
+
grn_obj **column,
|
332
|
+
grn_ctx **context,
|
333
|
+
grn_id *domain_id,
|
334
|
+
grn_obj **domain,
|
335
|
+
grn_obj **value,
|
336
|
+
grn_id *range_id,
|
337
|
+
grn_obj **range);
|
338
|
+
|
339
|
+
VALUE rb_grn_index_column_alloc (VALUE klass);
|
340
|
+
void rb_grn_index_column_bind (RbGrnIndexColumn *rb_grn_index_column,
|
341
|
+
grn_ctx *context,
|
342
|
+
grn_obj *column_key_support,
|
343
|
+
rb_grn_boolean owner);
|
344
|
+
void rb_grn_index_column_unbind (RbGrnIndexColumn *rb_grn_index_column);
|
345
|
+
void rb_grn_index_column_assign (VALUE self,
|
346
|
+
VALUE rb_context,
|
347
|
+
grn_ctx *context,
|
348
|
+
grn_obj *column,
|
349
|
+
rb_grn_boolean owner);
|
350
|
+
void rb_grn_index_column_deconstruct (RbGrnIndexColumn *rb_grn_index_column,
|
351
|
+
grn_obj **column,
|
352
|
+
grn_ctx **context,
|
353
|
+
grn_id *domain_id,
|
354
|
+
grn_obj **domain,
|
355
|
+
grn_obj **value,
|
356
|
+
grn_obj **old_value,
|
357
|
+
grn_id *range_id,
|
358
|
+
grn_obj **range,
|
359
|
+
grn_obj **id_query,
|
360
|
+
grn_obj **string_query);
|
361
|
+
|
174
362
|
VALUE rb_grn_record_new (VALUE table,
|
175
|
-
grn_id id
|
363
|
+
grn_id id,
|
364
|
+
VALUE values);
|
176
365
|
|
177
366
|
|
178
367
|
#define RB_GRN_INTERN(string) (ID2SYM(rb_intern(string)))
|
@@ -203,7 +392,7 @@ VALUE rb_grn_record_new (VALUE table,
|
|
203
392
|
|
204
393
|
#define RVAL2GRNTABLECURSOR(object) (rb_grn_table_cursor_from_ruby_object(object))
|
205
394
|
#define GRNTABLECURSOR2RVAL(klass, context, cursor) \
|
206
|
-
|
395
|
+
(rb_grn_table_cursor_to_ruby_object(klass, context, cursor, RB_GRN_TRUE))
|
207
396
|
#define GRNTABLECURSOR2RCLASS(object) (rb_grn_table_cursor_to_ruby_class(object))
|
208
397
|
|
209
398
|
#define RVAL2GRNCOLUMN(object, context) \
|
@@ -220,8 +409,8 @@ VALUE rb_grn_record_new (VALUE table,
|
|
220
409
|
|
221
410
|
#define RVAL2GRNBULK(object, context, bulk) \
|
222
411
|
(rb_grn_bulk_from_ruby_object(object, context, bulk))
|
223
|
-
#define RVAL2GRNBULK_WITH_TYPE(object, context, bulk, type)
|
224
|
-
(rb_grn_bulk_from_ruby_object_with_type(object, context, bulk, type))
|
412
|
+
#define RVAL2GRNBULK_WITH_TYPE(object, context, bulk, type_id, type) \
|
413
|
+
(rb_grn_bulk_from_ruby_object_with_type(object, context, bulk, type_id, type))
|
225
414
|
#define GRNBULK2RVAL(context, bulk, related_object) \
|
226
415
|
(rb_grn_bulk_to_ruby_object(context, bulk, related_object))
|
227
416
|
|
@@ -243,8 +432,9 @@ VALUE rb_grn_record_new (VALUE table,
|
|
243
432
|
|
244
433
|
#define GRNKEY2RVAL(context, key, key_size, table, related_object) \
|
245
434
|
(rb_grn_key_to_ruby_object(context, key, key_size, table, related_object))
|
246
|
-
#define RVAL2GRNKEY(object, context, key, domain, related_object) \
|
247
|
-
(rb_grn_key_from_ruby_object(object, context, key,
|
435
|
+
#define RVAL2GRNKEY(object, context, key, domain_id, domain, related_object) \
|
436
|
+
(rb_grn_key_from_ruby_object(object, context, key, domain_id, \
|
437
|
+
domain, related_object))
|
248
438
|
|
249
439
|
|
250
440
|
grn_encoding rb_grn_encoding_from_ruby_object (VALUE object,
|
@@ -274,11 +464,20 @@ VALUE rb_grn_table_to_ruby_object (grn_ctx *context,
|
|
274
464
|
rb_grn_boolean owner);
|
275
465
|
|
276
466
|
grn_table_cursor *
|
277
|
-
rb_grn_table_cursor_from_ruby_object (VALUE object
|
467
|
+
rb_grn_table_cursor_from_ruby_object (VALUE object,
|
468
|
+
grn_ctx **context);
|
278
469
|
VALUE rb_grn_table_cursor_to_ruby_object (VALUE klass,
|
279
470
|
grn_ctx *context,
|
280
|
-
grn_table_cursor *cursor
|
471
|
+
grn_table_cursor *cursor,
|
472
|
+
rb_grn_boolean owner);
|
281
473
|
VALUE rb_grn_table_cursor_to_ruby_class (grn_table_cursor *cursor);
|
474
|
+
void rb_grn_table_cursor_deconstruct (RbGrnTableCursor *rb_grn_table_cursor,
|
475
|
+
grn_table_cursor **cursor,
|
476
|
+
grn_ctx **context,
|
477
|
+
grn_id *domain_id,
|
478
|
+
grn_obj **domain,
|
479
|
+
grn_id *range_id,
|
480
|
+
grn_obj **range);
|
282
481
|
|
283
482
|
grn_obj *rb_grn_column_from_ruby_object (VALUE object,
|
284
483
|
grn_ctx **context);
|
@@ -305,7 +504,8 @@ grn_obj *rb_grn_bulk_from_ruby_object_with_type
|
|
305
504
|
(VALUE object,
|
306
505
|
grn_ctx *context,
|
307
506
|
grn_obj *bulk,
|
308
|
-
grn_id
|
507
|
+
grn_id type_id,
|
508
|
+
grn_obj *type);
|
309
509
|
VALUE rb_grn_bulk_to_ruby_object (grn_ctx *context,
|
310
510
|
grn_obj *bulk,
|
311
511
|
VALUE related_object);
|
@@ -339,6 +539,7 @@ grn_obj *rb_grn_key_from_ruby_object (VALUE rb_key,
|
|
339
539
|
grn_ctx *context,
|
340
540
|
grn_obj *key,
|
341
541
|
grn_id domain_id,
|
542
|
+
grn_obj *domain,
|
342
543
|
VALUE related_object);
|
343
544
|
|
344
545
|
RB_GRN_END_DECLS
|
data/ext/rb-groonga.c
CHANGED
@@ -21,19 +21,8 @@
|
|
21
21
|
extern grn_ctx grn_gctx;
|
22
22
|
|
23
23
|
static void
|
24
|
-
finish_groonga (
|
24
|
+
finish_groonga (void)
|
25
25
|
{
|
26
|
-
grn_ctx *context;
|
27
|
-
|
28
|
-
context = grn_gctx.next;
|
29
|
-
while (RB_GRN_TRUE) {
|
30
|
-
grn_ctx *next_context = context->next;
|
31
|
-
|
32
|
-
grn_ctx_fin(context);
|
33
|
-
if (next_context == &grn_gctx)
|
34
|
-
break;
|
35
|
-
context = next_context;
|
36
|
-
}
|
37
26
|
grn_fin();
|
38
27
|
}
|
39
28
|
|
@@ -76,9 +65,14 @@ Init_groonga (void)
|
|
76
65
|
*/
|
77
66
|
rb_define_const(mGrn, "BINDINGS_VERSION", cGrnBindingsVersion);
|
78
67
|
|
79
|
-
rb_grn_init_utils(mGrn);
|
80
68
|
rb_grn_init_exception(mGrn);
|
69
|
+
|
70
|
+
rb_grn_rc_check(grn_init(), Qnil);
|
71
|
+
atexit(finish_groonga);
|
72
|
+
|
73
|
+
rb_grn_init_utils(mGrn);
|
81
74
|
rb_grn_init_encoding(mGrn);
|
75
|
+
rb_grn_init_encoding_support(mGrn);
|
82
76
|
rb_grn_init_context(mGrn);
|
83
77
|
rb_grn_init_object(mGrn);
|
84
78
|
rb_grn_init_database(mGrn);
|
@@ -92,7 +86,4 @@ Init_groonga (void)
|
|
92
86
|
rb_grn_init_query(mGrn);
|
93
87
|
rb_grn_init_logger(mGrn);
|
94
88
|
rb_grn_init_snippet(mGrn);
|
95
|
-
|
96
|
-
rb_grn_rc_check(grn_init(), Qnil);
|
97
|
-
rb_set_end_proc(finish_groonga, Qnil);
|
98
89
|
}
|
data/extconf.rb
CHANGED
@@ -35,7 +35,7 @@ package_name = "groonga"
|
|
35
35
|
module_name = "groonga"
|
36
36
|
ext_dir_name = "ext"
|
37
37
|
src_dir = File.join(File.expand_path(File.dirname(__FILE__)), ext_dir_name)
|
38
|
-
major, minor, micro = 0, 0,
|
38
|
+
major, minor, micro = 0, 0, 8
|
39
39
|
|
40
40
|
def install_groonga_locally(major, minor, micro)
|
41
41
|
require 'open-uri'
|
@@ -116,6 +116,8 @@ have_header("ruby/st.h") unless have_macro("HAVE_RUBY_ST_H", "ruby.h")
|
|
116
116
|
have_func("rb_errinfo", "ruby.h")
|
117
117
|
have_type("enum ruby_value_type", "ruby.h")
|
118
118
|
|
119
|
+
$INSTALLFILES << ["../lib/**/*.rb", "$(RUBYLIBDIR)", "../lib"]
|
120
|
+
|
119
121
|
create_makefile(module_name, src_dir)
|
120
122
|
|
121
123
|
makefile = File.read("Makefile")
|
data/html/favicon.ico
ADDED
Binary file
|
data/html/favicon.xcf
ADDED
Binary file
|
data/html/index.html
CHANGED
@@ -61,7 +61,7 @@
|
|
61
61
|
<li><a href="groonga/TUTORIAL_ja_rdoc.html">Ruby/groongaのチュートリアル</a></li>
|
62
62
|
</ul>
|
63
63
|
|
64
|
-
<h2 id="about-active-groonga">ActiveGroonga
|
64
|
+
<h2 id="about-active-groonga">ActiveGroonga</h2>
|
65
65
|
<p>
|
66
66
|
ActiveGroongaはRuby/groongaの機能を使ってより利用しやすい全文検索機能・データストア機能を提供するライブラリです。
|
67
67
|
ActiveRecordのようなAPIでgroongaで管理しているデータを通常のオブジェクトのように扱えます。
|
@@ -88,12 +88,6 @@
|
|
88
88
|
</p>
|
89
89
|
<pre class="command">% sudo gem install activegroonga</pre>
|
90
90
|
|
91
|
-
<h3>ActiveGroongaのインストール</h3>
|
92
|
-
<p>
|
93
|
-
ActiveGroonagaもRubyGemsでインストールできます。
|
94
|
-
</p>
|
95
|
-
<pre class="command">% sudo gem install activegroonga</pre>
|
96
|
-
|
97
91
|
<h3>ActiveGroongaのドキュメント</h3>
|
98
92
|
<p>
|
99
93
|
ActiveGroonagaのドキュメントはそれほどありません。
|