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
@@ -36,10 +36,10 @@ VALUE rb_cGrnIndexColumn;
|
|
36
36
|
|
37
37
|
void
|
38
38
|
rb_grn_index_column_finalizer (grn_ctx *context, grn_obj *object,
|
39
|
-
|
39
|
+
RbGrnIndexColumn *rb_grn_index_column)
|
40
40
|
{
|
41
41
|
if (!context)
|
42
|
-
|
42
|
+
return;
|
43
43
|
|
44
44
|
grn_obj_unlink(context, rb_grn_index_column->id_query);
|
45
45
|
grn_obj_unlink(context, rb_grn_index_column->string_query);
|
@@ -50,7 +50,7 @@ rb_grn_index_column_finalizer (grn_ctx *context, grn_obj *object,
|
|
50
50
|
|
51
51
|
void
|
52
52
|
rb_grn_index_column_bind (RbGrnIndexColumn *rb_grn_index_column,
|
53
|
-
|
53
|
+
grn_ctx *context, grn_obj *column)
|
54
54
|
{
|
55
55
|
RbGrnObject *rb_grn_object;
|
56
56
|
|
@@ -58,41 +58,41 @@ rb_grn_index_column_bind (RbGrnIndexColumn *rb_grn_index_column,
|
|
58
58
|
rb_grn_object = RB_GRN_OBJECT(rb_grn_index_column);
|
59
59
|
|
60
60
|
rb_grn_index_column->old_value = grn_obj_open(context, GRN_BULK, 0,
|
61
|
-
|
61
|
+
rb_grn_object->range_id);
|
62
62
|
|
63
63
|
rb_grn_index_column->id_query = grn_obj_open(context, GRN_BULK, 0,
|
64
|
-
|
64
|
+
rb_grn_object->domain_id);
|
65
65
|
rb_grn_index_column->string_query = grn_obj_open(context, GRN_BULK,
|
66
|
-
|
67
|
-
|
66
|
+
GRN_OBJ_DO_SHALLOW_COPY,
|
67
|
+
GRN_DB_SHORT_TEXT);
|
68
68
|
}
|
69
69
|
|
70
70
|
void
|
71
71
|
rb_grn_index_column_deconstruct (RbGrnIndexColumn *rb_grn_index_column,
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
72
|
+
grn_obj **column,
|
73
|
+
grn_ctx **context,
|
74
|
+
grn_id *domain_id,
|
75
|
+
grn_obj **domain,
|
76
|
+
grn_obj **value,
|
77
|
+
grn_obj **old_value,
|
78
|
+
grn_id *range_id,
|
79
|
+
grn_obj **range,
|
80
|
+
grn_obj **id_query,
|
81
|
+
grn_obj **string_query)
|
82
82
|
{
|
83
83
|
RbGrnObject *rb_grn_object;
|
84
84
|
|
85
85
|
rb_grn_object = RB_GRN_OBJECT(rb_grn_index_column);
|
86
86
|
rb_grn_column_deconstruct(RB_GRN_COLUMN(rb_grn_object), column, context,
|
87
|
-
|
88
|
-
|
87
|
+
domain_id, domain, value,
|
88
|
+
range_id, range);
|
89
89
|
|
90
90
|
if (old_value)
|
91
|
-
|
91
|
+
*old_value = rb_grn_index_column->old_value;
|
92
92
|
if (id_query)
|
93
|
-
|
93
|
+
*id_query = rb_grn_index_column->id_query;
|
94
94
|
if (string_query)
|
95
|
-
|
95
|
+
*string_query = rb_grn_index_column->string_query;
|
96
96
|
}
|
97
97
|
|
98
98
|
/*
|
@@ -174,47 +174,47 @@ rb_grn_index_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
|
|
174
174
|
original_rb_value = rb_value;
|
175
175
|
|
176
176
|
rb_grn_index_column_deconstruct(SELF(self), &column, &context,
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
177
|
+
NULL, NULL,
|
178
|
+
&new_value, &old_value,
|
179
|
+
NULL, &range,
|
180
|
+
NULL, NULL);
|
181
181
|
|
182
182
|
id = RVAL2GRNID(rb_id, context, range, self);
|
183
183
|
|
184
184
|
if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_value, rb_cHash))) {
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
185
|
+
VALUE hash_value;
|
186
|
+
hash_value = rb_hash_new();
|
187
|
+
rb_hash_aset(hash_value, RB_GRN_INTERN("value"), rb_value);
|
188
|
+
rb_value = hash_value;
|
189
189
|
}
|
190
190
|
|
191
191
|
rb_grn_scan_options(rb_value,
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
192
|
+
"section", &rb_section,
|
193
|
+
"old_value", &rb_old_value,
|
194
|
+
"value", &rb_new_value,
|
195
|
+
NULL);
|
196
196
|
|
197
197
|
if (NIL_P(rb_section))
|
198
|
-
|
198
|
+
section = 1;
|
199
199
|
else
|
200
|
-
|
200
|
+
section = NUM2UINT(rb_section);
|
201
201
|
|
202
202
|
if (NIL_P(rb_old_value)) {
|
203
|
-
|
203
|
+
old_value = NULL;
|
204
204
|
} else {
|
205
|
-
|
206
|
-
|
205
|
+
GRN_BULK_REWIND(old_value);
|
206
|
+
RVAL2GRNBULK(rb_old_value, context, old_value);
|
207
207
|
}
|
208
208
|
|
209
209
|
if (NIL_P(rb_new_value)) {
|
210
|
-
|
210
|
+
new_value = NULL;
|
211
211
|
} else {
|
212
|
-
|
213
|
-
|
212
|
+
GRN_BULK_REWIND(new_value);
|
213
|
+
RVAL2GRNBULK(rb_new_value, context, new_value);
|
214
214
|
}
|
215
215
|
|
216
216
|
rc = grn_column_index_update(context, column,
|
217
|
-
|
217
|
+
id, section, old_value, new_value);
|
218
218
|
rb_grn_context_check(context, self);
|
219
219
|
rb_grn_rc_check(rc, self);
|
220
220
|
|
@@ -318,9 +318,9 @@ rb_grn_index_column_add (int argc, VALUE *argv, VALUE self)
|
|
318
318
|
NULL);
|
319
319
|
|
320
320
|
if (NIL_P(rb_section)) {
|
321
|
-
|
321
|
+
section = 1;
|
322
322
|
} else {
|
323
|
-
|
323
|
+
section = NUM2UINT(rb_section);
|
324
324
|
}
|
325
325
|
|
326
326
|
rc = grn_column_index_update(context, column, id, section, NULL, new_value);
|
@@ -432,9 +432,9 @@ rb_grn_index_column_delete (int argc, VALUE *argv, VALUE self)
|
|
432
432
|
NULL);
|
433
433
|
|
434
434
|
if (NIL_P(rb_section)) {
|
435
|
-
|
435
|
+
section = 1;
|
436
436
|
} else {
|
437
|
-
|
437
|
+
section = NUM2UINT(rb_section);
|
438
438
|
}
|
439
439
|
|
440
440
|
rc = grn_column_index_update(context, column, id, section, old_value, NULL);
|
@@ -551,9 +551,9 @@ rb_grn_index_column_update (int argc, VALUE *argv, VALUE self)
|
|
551
551
|
NULL);
|
552
552
|
|
553
553
|
if (NIL_P(rb_section)) {
|
554
|
-
|
554
|
+
section = 1;
|
555
555
|
} else {
|
556
|
-
|
556
|
+
section = NUM2UINT(rb_section);
|
557
557
|
}
|
558
558
|
|
559
559
|
rc = grn_column_index_update(context, column, id, section,
|
@@ -582,9 +582,9 @@ rb_grn_index_column_get_sources (VALUE self)
|
|
582
582
|
VALUE exception;
|
583
583
|
|
584
584
|
rb_grn_index_column_deconstruct(SELF(self), &column, &context,
|
585
|
-
|
586
|
-
|
587
|
-
|
585
|
+
NULL, NULL,
|
586
|
+
NULL, NULL, NULL, NULL,
|
587
|
+
NULL, NULL);
|
588
588
|
|
589
589
|
GRN_OBJ_INIT(&sources, GRN_BULK, 0, GRN_ID_NIL);
|
590
590
|
grn_obj_get_info(context, column, GRN_INFO_SOURCE, &sources);
|
@@ -594,19 +594,19 @@ rb_grn_index_column_get_sources (VALUE self)
|
|
594
594
|
source_ids = (grn_id *)GRN_BULK_HEAD(&sources);
|
595
595
|
rb_sources = rb_ary_new2(n);
|
596
596
|
for (i = 0; i < n; i++) {
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
597
|
+
grn_obj *source;
|
598
|
+
VALUE rb_source;
|
599
|
+
|
600
|
+
source = grn_ctx_at(context, *source_ids);
|
601
|
+
exception = rb_grn_context_to_exception(context, self);
|
602
|
+
if (!NIL_P(exception)) {
|
603
|
+
grn_obj_unlink(context, &sources);
|
604
|
+
rb_exc_raise(exception);
|
605
|
+
}
|
606
|
+
|
607
|
+
rb_source = GRNOBJECT2RVAL(Qnil, context, source, GRN_FALSE);
|
608
|
+
rb_ary_push(rb_sources, rb_source);
|
609
|
+
source_ids++;
|
610
610
|
}
|
611
611
|
grn_obj_unlink(context, &sources);
|
612
612
|
|
@@ -615,64 +615,64 @@ rb_grn_index_column_get_sources (VALUE self)
|
|
615
615
|
|
616
616
|
static grn_id
|
617
617
|
resolve_source_id (grn_ctx *context, grn_obj *column, grn_id range_id,
|
618
|
-
|
618
|
+
VALUE rb_source)
|
619
619
|
{
|
620
620
|
grn_id source_id;
|
621
621
|
|
622
622
|
if (CBOOL2RVAL(rb_obj_is_kind_of(rb_source, rb_cInteger))) {
|
623
|
-
|
623
|
+
source_id = NUM2UINT(rb_source);
|
624
624
|
} else {
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
625
|
+
grn_obj *source;
|
626
|
+
grn_bool need_source_unlink = GRN_FALSE;
|
627
|
+
|
628
|
+
if (TYPE(rb_source) == T_STRING) {
|
629
|
+
grn_obj *table;
|
630
|
+
const char *name;
|
631
|
+
const char *dot_point;
|
632
|
+
int length;
|
633
|
+
|
634
|
+
table = grn_ctx_at(context, grn_obj_get_range(context, column));
|
635
|
+
name = StringValueCStr(rb_source);
|
636
|
+
length = RSTRING_LEN(rb_source);
|
637
|
+
dot_point = strstr(name, ".");
|
638
|
+
if (dot_point) {
|
639
|
+
char table_name[4096];
|
640
|
+
int table_name_length;
|
641
|
+
|
642
|
+
table_name_length = grn_obj_name(context, table,
|
643
|
+
table_name, sizeof(table_name));
|
644
|
+
table_name[table_name_length] = '\0';
|
645
|
+
if (strncmp(table_name, name, dot_point - name) != 0) {
|
646
|
+
rb_raise(rb_eArgError,
|
647
|
+
"wrong table's column: <%s>: "
|
648
|
+
"expected table: <%s>",
|
649
|
+
name, table_name);
|
650
|
+
}
|
651
|
+
length -= (dot_point - name) + 1;
|
652
|
+
name = dot_point + 1;
|
653
|
+
}
|
654
|
+
source = grn_obj_column(context, table, name, length);
|
655
|
+
need_source_unlink = GRN_TRUE;
|
656
|
+
} else {
|
657
|
+
source = RVAL2GRNOBJECT(rb_source, &context);
|
658
|
+
}
|
659
|
+
rb_grn_context_check(context, rb_source);
|
660
|
+
if (source->header.type == GRN_ACCESSOR) {
|
661
|
+
char name[256];
|
662
|
+
int length;
|
663
|
+
length = grn_column_name(context, source, name, sizeof(name));
|
664
|
+
name[length] = '\0';
|
665
|
+
if (strcmp(name, "_key") != 0) {
|
666
|
+
rb_raise(rb_eArgError,
|
667
|
+
"source accessor must be '_key': <%s>", name);
|
668
|
+
}
|
669
|
+
source_id = range_id;
|
670
|
+
} else {
|
671
|
+
source_id = grn_obj_id(context, source);
|
672
|
+
}
|
673
|
+
if (need_source_unlink) {
|
674
|
+
grn_obj_unlink(context, source);
|
675
|
+
}
|
676
676
|
}
|
677
677
|
|
678
678
|
return source_id;
|
@@ -697,30 +697,30 @@ rb_grn_index_column_set_sources (VALUE self, VALUE rb_sources)
|
|
697
697
|
grn_rc rc;
|
698
698
|
|
699
699
|
rb_grn_index_column_deconstruct(SELF(self), &column, &context,
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
700
|
+
NULL, NULL,
|
701
|
+
NULL, NULL,
|
702
|
+
&range_id, NULL,
|
703
|
+
NULL, NULL);
|
704
704
|
|
705
705
|
n = RARRAY_LEN(rb_sources);
|
706
706
|
rb_source_values = RARRAY_PTR(rb_sources);
|
707
707
|
sources = ALLOCA_N(grn_id, n);
|
708
708
|
for (i = 0; i < n; i++) {
|
709
|
-
|
710
|
-
|
709
|
+
sources[i] = resolve_source_id(context, column, range_id,
|
710
|
+
rb_source_values[i]);
|
711
711
|
}
|
712
712
|
|
713
713
|
{
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
714
|
+
grn_obj bulk_sources;
|
715
|
+
GRN_OBJ_INIT(&bulk_sources, GRN_BULK, 0, GRN_ID_NIL);
|
716
|
+
GRN_TEXT_SET(context, &bulk_sources, sources, n * sizeof(grn_id));
|
717
|
+
rc = grn_obj_set_info(context, column, GRN_INFO_SOURCE, &bulk_sources);
|
718
|
+
exception = rb_grn_context_to_exception(context, self);
|
719
|
+
grn_obj_unlink(context, &bulk_sources);
|
720
720
|
}
|
721
721
|
|
722
722
|
if (!NIL_P(exception))
|
723
|
-
|
723
|
+
rb_exc_raise(exception);
|
724
724
|
rb_grn_rc_check(rc, self);
|
725
725
|
|
726
726
|
return Qnil;
|
@@ -736,7 +736,7 @@ static VALUE
|
|
736
736
|
rb_grn_index_column_set_source (VALUE self, VALUE rb_source)
|
737
737
|
{
|
738
738
|
if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_source, rb_cArray)))
|
739
|
-
|
739
|
+
rb_source = rb_ary_new3(1, rb_source);
|
740
740
|
|
741
741
|
return rb_grn_index_column_set_sources(self, rb_source);
|
742
742
|
}
|
@@ -785,37 +785,37 @@ rb_grn_index_column_search (int argc, VALUE *argv, VALUE self)
|
|
785
785
|
VALUE rb_query, options, rb_result, rb_operator;
|
786
786
|
|
787
787
|
rb_grn_index_column_deconstruct(SELF(self), &column, &context,
|
788
|
-
|
789
|
-
|
790
|
-
|
788
|
+
NULL, NULL,
|
789
|
+
NULL, NULL, NULL, &range,
|
790
|
+
&id_query, &string_query);
|
791
791
|
|
792
792
|
rb_scan_args(argc, argv, "11", &rb_query, &options);
|
793
793
|
|
794
794
|
if (CBOOL2RVAL(rb_obj_is_kind_of(rb_query, rb_cInteger))) {
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
795
|
+
grn_id id;
|
796
|
+
id = NUM2UINT(rb_query);
|
797
|
+
GRN_TEXT_SET(context, id_query, &id, sizeof(grn_id));
|
798
|
+
query = id_query;
|
799
799
|
} else {
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
800
|
+
const char *_query;
|
801
|
+
_query = StringValuePtr(rb_query);
|
802
|
+
GRN_TEXT_SET(context, string_query, _query, RSTRING_LEN(rb_query));
|
803
|
+
query = string_query;
|
804
804
|
}
|
805
805
|
|
806
806
|
rb_grn_scan_options(options,
|
807
|
-
|
808
|
-
|
809
|
-
|
807
|
+
"result", &rb_result,
|
808
|
+
"operator", &rb_operator,
|
809
|
+
NULL);
|
810
810
|
|
811
811
|
if (NIL_P(rb_result)) {
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
812
|
+
result = grn_table_create(context, NULL, 0, NULL,
|
813
|
+
GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
|
814
|
+
range, 0);
|
815
|
+
rb_grn_context_check(context, self);
|
816
|
+
rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
|
817
817
|
} else {
|
818
|
-
|
818
|
+
result = RVAL2GRNOBJECT(rb_result, &context);
|
819
819
|
}
|
820
820
|
|
821
821
|
operator = RVAL2GRNOPERATOR(rb_operator);
|
@@ -837,9 +837,9 @@ rb_grn_index_column_with_section_p (VALUE self)
|
|
837
837
|
grn_obj *column;
|
838
838
|
|
839
839
|
rb_grn_index_column_deconstruct(SELF(self), &column, NULL,
|
840
|
-
|
841
|
-
|
842
|
-
|
840
|
+
NULL, NULL,
|
841
|
+
NULL, NULL, NULL, NULL,
|
842
|
+
NULL, NULL);
|
843
843
|
|
844
844
|
return CBOOL2RVAL(column->header.flags & GRN_OBJ_WITH_SECTION);
|
845
845
|
}
|
@@ -855,9 +855,9 @@ rb_grn_index_column_with_weight_p (VALUE self)
|
|
855
855
|
grn_obj *column;
|
856
856
|
|
857
857
|
rb_grn_index_column_deconstruct(SELF(self), &column, NULL,
|
858
|
-
|
859
|
-
|
860
|
-
|
858
|
+
NULL, NULL,
|
859
|
+
NULL, NULL, NULL, NULL,
|
860
|
+
NULL, NULL);
|
861
861
|
|
862
862
|
return CBOOL2RVAL(column->header.flags & GRN_OBJ_WITH_WEIGHT);
|
863
863
|
}
|
@@ -873,9 +873,9 @@ rb_grn_index_column_with_position_p (VALUE self)
|
|
873
873
|
grn_obj *column;
|
874
874
|
|
875
875
|
rb_grn_index_column_deconstruct(SELF(self), &column, NULL,
|
876
|
-
|
877
|
-
|
878
|
-
|
876
|
+
NULL, NULL,
|
877
|
+
NULL, NULL, NULL, NULL,
|
878
|
+
NULL, NULL);
|
879
879
|
|
880
880
|
return CBOOL2RVAL(column->header.flags & GRN_OBJ_WITH_POSITION);
|
881
881
|
}
|
@@ -918,83 +918,83 @@ rb_grn_index_column_open_cursor (int argc, VALUE *argv, VALUE self)
|
|
918
918
|
VALUE rb_cursor;
|
919
919
|
|
920
920
|
rb_grn_index_column_deconstruct(SELF(self), &column, &context,
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
921
|
+
NULL, NULL,
|
922
|
+
NULL, NULL,
|
923
|
+
NULL, &range_object,
|
924
|
+
NULL, NULL);
|
925
925
|
|
926
926
|
rb_scan_args(argc, argv, "11", &rb_table_cursor, &options);
|
927
927
|
rb_grn_scan_options(options,
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
928
|
+
"with_section", &rb_with_section,
|
929
|
+
"with_weight", &rb_with_weight,
|
930
|
+
"with_position", &rb_with_position,
|
931
|
+
NULL);
|
932
932
|
|
933
933
|
table_cursor = RVAL2GRNTABLECURSOR(rb_table_cursor, NULL);
|
934
934
|
rb_table = GRNOBJECT2RVAL(Qnil, context, range_object, GRN_FALSE);
|
935
935
|
rb_lexicon = rb_iv_get(rb_table_cursor, "@table");
|
936
936
|
|
937
937
|
if (NIL_P(rb_with_section)) {
|
938
|
-
|
938
|
+
flags |= column->header.flags & GRN_OBJ_WITH_SECTION;
|
939
939
|
} else if (RVAL2CBOOL(rb_with_section)) {
|
940
|
-
|
940
|
+
flags |= GRN_OBJ_WITH_SECTION;
|
941
941
|
}
|
942
942
|
|
943
943
|
if (NIL_P(rb_with_weight)) {
|
944
|
-
|
944
|
+
flags |= column->header.flags & GRN_OBJ_WITH_WEIGHT;
|
945
945
|
} else if (RVAL2CBOOL(rb_with_weight)) {
|
946
|
-
|
946
|
+
flags |= GRN_OBJ_WITH_WEIGHT;
|
947
947
|
}
|
948
948
|
|
949
949
|
if (NIL_P(rb_with_position)) {
|
950
|
-
|
950
|
+
flags |= column->header.flags & GRN_OBJ_WITH_POSITION;
|
951
951
|
} else if (RVAL2CBOOL(rb_with_position)) {
|
952
|
-
|
952
|
+
flags |= GRN_OBJ_WITH_POSITION;
|
953
953
|
}
|
954
954
|
|
955
955
|
index_cursor = grn_index_cursor_open(context, table_cursor,
|
956
|
-
|
956
|
+
column, rid_min, rid_max, flags);
|
957
957
|
|
958
958
|
rb_cursor = GRNINDEXCURSOR2RVAL(context, index_cursor, rb_table, rb_lexicon);
|
959
959
|
|
960
960
|
if (rb_block_given_p())
|
961
|
-
|
961
|
+
return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
|
962
962
|
else
|
963
|
-
|
963
|
+
return rb_cursor;
|
964
964
|
}
|
965
965
|
|
966
966
|
void
|
967
967
|
rb_grn_init_index_column (VALUE mGrn)
|
968
968
|
{
|
969
969
|
rb_cGrnIndexColumn =
|
970
|
-
|
970
|
+
rb_define_class_under(mGrn, "IndexColumn", rb_cGrnColumn);
|
971
971
|
|
972
972
|
rb_define_method(rb_cGrnIndexColumn, "[]=",
|
973
|
-
|
973
|
+
rb_grn_index_column_array_set, 2);
|
974
974
|
|
975
975
|
rb_define_method(rb_cGrnIndexColumn, "add",
|
976
|
-
|
976
|
+
rb_grn_index_column_add, -1);
|
977
977
|
rb_define_method(rb_cGrnIndexColumn, "delete",
|
978
|
-
|
978
|
+
rb_grn_index_column_delete, -1);
|
979
979
|
rb_define_method(rb_cGrnIndexColumn, "update",
|
980
|
-
|
980
|
+
rb_grn_index_column_update, -1);
|
981
981
|
|
982
982
|
rb_define_method(rb_cGrnIndexColumn, "sources",
|
983
|
-
|
983
|
+
rb_grn_index_column_get_sources, 0);
|
984
984
|
rb_define_method(rb_cGrnIndexColumn, "sources=",
|
985
|
-
|
985
|
+
rb_grn_index_column_set_sources, 1);
|
986
986
|
rb_define_method(rb_cGrnIndexColumn, "source=",
|
987
|
-
|
987
|
+
rb_grn_index_column_set_source, 1);
|
988
988
|
|
989
989
|
rb_define_method(rb_cGrnIndexColumn, "search",
|
990
|
-
|
990
|
+
rb_grn_index_column_search, -1);
|
991
991
|
|
992
992
|
rb_define_method(rb_cGrnIndexColumn, "with_section?",
|
993
|
-
|
993
|
+
rb_grn_index_column_with_section_p, 0);
|
994
994
|
rb_define_method(rb_cGrnIndexColumn, "with_weight?",
|
995
|
-
|
995
|
+
rb_grn_index_column_with_weight_p, 0);
|
996
996
|
rb_define_method(rb_cGrnIndexColumn, "with_position?",
|
997
|
-
|
997
|
+
rb_grn_index_column_with_position_p, 0);
|
998
998
|
rb_define_method(rb_cGrnIndexColumn, "open_cursor",
|
999
|
-
|
999
|
+
rb_grn_index_column_open_cursor, -1);
|
1000
1000
|
}
|