rroonga 1.0.1 → 1.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 +46 -0
- data/NEWS.rdoc +46 -0
- data/README.ja.rdoc +2 -2
- data/README.rdoc +2 -3
- data/Rakefile +148 -11
- data/example/bookmark.rb +94 -91
- data/ext/groonga/extconf.rb +25 -25
- data/ext/groonga/groonga.def +2 -0
- data/ext/groonga/mkmf.log +7 -7
- data/ext/groonga/rb-grn-column.c +66 -0
- data/ext/groonga/rb-grn-context.c +92 -5
- data/ext/groonga/rb-grn-database.c +24 -1
- data/ext/groonga/rb-grn-exception.c +15 -0
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +8 -4
- data/ext/groonga/rb-grn-object.c +4 -2
- data/ext/groonga/rb-grn-patricia-trie.c +2 -2
- data/ext/groonga/rb-grn-snippet.c +1 -0
- data/ext/groonga/rb-grn-table-key-support.c +22 -19
- data/ext/groonga/rb-grn-table.c +63 -5
- data/ext/groonga/rb-grn.h +1 -1
- data/ext/groonga/rb-groonga.c +1 -0
- data/extconf.rb +1 -1
- data/html/developer.html +8 -2
- data/html/favicon.ico +0 -0
- data/html/favicon.svg +591 -0
- data/html/index.html +71 -8
- data/html/logo.svg +612 -0
- data/html/ranguba.css +92 -7
- data/html/readme.svg +256 -0
- data/lib/groonga/expression-builder.rb +8 -4
- data/lib/groonga/record.rb +77 -7
- data/lib/groonga/schema.rb +429 -100
- data/rroonga-build.rb +1 -1
- data/test/run-test.rb +1 -1
- data/test/test-array.rb +4 -0
- data/test/test-context.rb +8 -0
- data/test/test-database.rb +8 -1
- data/test/test-expression-builder.rb +14 -0
- data/test/test-fix-size-column.rb +4 -0
- data/test/test-hash.rb +10 -4
- data/test/test-index-column.rb +11 -0
- data/test/test-patricia-trie.rb +7 -1
- data/test/test-record.rb +14 -0
- data/test/test-remote.rb +3 -2
- data/test/test-schema-create-table.rb +32 -2
- data/test/test-schema.rb +108 -11
- data/test/test-table-select-normalize.rb +7 -3
- data/test/test-table-select.rb +12 -0
- data/test/test-table.rb +7 -0
- data/test/test-variable-size-column.rb +4 -0
- data/test-unit/Rakefile +40 -0
- data/test-unit/TODO +5 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/html/classic.html +15 -0
- data/test-unit/html/index.html +25 -0
- data/test-unit/html/index.html.ja +27 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
- data/test-unit/lib/test/unit/assertions.rb +1230 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +360 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +144 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/collector.rb +36 -0
- data/test-unit/lib/test/unit/color-scheme.rb +102 -0
- data/test-unit/lib/test/unit/color.rb +96 -0
- data/test-unit/lib/test/unit/diff.rb +724 -0
- data/test-unit/lib/test/unit/error.rb +130 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +136 -0
- data/test-unit/lib/test/unit/fixture.rb +176 -0
- data/test-unit/lib/test/unit/notification.rb +129 -0
- data/test-unit/lib/test/unit/omission.rb +191 -0
- data/test-unit/lib/test/unit/pending.rb +150 -0
- data/test-unit/lib/test/unit/priority.rb +180 -0
- data/test-unit/lib/test/unit/runner/console.rb +52 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/runner/tap.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +476 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/lib/test/unit.rb +323 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/test_adder.rb +20 -0
- data/test-unit/sample/test_subtracter.rb +20 -0
- data/test-unit/sample/test_user.rb +23 -0
- data/test-unit/test/collector/test-descendant.rb +133 -0
- data/test-unit/test/collector/test-load.rb +442 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_objectspace.rb +100 -0
- data/test-unit/test/run-test.rb +15 -0
- data/test-unit/test/test-attribute.rb +86 -0
- data/test-unit/test/test-color-scheme.rb +67 -0
- data/test-unit/test/test-color.rb +47 -0
- data/test-unit/test/test-diff.rb +518 -0
- data/test-unit/test/test-emacs-runner.rb +60 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/test-notification.rb +33 -0
- data/test-unit/test/test-omission.rb +81 -0
- data/test-unit/test/test-pending.rb +70 -0
- data/test-unit/test/test-priority.rb +119 -0
- data/test-unit/test/test-testcase.rb +544 -0
- data/test-unit/test/test_assertions.rb +1151 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit-test-util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/text/{TUTORIAL.ja.rdoc → tutorial.ja.rdoc} +165 -126
- metadata +106 -16
- data/html/favicon.xcf +0 -0
- data/html/logo.xcf +0 -0
- data/license/GPL +0 -340
- data/license/RUBY +0 -59
- data/pkg-config.rb +0 -333
data/ext/groonga/mkmf.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
checking for GCC... -------------------- yes
|
|
2
2
|
|
|
3
|
-
"
|
|
3
|
+
"cc -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/rroonga.18/ext/groonga -fno-strict-aliasing -g -g -O2 -fPIC -c conftest.c"
|
|
4
4
|
checked program was:
|
|
5
5
|
/* begin */
|
|
6
6
|
1: /*top*/
|
|
@@ -18,7 +18,7 @@ checking for Win32 OS... -------------------- no
|
|
|
18
18
|
|
|
19
19
|
have_macro: checking for HAVE_RUBY_ST_H in ruby.h... -------------------- no
|
|
20
20
|
|
|
21
|
-
"
|
|
21
|
+
"cc -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/rroonga.18/ext/groonga -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/tmp/local/include/groonga -c conftest.c"
|
|
22
22
|
conftest.c:4:3: error: #error
|
|
23
23
|
conftest.c:5: error: expected identifier or ‘(’ before ‘>>’ token
|
|
24
24
|
checked program was:
|
|
@@ -35,7 +35,7 @@ checked program was:
|
|
|
35
35
|
|
|
36
36
|
have_header: checking for ruby/st.h... -------------------- no
|
|
37
37
|
|
|
38
|
-
"
|
|
38
|
+
"cc -E -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/rroonga.18/ext/groonga -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/tmp/local/include/groonga conftest.c -o conftest.i"
|
|
39
39
|
conftest.c:1:21: error: ruby/st.h: そのようなファイルやディレクトリはありません
|
|
40
40
|
checked program was:
|
|
41
41
|
/* begin */
|
|
@@ -46,7 +46,7 @@ checked program was:
|
|
|
46
46
|
|
|
47
47
|
have_func: checking for rb_errinfo() in ruby.h... -------------------- no
|
|
48
48
|
|
|
49
|
-
"
|
|
49
|
+
"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/rroonga.18/ext/groonga -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/tmp/local/include/groonga conftest.c -L. -L/usr/lib -L. -rdynamic -Wl,-export-dynamic -L/tmp/local/lib -lgroonga -lruby1.8-static -lgroonga -lpthread -lrt -ldl -lcrypt -lm -lc"
|
|
50
50
|
conftest.c: In function ‘t’:
|
|
51
51
|
conftest.c:5: error: ‘rb_errinfo’ undeclared (first use in this function)
|
|
52
52
|
conftest.c:5: error: (Each undeclared identifier is reported only once
|
|
@@ -60,10 +60,10 @@ checked program was:
|
|
|
60
60
|
5: int t() { void ((*volatile p)()); p = (void ((*)()))rb_errinfo; return 0; }
|
|
61
61
|
/* end */
|
|
62
62
|
|
|
63
|
-
"
|
|
63
|
+
"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/rroonga.18/ext/groonga -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/tmp/local/include/groonga conftest.c -L. -L/usr/lib -L. -rdynamic -Wl,-export-dynamic -L/tmp/local/lib -lgroonga -lruby1.8-static -lgroonga -lpthread -lrt -ldl -lcrypt -lm -lc"
|
|
64
64
|
conftest.c: In function ‘t’:
|
|
65
65
|
conftest.c:5: warning: implicit declaration of function ‘rb_errinfo’
|
|
66
|
-
/tmp/
|
|
66
|
+
/tmp/ccRn7Jyd.o: In function `t':
|
|
67
67
|
/home/kou/work/ruby/rroonga.18/ext/groonga/conftest.c:5: undefined reference to `rb_errinfo'
|
|
68
68
|
collect2: ld returned 1 exit status
|
|
69
69
|
checked program was:
|
|
@@ -79,7 +79,7 @@ checked program was:
|
|
|
79
79
|
|
|
80
80
|
have_type: checking for enum ruby_value_type in ruby.h... -------------------- no
|
|
81
81
|
|
|
82
|
-
"
|
|
82
|
+
"cc -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/rroonga.18/ext/groonga -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/tmp/local/include/groonga -c conftest.c"
|
|
83
83
|
conftest.c:5: error: invalid application of ‘sizeof’ to incomplete type ‘conftest_type’
|
|
84
84
|
conftest.c:5: error: size of array ‘conftestval’ is negative
|
|
85
85
|
checked program was:
|
data/ext/groonga/rb-grn-column.c
CHANGED
|
@@ -552,6 +552,68 @@ rb_grn_column_is_locked (int argc, VALUE *argv, VALUE self)
|
|
|
552
552
|
return CBOOL2RVAL(grn_obj_is_locked(context, column));
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
+
/*
|
|
556
|
+
* Document-method: reference_column?
|
|
557
|
+
*
|
|
558
|
+
* call-seq:
|
|
559
|
+
* column.reference_column? -> true/false
|
|
560
|
+
*
|
|
561
|
+
* _column_の値がテーブルのレコードとなる場合は+true+を返し、
|
|
562
|
+
* そうでない場合は+false+を返す。
|
|
563
|
+
*/
|
|
564
|
+
static VALUE
|
|
565
|
+
rb_grn_column_reference_column_p (VALUE self)
|
|
566
|
+
{
|
|
567
|
+
grn_ctx *context;
|
|
568
|
+
grn_obj *column;
|
|
569
|
+
grn_id range_id;
|
|
570
|
+
grn_obj *range;
|
|
571
|
+
unsigned short int type;
|
|
572
|
+
|
|
573
|
+
rb_grn_column_deconstruct(SELF(self), &column, &context,
|
|
574
|
+
NULL, NULL,
|
|
575
|
+
NULL, NULL, NULL);
|
|
576
|
+
|
|
577
|
+
range_id = grn_obj_get_range(context, column);
|
|
578
|
+
range = grn_ctx_at(context, range_id);
|
|
579
|
+
type = range->header.type;
|
|
580
|
+
grn_obj_unlink(context, range);
|
|
581
|
+
switch (type) {
|
|
582
|
+
case GRN_TABLE_HASH_KEY:
|
|
583
|
+
case GRN_TABLE_PAT_KEY:
|
|
584
|
+
case GRN_TABLE_NO_KEY:
|
|
585
|
+
return Qtrue;
|
|
586
|
+
default:
|
|
587
|
+
return Qfalse;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/*
|
|
592
|
+
* Document-method: index_column?
|
|
593
|
+
*
|
|
594
|
+
* call-seq:
|
|
595
|
+
* column.index_column? -> true/false
|
|
596
|
+
*
|
|
597
|
+
* _column_がGroonga::IndexColumnの場合は+true+を返し、
|
|
598
|
+
* そうでない場合は+false+を返す。
|
|
599
|
+
*/
|
|
600
|
+
static VALUE
|
|
601
|
+
rb_grn_column_index_column_p (VALUE self)
|
|
602
|
+
{
|
|
603
|
+
grn_ctx *context;
|
|
604
|
+
grn_obj *column;
|
|
605
|
+
|
|
606
|
+
rb_grn_column_deconstruct(SELF(self), &column, &context,
|
|
607
|
+
NULL, NULL,
|
|
608
|
+
NULL, NULL, NULL);
|
|
609
|
+
|
|
610
|
+
if (column->header.type == GRN_COLUMN_INDEX) {
|
|
611
|
+
return Qtrue;
|
|
612
|
+
} else {
|
|
613
|
+
return Qfalse;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
555
617
|
void
|
|
556
618
|
rb_grn_init_column (VALUE mGrn)
|
|
557
619
|
{
|
|
@@ -566,6 +628,10 @@ rb_grn_init_column (VALUE mGrn)
|
|
|
566
628
|
rb_define_method(rb_cGrnColumn, "unlock", rb_grn_column_unlock, -1);
|
|
567
629
|
rb_define_method(rb_cGrnColumn, "clear_lock", rb_grn_column_clear_lock, -1);
|
|
568
630
|
rb_define_method(rb_cGrnColumn, "locked?", rb_grn_column_is_locked, -1);
|
|
631
|
+
rb_define_method(rb_cGrnColumn, "reference_column?",
|
|
632
|
+
rb_grn_column_reference_column_p, 0);
|
|
633
|
+
rb_define_method(rb_cGrnColumn, "index_column?",
|
|
634
|
+
rb_grn_column_index_column_p, 0);
|
|
569
635
|
|
|
570
636
|
rb_grn_init_fix_size_column(mGrn);
|
|
571
637
|
rb_grn_init_variable_size_column(mGrn);
|
|
@@ -56,19 +56,27 @@ rb_grn_context_from_ruby_object (VALUE object)
|
|
|
56
56
|
return rb_grn_context->context;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
void
|
|
60
|
-
|
|
59
|
+
static void
|
|
60
|
+
rb_grn_context_unlink_database (grn_ctx *context)
|
|
61
61
|
{
|
|
62
62
|
grn_obj *database;
|
|
63
63
|
|
|
64
|
-
if (context->stat == GRN_CTX_FIN)
|
|
65
|
-
return;
|
|
66
|
-
|
|
67
64
|
database = grn_ctx_db(context);
|
|
68
65
|
debug("context:database: %p:%p\n", context, database);
|
|
69
66
|
if (database && database->header.type == GRN_DB) {
|
|
67
|
+
debug("context:database: %p:%p: unlink\n", context, database);
|
|
70
68
|
grn_obj_unlink(context, database);
|
|
71
69
|
}
|
|
70
|
+
debug("context:database: %p:%p: done\n", context, database);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void
|
|
74
|
+
rb_grn_context_fin (grn_ctx *context)
|
|
75
|
+
{
|
|
76
|
+
if (context->stat == GRN_CTX_FIN)
|
|
77
|
+
return;
|
|
78
|
+
|
|
79
|
+
rb_grn_context_unlink_database(context);
|
|
72
80
|
grn_ctx_fin(context);
|
|
73
81
|
}
|
|
74
82
|
|
|
@@ -92,6 +100,33 @@ rb_grn_context_alloc (VALUE klass)
|
|
|
92
100
|
return Data_Wrap_Struct(klass, NULL, rb_grn_context_free, NULL);
|
|
93
101
|
}
|
|
94
102
|
|
|
103
|
+
static grn_obj *
|
|
104
|
+
rb_grn_context_finalizer (grn_ctx *context, int n_args, grn_obj **grn_objects,
|
|
105
|
+
grn_user_data *user_data)
|
|
106
|
+
{
|
|
107
|
+
RbGrnContext *rb_grn_context;
|
|
108
|
+
|
|
109
|
+
if (rb_grn_exited)
|
|
110
|
+
return NULL;
|
|
111
|
+
|
|
112
|
+
rb_grn_context = user_data->ptr;
|
|
113
|
+
|
|
114
|
+
GRN_CTX_USER_DATA(context)->ptr = NULL;
|
|
115
|
+
grn_ctx_set_finalizer(context, NULL);
|
|
116
|
+
|
|
117
|
+
debug("context-finalize: %p:%p:%p\n",
|
|
118
|
+
context, rb_grn_context, rb_grn_context->context);
|
|
119
|
+
|
|
120
|
+
rb_grn_context->context = NULL;
|
|
121
|
+
|
|
122
|
+
rb_grn_context_unlink_database(context);
|
|
123
|
+
|
|
124
|
+
debug("context-finalize: %p:%p:%p: done\n",
|
|
125
|
+
context, rb_grn_context, rb_grn_context->context);
|
|
126
|
+
|
|
127
|
+
return NULL;
|
|
128
|
+
}
|
|
129
|
+
|
|
95
130
|
VALUE
|
|
96
131
|
rb_grn_context_to_exception (grn_ctx *context, VALUE related_object)
|
|
97
132
|
{
|
|
@@ -301,6 +336,7 @@ rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
|
|
|
301
336
|
rb_grn_context_check(context, self);
|
|
302
337
|
|
|
303
338
|
GRN_CTX_USER_DATA(context)->ptr = rb_grn_context;
|
|
339
|
+
grn_ctx_set_finalizer(context, rb_grn_context_finalizer);
|
|
304
340
|
|
|
305
341
|
if (!NIL_P(rb_encoding)) {
|
|
306
342
|
grn_encoding encoding;
|
|
@@ -380,6 +416,52 @@ rb_grn_context_set_encoding (VALUE self, VALUE rb_encoding)
|
|
|
380
416
|
return rb_encoding;
|
|
381
417
|
}
|
|
382
418
|
|
|
419
|
+
/*
|
|
420
|
+
* call-seq:
|
|
421
|
+
* context.support_zlib?
|
|
422
|
+
*
|
|
423
|
+
* groongaがZlibサポート付きでビルドされていれば+true+、そう
|
|
424
|
+
* でなければ+false+を返す。
|
|
425
|
+
*/
|
|
426
|
+
static VALUE
|
|
427
|
+
rb_grn_context_support_zlib_p (VALUE self)
|
|
428
|
+
{
|
|
429
|
+
VALUE rb_support_p;
|
|
430
|
+
grn_ctx *context;
|
|
431
|
+
grn_obj support_p;
|
|
432
|
+
|
|
433
|
+
context = SELF(self);
|
|
434
|
+
GRN_BOOL_INIT(&support_p, 0);
|
|
435
|
+
grn_obj_get_info(context, NULL, GRN_INFO_SUPPORT_ZLIB, &support_p);
|
|
436
|
+
rb_support_p = CBOOL2RVAL(GRN_BOOL_VALUE(&support_p));
|
|
437
|
+
GRN_OBJ_FIN(context, &support_p);
|
|
438
|
+
|
|
439
|
+
return rb_support_p;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/*
|
|
443
|
+
* call-seq:
|
|
444
|
+
* context.support_lzo?
|
|
445
|
+
*
|
|
446
|
+
* groongaがLZOサポート付きでビルドされていれば+true+、そう
|
|
447
|
+
* でなければ+false+を返す。
|
|
448
|
+
*/
|
|
449
|
+
static VALUE
|
|
450
|
+
rb_grn_context_support_lzo_p (VALUE self)
|
|
451
|
+
{
|
|
452
|
+
VALUE rb_support_p;
|
|
453
|
+
grn_ctx *context;
|
|
454
|
+
grn_obj support_p;
|
|
455
|
+
|
|
456
|
+
context = SELF(self);
|
|
457
|
+
GRN_BOOL_INIT(&support_p, 0);
|
|
458
|
+
grn_obj_get_info(context, NULL, GRN_INFO_SUPPORT_LZO, &support_p);
|
|
459
|
+
rb_support_p = CBOOL2RVAL(GRN_BOOL_VALUE(&support_p));
|
|
460
|
+
GRN_OBJ_FIN(context, &support_p);
|
|
461
|
+
|
|
462
|
+
return rb_support_p;
|
|
463
|
+
}
|
|
464
|
+
|
|
383
465
|
/*
|
|
384
466
|
* call-seq:
|
|
385
467
|
* context.database -> Groonga::Database
|
|
@@ -639,6 +721,11 @@ rb_grn_init_context (VALUE mGrn)
|
|
|
639
721
|
rb_define_method(cGrnContext, "encoding", rb_grn_context_get_encoding, 0);
|
|
640
722
|
rb_define_method(cGrnContext, "encoding=", rb_grn_context_set_encoding, 1);
|
|
641
723
|
|
|
724
|
+
rb_define_method(cGrnContext, "support_zlib?",
|
|
725
|
+
rb_grn_context_support_zlib_p, 0);
|
|
726
|
+
rb_define_method(cGrnContext, "support_lzo?",
|
|
727
|
+
rb_grn_context_support_lzo_p, 0);
|
|
728
|
+
|
|
642
729
|
rb_define_method(cGrnContext, "database", rb_grn_context_get_database, 0);
|
|
643
730
|
|
|
644
731
|
rb_define_method(cGrnContext, "[]", rb_grn_context_array_reference, 1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* -*- c-file-style: "ruby" -*- */
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
|
3
|
+
Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
|
|
4
4
|
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
|
@@ -441,6 +441,27 @@ rb_grn_database_is_locked (VALUE self)
|
|
|
441
441
|
return CBOOL2RVAL(grn_obj_is_locked(context, database));
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
/*
|
|
445
|
+
* Document-method: touch
|
|
446
|
+
*
|
|
447
|
+
* call-seq:
|
|
448
|
+
* database.touch
|
|
449
|
+
*
|
|
450
|
+
* _database_の最終更新時刻を現在時刻にする。
|
|
451
|
+
*/
|
|
452
|
+
static VALUE
|
|
453
|
+
rb_grn_database_touch (VALUE self)
|
|
454
|
+
{
|
|
455
|
+
grn_ctx *context;
|
|
456
|
+
grn_obj *database;
|
|
457
|
+
|
|
458
|
+
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
|
459
|
+
NULL, NULL, NULL, NULL);
|
|
460
|
+
|
|
461
|
+
grn_db_touch(context, database);
|
|
462
|
+
return Qnil;
|
|
463
|
+
}
|
|
464
|
+
|
|
444
465
|
void
|
|
445
466
|
rb_grn_init_database (VALUE mGrn)
|
|
446
467
|
{
|
|
@@ -469,4 +490,6 @@ rb_grn_init_database (VALUE mGrn)
|
|
|
469
490
|
rb_define_method(rb_cGrnDatabase, "clear_lock",
|
|
470
491
|
rb_grn_database_clear_lock, 0);
|
|
471
492
|
rb_define_method(rb_cGrnDatabase, "locked?", rb_grn_database_is_locked, 0);
|
|
493
|
+
|
|
494
|
+
rb_define_method(rb_cGrnDatabase, "touch", rb_grn_database_touch, 0);
|
|
472
495
|
}
|
|
@@ -93,6 +93,7 @@ static VALUE eGrnTooSmallOffset;
|
|
|
93
93
|
static VALUE eGrnTooLargeOffset;
|
|
94
94
|
static VALUE eGrnTooSmallLimit;
|
|
95
95
|
static VALUE eGrnCASError;
|
|
96
|
+
static VALUE eGrnUnsupportedCommandVersion;
|
|
96
97
|
|
|
97
98
|
VALUE
|
|
98
99
|
rb_grn_rc_to_exception (grn_rc rc)
|
|
@@ -316,6 +317,9 @@ rb_grn_rc_to_exception (grn_rc rc)
|
|
|
316
317
|
case GRN_CAS_ERROR:
|
|
317
318
|
exception = eGrnCASError;
|
|
318
319
|
break;
|
|
320
|
+
case GRN_UNSUPPORTED_COMMAND_VERSION:
|
|
321
|
+
exception = eGrnUnsupportedCommandVersion;
|
|
322
|
+
break;
|
|
319
323
|
}
|
|
320
324
|
|
|
321
325
|
if (NIL_P(exception))
|
|
@@ -546,6 +550,9 @@ rb_grn_rc_to_message (grn_rc rc)
|
|
|
546
550
|
case GRN_CAS_ERROR:
|
|
547
551
|
message = "CAS error";
|
|
548
552
|
break;
|
|
553
|
+
case GRN_UNSUPPORTED_COMMAND_VERSION:
|
|
554
|
+
message = "unsupported command version";
|
|
555
|
+
break;
|
|
549
556
|
}
|
|
550
557
|
|
|
551
558
|
if (!message)
|
|
@@ -1166,4 +1173,12 @@ rb_grn_init_exception (VALUE mGrn)
|
|
|
1166
1173
|
* CAS(Compare and Swap)が失敗したときに発生する。
|
|
1167
1174
|
*/
|
|
1168
1175
|
eGrnCASError = rb_define_class_under(mGrn, "CASError", rb_eGrnError);
|
|
1176
|
+
|
|
1177
|
+
/*
|
|
1178
|
+
* Document-class: Groonga::UnsupportedCommandVersion
|
|
1179
|
+
*
|
|
1180
|
+
* 未サポートのコマンドバージョンを指定したときに発生する。
|
|
1181
|
+
*/
|
|
1182
|
+
eGrnUnsupportedCommandVersion =
|
|
1183
|
+
rb_define_class_under(mGrn, "UnsupportedCommandVersion", rb_eGrnError);
|
|
1169
1184
|
}
|
data/ext/groonga/rb-grn-hash.c
CHANGED
|
@@ -81,7 +81,7 @@ VALUE rb_cGrnHash;
|
|
|
81
81
|
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
|
82
82
|
* IDを取得する。
|
|
83
83
|
*
|
|
84
|
-
*
|
|
84
|
+
* 省略した場合はShortText型をキーとして使用する。この場合、
|
|
85
85
|
* 4096バイトまで使用可能である。
|
|
86
86
|
*
|
|
87
87
|
* [+:value_type+]
|
|
@@ -192,7 +192,7 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
|
|
|
192
192
|
flags |= GRN_OBJ_KEY_NORMALIZE;
|
|
193
193
|
|
|
194
194
|
if (NIL_P(rb_key_type)) {
|
|
195
|
-
|
|
195
|
+
key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
|
|
196
196
|
} else {
|
|
197
197
|
key_type = RVAL2GRNOBJECT(rb_key_type, &context);
|
|
198
198
|
}
|
|
@@ -267,7 +267,8 @@ rb_grn_index_column_get_sources (VALUE self)
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
static grn_id
|
|
270
|
-
resolve_source_id (grn_ctx *context, grn_obj *column,
|
|
270
|
+
resolve_source_id (grn_ctx *context, grn_obj *column, grn_id range_id,
|
|
271
|
+
VALUE rb_source)
|
|
271
272
|
{
|
|
272
273
|
grn_id source_id;
|
|
273
274
|
|
|
@@ -316,7 +317,7 @@ resolve_source_id (grn_ctx *context, grn_obj *column, VALUE rb_source)
|
|
|
316
317
|
rb_raise(rb_eArgError,
|
|
317
318
|
"source accessor must be '_key': <%s>", name);
|
|
318
319
|
}
|
|
319
|
-
source_id =
|
|
320
|
+
source_id = range_id;
|
|
320
321
|
} else {
|
|
321
322
|
source_id = grn_obj_id(context, source);
|
|
322
323
|
}
|
|
@@ -339,19 +340,22 @@ rb_grn_index_column_set_sources (VALUE self, VALUE rb_sources)
|
|
|
339
340
|
grn_obj *column;
|
|
340
341
|
int i, n;
|
|
341
342
|
VALUE *rb_source_values;
|
|
343
|
+
grn_id range_id;
|
|
342
344
|
grn_id *sources;
|
|
343
345
|
grn_rc rc;
|
|
344
346
|
|
|
345
347
|
rb_grn_index_column_deconstruct(SELF(self), &column, &context,
|
|
346
348
|
NULL, NULL,
|
|
347
|
-
NULL, NULL,
|
|
349
|
+
NULL, NULL,
|
|
350
|
+
&range_id, NULL,
|
|
348
351
|
NULL, NULL);
|
|
349
352
|
|
|
350
353
|
n = RARRAY_LEN(rb_sources);
|
|
351
354
|
rb_source_values = RARRAY_PTR(rb_sources);
|
|
352
355
|
sources = ALLOCA_N(grn_id, n);
|
|
353
356
|
for (i = 0; i < n; i++) {
|
|
354
|
-
sources[i] = resolve_source_id(context, column,
|
|
357
|
+
sources[i] = resolve_source_id(context, column, range_id,
|
|
358
|
+
rb_source_values[i]);
|
|
355
359
|
}
|
|
356
360
|
|
|
357
361
|
{
|
data/ext/groonga/rb-grn-object.c
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/*
|
|
20
20
|
* Document-class: Groonga::Object
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* rroongaが提供するクラスのベースとなるクラス。
|
|
23
23
|
* Groonga::ContextとGroonga::Logger以外はGroonga::Objectを継
|
|
24
24
|
* 承している。
|
|
25
25
|
*/
|
|
@@ -829,7 +829,9 @@ rb_grn_object_inspect_content (VALUE self, VALUE inspected)
|
|
|
829
829
|
object = rb_grn_object->object;
|
|
830
830
|
|
|
831
831
|
rb_str_cat2(inspected, " ");
|
|
832
|
-
if (
|
|
832
|
+
if (rb_grn_exited) {
|
|
833
|
+
rb_str_cat2(inspected, "(finished)");
|
|
834
|
+
} else if (object) {
|
|
833
835
|
rb_grn_object_inspect_object_content(inspected, context, object);
|
|
834
836
|
} else {
|
|
835
837
|
rb_str_cat2(inspected, "(closed)");
|
|
@@ -90,7 +90,7 @@ VALUE rb_cGrnPatriciaTrie;
|
|
|
90
90
|
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
|
91
91
|
* IDを取得する。
|
|
92
92
|
*
|
|
93
|
-
*
|
|
93
|
+
* 省略した場合はShortText型をキーとして使用する。この場合、
|
|
94
94
|
* 4096バイトまで使用可能である。
|
|
95
95
|
*
|
|
96
96
|
* [+:value_type+]
|
|
@@ -206,7 +206,7 @@ rb_grn_patricia_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
|
|
206
206
|
flags |= GRN_OBJ_KEY_WITH_SIS;
|
|
207
207
|
|
|
208
208
|
if (NIL_P(rb_key_type)) {
|
|
209
|
-
|
|
209
|
+
key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
|
|
210
210
|
} else {
|
|
211
211
|
key_type = RVAL2GRNOBJECT(rb_key_type, &context);
|
|
212
212
|
}
|
|
@@ -302,6 +302,7 @@ rb_grn_snippet_execute (VALUE self, VALUE rb_string)
|
|
|
302
302
|
|
|
303
303
|
rc = grn_snip_exec(context, snippet, string, string_length,
|
|
304
304
|
&n_results, &max_tagged_length);
|
|
305
|
+
rb_grn_context_check(context, self);
|
|
305
306
|
rb_grn_rc_check(rc, self);
|
|
306
307
|
|
|
307
308
|
rb_results = rb_ary_new2(n_results);
|
|
@@ -457,23 +457,6 @@ rb_grn_table_key_support_get_column_value (int argc, VALUE *argv, VALUE self)
|
|
|
457
457
|
return rb_grn_table_get_column_value_raw(self, id, rb_name);
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
/*
|
|
461
|
-
* call-seq:
|
|
462
|
-
* table.find(key) -> Groonga::Record
|
|
463
|
-
*
|
|
464
|
-
* テーブルの_key_に対応するレコードを返す。
|
|
465
|
-
*
|
|
466
|
-
* 0.9.0から非推奨。代わりにtable[key]を使うこと。
|
|
467
|
-
*/
|
|
468
|
-
static VALUE
|
|
469
|
-
rb_grn_table_key_support_find (VALUE self, VALUE rb_key)
|
|
470
|
-
{
|
|
471
|
-
rb_warn("#find is deprecated. Use #[] instead: %s",
|
|
472
|
-
rb_grn_inspect(self));
|
|
473
|
-
|
|
474
|
-
return rb_grn_table_key_support_array_reference(self, rb_key);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
460
|
static VALUE
|
|
478
461
|
rb_grn_table_key_support_get_value_by_key (VALUE self, VALUE rb_key)
|
|
479
462
|
{
|
|
@@ -691,6 +674,25 @@ rb_grn_table_key_support_normalize_key_p (VALUE self)
|
|
|
691
674
|
return CBOOL2RVAL(table->header.flags & GRN_OBJ_KEY_NORMALIZE);
|
|
692
675
|
}
|
|
693
676
|
|
|
677
|
+
/*
|
|
678
|
+
* call-seq:
|
|
679
|
+
* table.support_key? -> true/false
|
|
680
|
+
*
|
|
681
|
+
* テーブルでキーを使えるなら+true+、使えないなら+false+を返
|
|
682
|
+
* す。キーを使えないテーブルはGroonga::Arrayだけ。
|
|
683
|
+
*/
|
|
684
|
+
static VALUE
|
|
685
|
+
rb_grn_table_key_support_support_key_p (VALUE self)
|
|
686
|
+
{
|
|
687
|
+
grn_obj *table;
|
|
688
|
+
|
|
689
|
+
rb_grn_table_key_support_deconstruct(SELF(self), &table, NULL,
|
|
690
|
+
NULL, NULL, NULL,
|
|
691
|
+
NULL, NULL, NULL,
|
|
692
|
+
NULL);
|
|
693
|
+
return table->header.domain == GRN_ID_NIL ? Qfalse : Qtrue;
|
|
694
|
+
}
|
|
695
|
+
|
|
694
696
|
void
|
|
695
697
|
rb_grn_init_table_key_support (VALUE mGrn)
|
|
696
698
|
{
|
|
@@ -709,8 +711,6 @@ rb_grn_init_table_key_support (VALUE mGrn)
|
|
|
709
711
|
rb_define_method(rb_mGrnTableKeySupport, "delete",
|
|
710
712
|
rb_grn_table_key_support_delete, 1);
|
|
711
713
|
|
|
712
|
-
rb_define_method(rb_mGrnTableKeySupport, "find",
|
|
713
|
-
rb_grn_table_key_support_find, 1);
|
|
714
714
|
rb_define_method(rb_mGrnTableKeySupport, "[]",
|
|
715
715
|
rb_grn_table_key_support_array_reference, 1);
|
|
716
716
|
rb_define_method(rb_mGrnTableKeySupport, "[]=",
|
|
@@ -733,4 +733,7 @@ rb_grn_init_table_key_support (VALUE mGrn)
|
|
|
733
733
|
|
|
734
734
|
rb_define_method(rb_mGrnTableKeySupport, "normalize_key?",
|
|
735
735
|
rb_grn_table_key_support_normalize_key_p, 0);
|
|
736
|
+
|
|
737
|
+
rb_define_method(rb_mGrnTableKeySupport, "support_key?",
|
|
738
|
+
rb_grn_table_key_support_support_key_p, 0);
|
|
736
739
|
}
|
data/ext/groonga/rb-grn-table.c
CHANGED
|
@@ -75,6 +75,7 @@ rb_grn_table_bind (RbGrnTable *rb_grn_table,
|
|
|
75
75
|
rb_grn_object = RB_GRN_OBJECT(rb_grn_table);
|
|
76
76
|
rb_grn_table->value = grn_obj_open(context, GRN_BULK, 0,
|
|
77
77
|
rb_grn_object->range_id);
|
|
78
|
+
rb_grn_table->columns = Qnil;
|
|
78
79
|
rb_grn_table->columns = rb_ary_new();
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -202,7 +203,7 @@ rb_grn_table_inspect_content (VALUE self, VALUE inspected)
|
|
|
202
203
|
|
|
203
204
|
/*
|
|
204
205
|
* call-seq:
|
|
205
|
-
*
|
|
206
|
+
* table.inspect -> String
|
|
206
207
|
*
|
|
207
208
|
* テーブルの中身を人に見やすい文字列で返す。
|
|
208
209
|
*/
|
|
@@ -428,8 +429,14 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
|
|
|
428
429
|
flags |= GRN_OBJ_PERSISTENT;
|
|
429
430
|
}
|
|
430
431
|
|
|
431
|
-
if (
|
|
432
|
+
if (NIL_P(rb_with_section)) {
|
|
433
|
+
if (TYPE(rb_sources) == T_ARRAY && RARRAY_LEN(rb_sources) > 1) {
|
|
434
|
+
flags |= GRN_OBJ_WITH_SECTION;
|
|
435
|
+
}
|
|
436
|
+
} else if (RVAL2CBOOL(rb_with_section)) {
|
|
432
437
|
flags |= GRN_OBJ_WITH_SECTION;
|
|
438
|
+
}
|
|
439
|
+
|
|
433
440
|
|
|
434
441
|
if (RVAL2CBOOL(rb_with_weight))
|
|
435
442
|
flags |= GRN_OBJ_WITH_WEIGHT;
|
|
@@ -734,6 +741,11 @@ rb_grn_table_open_grn_cursor (int argc, VALUE *argv, VALUE self,
|
|
|
734
741
|
rb_grn_inspect(rb_order));
|
|
735
742
|
}
|
|
736
743
|
if (NIL_P(rb_order_by)) {
|
|
744
|
+
if (table->header.type == GRN_TABLE_PAT_KEY) {
|
|
745
|
+
flags |= GRN_CURSOR_BY_KEY;
|
|
746
|
+
} else {
|
|
747
|
+
flags |= GRN_CURSOR_BY_ID;
|
|
748
|
+
}
|
|
737
749
|
} else if (rb_grn_equal_option(rb_order_by, "id")) {
|
|
738
750
|
flags |= GRN_CURSOR_BY_ID;
|
|
739
751
|
} else if (rb_grn_equal_option(rb_order_by, "key")) {
|
|
@@ -798,10 +810,12 @@ rb_grn_table_open_grn_cursor (int argc, VALUE *argv, VALUE self,
|
|
|
798
810
|
* 取り出す。
|
|
799
811
|
*
|
|
800
812
|
* [+:order_by+]
|
|
801
|
-
* +:id+を指定するとID
|
|
813
|
+
* +:id+を指定するとID順にレコードを取り出す。(Arrayと
|
|
814
|
+
* Hashのデフォルト)
|
|
802
815
|
*
|
|
803
816
|
* +:key+指定するとキー順にレコードを取り出す。ただし、
|
|
804
|
-
* Groonga::PatriciaTrie
|
|
817
|
+
* Groonga::PatriciaTrieにしか使えない。(PatriciaTrieのデ
|
|
818
|
+
* フォルト)
|
|
805
819
|
*
|
|
806
820
|
* [+:greater_than+]
|
|
807
821
|
* +true+を指定すると+:min+で指定した値に一致した[+key+]を
|
|
@@ -1234,7 +1248,11 @@ rb_grn_table_group (int argc, VALUE *argv, VALUE self)
|
|
|
1234
1248
|
VALUE
|
|
1235
1249
|
rb_grn_table_array_reference (VALUE self, VALUE rb_id)
|
|
1236
1250
|
{
|
|
1237
|
-
|
|
1251
|
+
if (FIXNUM_P(rb_id)) {
|
|
1252
|
+
return rb_grn_record_new_raw(self, rb_id, Qnil);
|
|
1253
|
+
} else {
|
|
1254
|
+
return Qnil;
|
|
1255
|
+
}
|
|
1238
1256
|
}
|
|
1239
1257
|
|
|
1240
1258
|
VALUE
|
|
@@ -1935,6 +1953,19 @@ rb_grn_table_merge_bang (VALUE self, VALUE rb_other)
|
|
|
1935
1953
|
return rb_grn_table_set_operation_bang(self, rb_other, GRN_OP_ADJUST);
|
|
1936
1954
|
}
|
|
1937
1955
|
|
|
1956
|
+
/*
|
|
1957
|
+
* call-seq:
|
|
1958
|
+
* table.support_key? -> true/false
|
|
1959
|
+
*
|
|
1960
|
+
* _table_に主キーが設定されていれば+true+、されていなければ
|
|
1961
|
+
* +false+を返す。
|
|
1962
|
+
*/
|
|
1963
|
+
static VALUE
|
|
1964
|
+
rb_grn_table_support_key_p (VALUE self)
|
|
1965
|
+
{
|
|
1966
|
+
return Qfalse;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1938
1969
|
/*
|
|
1939
1970
|
* call-seq:
|
|
1940
1971
|
* table.support_sub_records? -> true/false
|
|
@@ -1955,6 +1986,29 @@ rb_grn_table_support_sub_records_p (VALUE self)
|
|
|
1955
1986
|
return CBOOL2RVAL(table->header.flags & GRN_OBJ_WITH_SUBREC);
|
|
1956
1987
|
}
|
|
1957
1988
|
|
|
1989
|
+
/*
|
|
1990
|
+
* call-seq:
|
|
1991
|
+
* table.exist?(id) -> true/false
|
|
1992
|
+
*
|
|
1993
|
+
* _table_に_id_で指定したIDのレコードが存在する場合は+true+、
|
|
1994
|
+
* 存在しない場合は+false+を返す。
|
|
1995
|
+
*
|
|
1996
|
+
* 注意: 実行には相応のコストがかかるのであまり頻繁に呼ばな
|
|
1997
|
+
* いようにして下さい。
|
|
1998
|
+
*/
|
|
1999
|
+
static VALUE
|
|
2000
|
+
rb_grn_table_exist_p (VALUE self, VALUE id)
|
|
2001
|
+
{
|
|
2002
|
+
grn_ctx *context;
|
|
2003
|
+
grn_obj *table;
|
|
2004
|
+
|
|
2005
|
+
rb_grn_table_deconstruct(SELF(self), &table, &context,
|
|
2006
|
+
NULL, NULL,
|
|
2007
|
+
NULL, NULL, NULL,
|
|
2008
|
+
NULL);
|
|
2009
|
+
return CBOOL2RVAL(grn_table_at(context, table, NUM2UINT(id)));
|
|
2010
|
+
}
|
|
2011
|
+
|
|
1958
2012
|
void
|
|
1959
2013
|
rb_grn_init_table (VALUE mGrn)
|
|
1960
2014
|
{
|
|
@@ -2022,9 +2076,13 @@ rb_grn_init_table (VALUE mGrn)
|
|
|
2022
2076
|
rb_define_method(rb_cGrnTable, "merge!",
|
|
2023
2077
|
rb_grn_table_merge_bang, 1);
|
|
2024
2078
|
|
|
2079
|
+
rb_define_method(rb_cGrnTable, "support_key?",
|
|
2080
|
+
rb_grn_table_support_key_p, 0);
|
|
2025
2081
|
rb_define_method(rb_cGrnTable, "support_sub_records?",
|
|
2026
2082
|
rb_grn_table_support_sub_records_p, 0);
|
|
2027
2083
|
|
|
2084
|
+
rb_define_method(rb_cGrnTable, "exist?", rb_grn_table_exist_p, 1);
|
|
2085
|
+
|
|
2028
2086
|
rb_grn_init_table_key_support(mGrn);
|
|
2029
2087
|
rb_grn_init_array(mGrn);
|
|
2030
2088
|
rb_grn_init_hash(mGrn);
|
data/ext/groonga/rb-grn.h
CHANGED