rroonga 10.0.1 → 11.0.6
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.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/Rakefile +30 -28
- data/doc/text/news.md +51 -5
- data/doc/text/tutorial.md +1 -1
- data/ext/groonga/extconf.rb +18 -3
- data/ext/groonga/rb-grn-accessor.c +2 -2
- data/ext/groonga/rb-grn-column-cache.c +3 -3
- data/ext/groonga/rb-grn-column.c +4 -4
- data/ext/groonga/rb-grn-context.c +82 -58
- data/ext/groonga/rb-grn-data-column.c +4 -4
- data/ext/groonga/rb-grn-database.c +45 -26
- data/ext/groonga/rb-grn-double-array-trie.c +2 -2
- data/ext/groonga/rb-grn-encoding-support.c +2 -2
- data/ext/groonga/rb-grn-exception.c +14 -0
- data/ext/groonga/rb-grn-expression-builder.c +3 -3
- data/ext/groonga/rb-grn-expression.c +3 -3
- data/ext/groonga/rb-grn-fix-size-column.c +2 -2
- data/ext/groonga/rb-grn-flushable.c +2 -1
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +3 -3
- data/ext/groonga/rb-grn-index-cursor.c +2 -2
- data/ext/groonga/rb-grn-inverted-index-cursor.c +3 -3
- data/ext/groonga/rb-grn-object.c +30 -9
- data/ext/groonga/rb-grn-operator.c +100 -259
- data/ext/groonga/rb-grn-patricia-trie.c +2 -2
- data/ext/groonga/rb-grn-plugin.c +34 -22
- data/ext/groonga/rb-grn-request-timer-id.c +2 -2
- data/ext/groonga/rb-grn-snippet.c +3 -3
- data/ext/groonga/rb-grn-table-cursor-key-support.c +2 -2
- data/ext/groonga/rb-grn-table-cursor.c +3 -3
- data/ext/groonga/rb-grn-table-key-support.c +6 -4
- data/ext/groonga/rb-grn-table.c +63 -45
- data/ext/groonga/rb-grn-type.c +5 -1
- data/ext/groonga/rb-grn-utils.c +17 -1
- data/ext/groonga/rb-grn-variable-size-column.c +2 -2
- data/ext/groonga/rb-grn-variable.c +2 -2
- data/ext/groonga/rb-grn.h +10 -5
- data/ext/groonga/rb-groonga.c +6 -2
- data/lib/groonga/context.rb +32 -0
- data/rroonga-build.rb +5 -4
- data/rroonga.gemspec +5 -2
- data/test/groonga-test-utils.rb +9 -0
- data/test/run-test.rb +1 -1
- data/test/test-column.rb +12 -1
- data/test/test-index-column.rb +3 -3
- data/test/test-logger.rb +2 -0
- data/test/test-ractor.rb +65 -0
- data/test/test-remote.rb +16 -0
- data/test/test-table-arrow.rb +20 -11
- metadata +84 -68
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <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
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "rb-grn.h"
|
20
20
|
|
21
|
-
#define SELF(object) ((RbGrnTableCursor *)
|
21
|
+
#define SELF(object) ((RbGrnTableCursor *)RTYPEDDATA_DATA(object))
|
22
22
|
|
23
23
|
VALUE rb_cGrnTableCursor;
|
24
24
|
|
@@ -277,7 +277,7 @@ rb_grn_table_cursor_each (VALUE self)
|
|
277
277
|
void
|
278
278
|
rb_grn_init_table_cursor (VALUE mGrn)
|
279
279
|
{
|
280
|
-
rb_cGrnTableCursor = rb_define_class_under(mGrn, "TableCursor",
|
280
|
+
rb_cGrnTableCursor = rb_define_class_under(mGrn, "TableCursor", rb_cObject);
|
281
281
|
rb_define_alloc_func(rb_cGrnTableCursor, rb_grn_object_alloc);
|
282
282
|
|
283
283
|
rb_include_module(rb_cGrnTableCursor, rb_mEnumerable);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include "rb-grn.h"
|
21
21
|
|
22
|
-
#define SELF(object) ((RbGrnTableKeySupport *)
|
22
|
+
#define SELF(object) ((RbGrnTableKeySupport *)RTYPEDDATA_DATA(object))
|
23
23
|
|
24
24
|
VALUE rb_mGrnTableKeySupport;
|
25
25
|
|
@@ -481,8 +481,10 @@ typedef struct _SetValueData
|
|
481
481
|
} SetValueData;
|
482
482
|
|
483
483
|
static VALUE
|
484
|
-
set_value (
|
484
|
+
set_value (RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
|
485
485
|
{
|
486
|
+
VALUE args = yielded_arg;
|
487
|
+
SetValueData *data = (SetValueData *)callback_arg;
|
486
488
|
VALUE rb_name, rb_value, rb_column;
|
487
489
|
RbGrnObject *rb_grn_object;
|
488
490
|
|
@@ -496,7 +498,7 @@ set_value (VALUE args, SetValueData *data)
|
|
496
498
|
rb_grn_inspect(rb_name), rb_grn_inspect(data->self));
|
497
499
|
}
|
498
500
|
|
499
|
-
rb_grn_object = RB_GRN_OBJECT(
|
501
|
+
rb_grn_object = RB_GRN_OBJECT(RTYPEDDATA_DATA(rb_column));
|
500
502
|
return rb_grn_object_set_raw(rb_grn_object,
|
501
503
|
data->id, rb_value, GRN_OBJ_SET, data->self);
|
502
504
|
}
|
data/ext/groonga/rb-grn-table.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
|
6
6
|
|
@@ -20,13 +20,6 @@
|
|
20
20
|
|
21
21
|
#include "rb-grn.h"
|
22
22
|
|
23
|
-
#define SELF(object) ((RbGrnTable *)DATA_PTR(object))
|
24
|
-
|
25
|
-
VALUE rb_cGrnTable;
|
26
|
-
|
27
|
-
static ID id_array_reference;
|
28
|
-
static ID id_array_set;
|
29
|
-
|
30
23
|
/*
|
31
24
|
* Document-class: Groonga::Table < Groonga::Object
|
32
25
|
*
|
@@ -35,6 +28,59 @@ static ID id_array_set;
|
|
35
28
|
* are extended from this class.
|
36
29
|
*/
|
37
30
|
|
31
|
+
#define SELF(object) ((RbGrnTable *)RTYPEDDATA_DATA(object))
|
32
|
+
|
33
|
+
VALUE rb_cGrnTable;
|
34
|
+
|
35
|
+
static ID id_array_reference;
|
36
|
+
static ID id_array_set;
|
37
|
+
|
38
|
+
static void
|
39
|
+
rb_grn_table_mark (void *data)
|
40
|
+
{
|
41
|
+
RbGrnObject *rb_grn_object = data;
|
42
|
+
RbGrnTable *rb_grn_table = data;
|
43
|
+
grn_ctx *context;
|
44
|
+
grn_obj *table;
|
45
|
+
|
46
|
+
if (!rb_grn_object)
|
47
|
+
return;
|
48
|
+
|
49
|
+
rb_gc_mark(rb_grn_table->columns);
|
50
|
+
|
51
|
+
context = rb_grn_object->context;
|
52
|
+
table = rb_grn_object->object;
|
53
|
+
if (!context || !table)
|
54
|
+
return;
|
55
|
+
|
56
|
+
rb_grn_context_mark_grn_id(context, table->header.domain);
|
57
|
+
rb_grn_context_mark_grn_id(context, grn_obj_get_range(context, table));
|
58
|
+
|
59
|
+
if (!grn_obj_path(context, table))
|
60
|
+
return;
|
61
|
+
|
62
|
+
if (grn_obj_name(context, table, NULL, 0) == 0)
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
|
66
|
+
static void
|
67
|
+
rb_grn_table_free (void *pointer)
|
68
|
+
{
|
69
|
+
rb_grn_object_free(pointer);
|
70
|
+
}
|
71
|
+
|
72
|
+
static rb_data_type_t data_type = {
|
73
|
+
"Groonga::Table",
|
74
|
+
{
|
75
|
+
rb_grn_table_mark,
|
76
|
+
rb_grn_table_free,
|
77
|
+
NULL,
|
78
|
+
},
|
79
|
+
&rb_grn_object_data_type,
|
80
|
+
NULL,
|
81
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
82
|
+
};
|
83
|
+
|
38
84
|
grn_obj *
|
39
85
|
rb_grn_table_from_ruby_object (VALUE object, grn_ctx **context)
|
40
86
|
{
|
@@ -101,38 +147,10 @@ rb_grn_table_deconstruct (RbGrnTable *rb_grn_table,
|
|
101
147
|
*columns = rb_grn_table->columns;
|
102
148
|
}
|
103
149
|
|
104
|
-
static void
|
105
|
-
rb_grn_table_mark (void *data)
|
106
|
-
{
|
107
|
-
RbGrnObject *rb_grn_object = data;
|
108
|
-
RbGrnTable *rb_grn_table = data;
|
109
|
-
grn_ctx *context;
|
110
|
-
grn_obj *table;
|
111
|
-
|
112
|
-
if (!rb_grn_object)
|
113
|
-
return;
|
114
|
-
|
115
|
-
rb_gc_mark(rb_grn_table->columns);
|
116
|
-
|
117
|
-
context = rb_grn_object->context;
|
118
|
-
table = rb_grn_object->object;
|
119
|
-
if (!context || !table)
|
120
|
-
return;
|
121
|
-
|
122
|
-
rb_grn_context_mark_grn_id(context, table->header.domain);
|
123
|
-
rb_grn_context_mark_grn_id(context, grn_obj_get_range(context, table));
|
124
|
-
|
125
|
-
if (!grn_obj_path(context, table))
|
126
|
-
return;
|
127
|
-
|
128
|
-
if (grn_obj_name(context, table, NULL, 0) == 0)
|
129
|
-
return;
|
130
|
-
}
|
131
|
-
|
132
150
|
static VALUE
|
133
151
|
rb_grn_table_alloc (VALUE klass)
|
134
152
|
{
|
135
|
-
return
|
153
|
+
return TypedData_Wrap_Struct(klass, &data_type, NULL);
|
136
154
|
}
|
137
155
|
|
138
156
|
static VALUE
|
@@ -342,7 +360,7 @@ rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
|
|
342
360
|
|
343
361
|
rb_column = GRNCOLUMN2RVAL(Qnil, context, column, GRN_TRUE);
|
344
362
|
rb_ary_push(columns, rb_column);
|
345
|
-
rb_grn_named_object_set_name(RB_GRN_NAMED_OBJECT(
|
363
|
+
rb_grn_named_object_set_name(RB_GRN_NAMED_OBJECT(RTYPEDDATA_DATA(rb_column)),
|
346
364
|
name, name_size);
|
347
365
|
|
348
366
|
return rb_column;
|
@@ -497,7 +515,7 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
|
|
497
515
|
rb_funcall(rb_column, rb_intern("sources="), 1, rb_sources);
|
498
516
|
|
499
517
|
rb_ary_push(columns, rb_column);
|
500
|
-
rb_grn_named_object_set_name(RB_GRN_NAMED_OBJECT(
|
518
|
+
rb_grn_named_object_set_name(RB_GRN_NAMED_OBJECT(RTYPEDDATA_DATA(rb_column)),
|
501
519
|
name, name_size);
|
502
520
|
|
503
521
|
return rb_column;
|
@@ -558,7 +576,7 @@ rb_grn_table_get_column (VALUE self, VALUE rb_name)
|
|
558
576
|
VALUE rb_column = raw_columns[i];
|
559
577
|
RbGrnNamedObject *rb_grn_named_object;
|
560
578
|
|
561
|
-
rb_grn_named_object = RB_GRN_NAMED_OBJECT(
|
579
|
+
rb_grn_named_object = RB_GRN_NAMED_OBJECT(RTYPEDDATA_DATA(rb_column));
|
562
580
|
if (name_size == rb_grn_named_object->name_size &&
|
563
581
|
memcmp(name, rb_grn_named_object->name, name_size) == 0) {
|
564
582
|
return rb_column;
|
@@ -583,9 +601,9 @@ rb_grn_table_get_column (VALUE self, VALUE rb_name)
|
|
583
601
|
owner = column->header.type == GRN_ACCESSOR;
|
584
602
|
rb_column = GRNCOLUMN2RVAL(Qnil, context, column, owner);
|
585
603
|
if (owner) {
|
586
|
-
rb_grn_context_register_floating_object(
|
604
|
+
rb_grn_context_register_floating_object(RTYPEDDATA_DATA(rb_column));
|
587
605
|
}
|
588
|
-
rb_grn_named_object_set_name(RB_GRN_NAMED_OBJECT(
|
606
|
+
rb_grn_named_object_set_name(RB_GRN_NAMED_OBJECT(RTYPEDDATA_DATA(rb_column)),
|
589
607
|
name, name_size);
|
590
608
|
|
591
609
|
return rb_column;
|
@@ -688,7 +706,7 @@ rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
|
|
688
706
|
RbGrnNamedObject *rb_grn_named_object;
|
689
707
|
name_size = grn_column_name(context, column,
|
690
708
|
name, GRN_TABLE_MAX_KEY_SIZE);
|
691
|
-
rb_grn_named_object = RB_GRN_NAMED_OBJECT(
|
709
|
+
rb_grn_named_object = RB_GRN_NAMED_OBJECT(RTYPEDDATA_DATA(rb_column));
|
692
710
|
rb_grn_named_object_set_name(rb_grn_named_object, name, name_size);
|
693
711
|
}
|
694
712
|
|
@@ -1092,7 +1110,7 @@ rb_grn_table_delete_by_expression (VALUE self)
|
|
1092
1110
|
|
1093
1111
|
rb_builder = rb_grn_record_expression_builder_new(self, Qnil);
|
1094
1112
|
rb_expression = rb_grn_record_expression_builder_build(rb_builder);
|
1095
|
-
rb_grn_object_deconstruct(RB_GRN_OBJECT(
|
1113
|
+
rb_grn_object_deconstruct(RB_GRN_OBJECT(RTYPEDDATA_DATA(rb_expression)),
|
1096
1114
|
&expression, NULL,
|
1097
1115
|
NULL, NULL, NULL, NULL);
|
1098
1116
|
|
@@ -2394,7 +2412,7 @@ rb_grn_table_select (int argc, VALUE *argv, VALUE self)
|
|
2394
2412
|
rb_funcall(builder, rb_intern("default_column="), 1, rb_default_column);
|
2395
2413
|
rb_expression = rb_grn_record_expression_builder_build(builder);
|
2396
2414
|
}
|
2397
|
-
rb_grn_object_deconstruct(RB_GRN_OBJECT(
|
2415
|
+
rb_grn_object_deconstruct(RB_GRN_OBJECT(RTYPEDDATA_DATA(rb_expression)),
|
2398
2416
|
&expression, NULL,
|
2399
2417
|
NULL, NULL, NULL, NULL);
|
2400
2418
|
|
data/ext/groonga/rb-grn-type.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2020 Sutou Kouhei <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
|
@@ -304,6 +304,10 @@ rb_grn_init_type (VALUE mGrn)
|
|
304
304
|
rb_define_const(rb_cGrnType, "INT64", INT2NUM(GRN_DB_INT64));
|
305
305
|
/* 64bit符号なし整数。 */
|
306
306
|
rb_define_const(rb_cGrnType, "UINT64", INT2NUM(GRN_DB_UINT64));
|
307
|
+
#if RB_GRN_HAVE_FLOAT32
|
308
|
+
/* 32bit floating pointer number in IEEE754 format. */
|
309
|
+
rb_define_const(rb_cGrnType, "FLOAT32", INT2NUM(GRN_DB_FLOAT32));
|
310
|
+
#endif
|
307
311
|
/* ieee754形式の64bit浮動小数点数。 */
|
308
312
|
rb_define_const(rb_cGrnType, "FLOAT", INT2NUM(GRN_DB_FLOAT));
|
309
313
|
/* 1970年1月1日0時0分0秒からの経過マイクロ秒数を64bit符
|
data/ext/groonga/rb-grn-utils.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/* vim: set sts=4 sw=4 ts=8 noet: */
|
3
3
|
/*
|
4
|
-
Copyright (C) 2009-
|
4
|
+
Copyright (C) 2009-2020 Sutou Kouhei <kou@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
7
7
|
modify it under the terms of the GNU Lesser General Public
|
@@ -201,6 +201,11 @@ rb_grn_bulk_to_ruby_object_by_range_id (grn_ctx *context, grn_obj *bulk,
|
|
201
201
|
case GRN_DB_UINT64:
|
202
202
|
*rb_value = ULL2NUM(GRN_UINT64_VALUE(bulk));
|
203
203
|
break;
|
204
|
+
#if RB_GRN_HAVE_FLOAT32
|
205
|
+
case GRN_DB_FLOAT32:
|
206
|
+
*rb_value = rb_float_new(GRN_FLOAT32_VALUE(bulk));
|
207
|
+
break;
|
208
|
+
#endif
|
204
209
|
case GRN_DB_FLOAT:
|
205
210
|
*rb_value = rb_float_new(GRN_FLOAT_VALUE(bulk));
|
206
211
|
break;
|
@@ -447,6 +452,7 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
447
452
|
int64_t int64_value;
|
448
453
|
uint64_t uint64_value;
|
449
454
|
int64_t time_value;
|
455
|
+
float float_value;
|
450
456
|
double double_value;
|
451
457
|
grn_geo_point geo_point_value;
|
452
458
|
grn_id record_id;
|
@@ -525,6 +531,16 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
525
531
|
string = (const char *)&(value.uint64_value);
|
526
532
|
size = sizeof(value.uint64_value);
|
527
533
|
break;
|
534
|
+
#if RB_GRN_HAVE_FLOAT32
|
535
|
+
case GRN_DB_FLOAT32:
|
536
|
+
if (string_p) {
|
537
|
+
object = rb_Float(object);
|
538
|
+
}
|
539
|
+
value.float_value = NUM2DBL(object);
|
540
|
+
string = (const char *)&(value.float_value);
|
541
|
+
size = sizeof(value.float_value);
|
542
|
+
break;
|
543
|
+
#endif
|
528
544
|
case GRN_DB_FLOAT:
|
529
545
|
if (string_p) {
|
530
546
|
object = rb_Float(object);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include "rb-grn.h"
|
21
21
|
|
22
|
-
#define SELF(object) ((RbGrnVariableSizeColumn *)
|
22
|
+
#define SELF(object) ((RbGrnVariableSizeColumn *)RTYPEDDATA_DATA(object))
|
23
23
|
|
24
24
|
VALUE rb_cGrnVariableSizeColumn;
|
25
25
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009 Kouhei
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <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
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "rb-grn.h"
|
20
20
|
|
21
|
-
#define SELF(object) ((RbGrnVariable *)
|
21
|
+
#define SELF(object) ((RbGrnVariable *)RTYPEDDATA_DATA(object))
|
22
22
|
|
23
23
|
VALUE rb_cGrnVariable;
|
24
24
|
|
data/ext/groonga/rb-grn.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2015-2017 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -75,7 +75,7 @@ RB_GRN_BEGIN_DECLS
|
|
75
75
|
|
76
76
|
#ifdef __WIN32__
|
77
77
|
# ifdef RB_GRN_COMPILATION
|
78
|
-
# define RB_GRN_VAR __declspec(dllexport)
|
78
|
+
# define RB_GRN_VAR extern __declspec(dllexport)
|
79
79
|
# else
|
80
80
|
# define RB_GRN_VAR extern __declspec(dllimport)
|
81
81
|
# endif
|
@@ -89,9 +89,11 @@ RB_GRN_BEGIN_DECLS
|
|
89
89
|
# define debug(...)
|
90
90
|
#endif
|
91
91
|
|
92
|
-
#define
|
92
|
+
#define RB_GRN_HAVE_FLOAT32 GRN_VERSION_OR_LATER(10, 0, 2)
|
93
|
+
|
94
|
+
#define RB_GRN_MAJOR_VERSION 11
|
93
95
|
#define RB_GRN_MINOR_VERSION 0
|
94
|
-
#define RB_GRN_MICRO_VERSION
|
96
|
+
#define RB_GRN_MICRO_VERSION 6
|
95
97
|
|
96
98
|
#define RB_GRN_OBJECT(object) ((RbGrnObject *)(object))
|
97
99
|
#define RB_GRN_NAMED_OBJECT(object) ((RbGrnNamedObject *)(object))
|
@@ -312,6 +314,8 @@ RB_GRN_VAR VALUE rb_mGrnRequestTimer;
|
|
312
314
|
RB_GRN_VAR VALUE rb_cGrnRequestTimerID;
|
313
315
|
RB_GRN_VAR VALUE rb_cGrnColumnCache;
|
314
316
|
|
317
|
+
RB_GRN_VAR rb_data_type_t rb_grn_object_data_type;
|
318
|
+
|
315
319
|
void rb_grn_init_utils (VALUE mGrn);
|
316
320
|
void rb_grn_init_exception (VALUE mGrn);
|
317
321
|
void rb_grn_init_encoding (VALUE mGrn);
|
@@ -777,7 +781,8 @@ rb_encoding *rb_grn_encoding_to_ruby_encoding (grn_encoding encoding);
|
|
777
781
|
VALUE rb_grn_encoding_to_ruby_encoding_object
|
778
782
|
(grn_encoding encoding);
|
779
783
|
|
780
|
-
|
784
|
+
RbGrnContext *rb_grn_context_get_struct (VALUE rb_context);
|
785
|
+
grn_ctx *rb_grn_context_from_ruby_object (VALUE rb_context);
|
781
786
|
VALUE rb_grn_context_to_ruby_object (grn_ctx *context);
|
782
787
|
VALUE rb_grn_context_rb_string_new (grn_ctx *context,
|
783
788
|
const char *string,
|
data/ext/groonga/rb-groonga.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -22,7 +22,7 @@
|
|
22
22
|
grn_bool rb_grn_exited = GRN_FALSE;
|
23
23
|
|
24
24
|
static VALUE
|
25
|
-
finish_groonga (
|
25
|
+
finish_groonga (RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
|
26
26
|
{
|
27
27
|
debug("finish\n");
|
28
28
|
grn_fin();
|
@@ -205,6 +205,10 @@ rb_grn_init_package_label (VALUE mGrn)
|
|
205
205
|
void
|
206
206
|
Init_groonga (void)
|
207
207
|
{
|
208
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
209
|
+
rb_ext_ractor_safe(true);
|
210
|
+
#endif
|
211
|
+
|
208
212
|
VALUE mGrn;
|
209
213
|
|
210
214
|
mGrn = rb_define_module("Groonga");
|
data/lib/groonga/context.rb
CHANGED
@@ -20,6 +20,38 @@ require "groonga/context/command-executor"
|
|
20
20
|
|
21
21
|
module Groonga
|
22
22
|
class Context
|
23
|
+
class << self
|
24
|
+
# Opens a new context. If block is given, the opened context is
|
25
|
+
# closed automatically after the given block is evaluated.
|
26
|
+
#
|
27
|
+
# @overload open(*args, &block)
|
28
|
+
# @param args [::Array<Object>] Passed through to
|
29
|
+
# {Groonga::Context#initialize}.
|
30
|
+
# @yieldparam context [Groonga::Context] The newly created context.
|
31
|
+
# @return [Object] The return value of the given block is the
|
32
|
+
# return value of the call.
|
33
|
+
#
|
34
|
+
# @overload open(*args)
|
35
|
+
# @param args [::Array<Object>] Passed through to
|
36
|
+
# {Groonga::Context#initialize}.
|
37
|
+
# @yieldparam context [Groonga::Context] The newly created context.
|
38
|
+
# @return [Groonga::Context] The newly created context.
|
39
|
+
#
|
40
|
+
# @see Groonga::Context#initialize
|
41
|
+
def open(*args, **kwargs)
|
42
|
+
context = new(*args, **kwargs)
|
43
|
+
if block_given?
|
44
|
+
begin
|
45
|
+
yield(context)
|
46
|
+
ensure
|
47
|
+
context.close
|
48
|
+
end
|
49
|
+
else
|
50
|
+
context
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
23
55
|
# _path_ にある既存のデータベースを開く。ブロックを指定した場
|
24
56
|
# 合はブロックに開いたデータベースを渡し、ブロックを抜けると
|
25
57
|
# きに閉じる。
|
data/rroonga-build.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2021 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
# Copyright (C) 2015-2017 Masafumi Yokoyama <yokoyama@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
@@ -16,11 +16,12 @@
|
|
16
16
|
|
17
17
|
module RroongaBuild
|
18
18
|
module RequiredGroongaVersion
|
19
|
-
MAJOR =
|
19
|
+
MAJOR = 11
|
20
20
|
MINOR = 0
|
21
|
-
MICRO =
|
21
|
+
MICRO = 0
|
22
22
|
VERSION = [MAJOR, MINOR, MICRO]
|
23
|
-
|
23
|
+
STRING = VERSION.join(".")
|
24
|
+
RELEASED_DATE = Time.utc(2021, 2, 9)
|
24
25
|
end
|
25
26
|
|
26
27
|
module_function
|
data/rroonga.gemspec
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
require "English"
|
20
|
+
require_relative "rroonga-build"
|
20
21
|
|
21
22
|
base_dir = File.dirname(__FILE__)
|
22
23
|
ext_dir = File.join(base_dir, "ext", "groonga")
|
@@ -82,9 +83,10 @@ Gem::Specification.new do |s|
|
|
82
83
|
|
83
84
|
s.required_ruby_version = ">= 1.9.3"
|
84
85
|
|
85
|
-
s.add_runtime_dependency("pkg-config")
|
86
86
|
s.add_runtime_dependency("groonga-client", ">= 0.0.3")
|
87
87
|
s.add_runtime_dependency("json")
|
88
|
+
s.add_runtime_dependency("native-package-installer")
|
89
|
+
s.add_runtime_dependency("pkg-config")
|
88
90
|
s.add_development_dependency("test-unit", [">= 3.0.0"])
|
89
91
|
s.add_development_dependency("rake")
|
90
92
|
s.add_development_dependency("bundler")
|
@@ -92,6 +94,7 @@ Gem::Specification.new do |s|
|
|
92
94
|
s.add_development_dependency("packnga", [">= 1.0.0"])
|
93
95
|
s.add_development_dependency("kramdown")
|
94
96
|
|
95
|
-
|
97
|
+
required_groonga_version = RroongaBuild::RequiredGroongaVersion::STRING
|
98
|
+
s.metadata["msys2_mingw_dependencies"] = "groonga>=#{required_groonga_version}"
|
96
99
|
end
|
97
100
|
|
data/test/groonga-test-utils.rb
CHANGED
@@ -140,6 +140,9 @@ module GroongaTestUtils
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def teardown_log_path
|
143
|
+
Groonga::Logger.path = nil
|
144
|
+
Groonga::QueryLogger.path = nil
|
145
|
+
|
143
146
|
return unless @dump_log
|
144
147
|
if @log_path.exist?(log_path)
|
145
148
|
header = "--- log: #{@log_path} ---"
|
@@ -209,4 +212,10 @@ module GroongaTestUtils
|
|
209
212
|
def check_mecab_availability
|
210
213
|
omit("MeCab isn't available") if context["TokenMecab"].nil?
|
211
214
|
end
|
215
|
+
|
216
|
+
def need_groonga(major, minor, micro)
|
217
|
+
if (Groonga::BUILD_VERSION[0, 3] <=> [major, minor, micro]) < 0
|
218
|
+
omit("Groonga #{major}.#{minor}.#{micro} or later is required")
|
219
|
+
end
|
220
|
+
end
|
212
221
|
end
|
data/test/run-test.rb
CHANGED
data/test/test-column.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2020 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
@@ -307,6 +307,17 @@ class ColumnTest < Test::Unit::TestCase
|
|
307
307
|
assert_false(post["hidden"])
|
308
308
|
end
|
309
309
|
|
310
|
+
def test_float32
|
311
|
+
need_groonga(10, 0, 2)
|
312
|
+
|
313
|
+
numbers = Groonga::Array.create(:name => "Numbers")
|
314
|
+
numbers.define_column("data", "Float32")
|
315
|
+
|
316
|
+
number = numbers.add
|
317
|
+
number["data"] = 1.1
|
318
|
+
assert_in_delta(1.1, number["data"])
|
319
|
+
end
|
320
|
+
|
310
321
|
def test_indexes
|
311
322
|
Groonga::Schema.define do |schema|
|
312
323
|
schema.create_table("Comments") do |table|
|
data/test/test-index-column.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
|
4
2
|
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
3
|
#
|
6
4
|
# This library is free software; you can redistribute it and/or
|
@@ -203,6 +201,8 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
203
201
|
end
|
204
202
|
|
205
203
|
def test_reindex
|
204
|
+
check_mecab_availability
|
205
|
+
|
206
206
|
Groonga::Schema.define do |schema|
|
207
207
|
schema.create_table("Memos", :type => :array) do |table|
|
208
208
|
table.short_text("title")
|
data/test/test-logger.rb
CHANGED
@@ -39,6 +39,8 @@ class LoggerTest < Test::Unit::TestCase
|
|
39
39
|
FileUtils.mv(@log_path, "#{@log_path}.old")
|
40
40
|
end
|
41
41
|
assert_false(@log_path.exist?)
|
42
|
+
# Reopen log uses debug level since Groonga 11.0.1.
|
43
|
+
Groonga::Logger.max_level = :debug
|
42
44
|
Groonga::Logger.reopen
|
43
45
|
assert_true(@log_path.exist?)
|
44
46
|
end
|
data/test/test-ractor.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (C) 2021 Sutou Kouhei <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
|
+
|
16
|
+
class RactorTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
setup
|
20
|
+
def need_ractor
|
21
|
+
omit("Ractor is needed") unless defined?(Ractor)
|
22
|
+
end
|
23
|
+
|
24
|
+
setup :setup_database
|
25
|
+
|
26
|
+
setup
|
27
|
+
def setup_tables
|
28
|
+
Groonga::Schema.define do |schema|
|
29
|
+
schema.create_table("Comments") do |table|
|
30
|
+
table.text("content")
|
31
|
+
end
|
32
|
+
|
33
|
+
schema.create_table("Terms",
|
34
|
+
type: :patricia_trie,
|
35
|
+
default_tokenizer: "TokenNgram",
|
36
|
+
normalizer: "NormalizerNFKC130") do |table|
|
37
|
+
table.index("Comments.content", with_position: true)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
setup
|
43
|
+
def setup_records
|
44
|
+
comments = Groonga["Comments"]
|
45
|
+
comments.add(content: "Hello World")
|
46
|
+
comments.add(content: "Groonga is fast!")
|
47
|
+
comments.add(content: "Rroonga is the Groonga bindings")
|
48
|
+
end
|
49
|
+
|
50
|
+
test "select" do
|
51
|
+
ractor = Ractor.new(@database_path) do |database_path|
|
52
|
+
Groonga::Context.open(encoding: nil) do |context|
|
53
|
+
context.open_database(database_path) do
|
54
|
+
comments = context["Comments"]
|
55
|
+
matched_comments = comments.select do |comment|
|
56
|
+
comment.content.match("Groonga")
|
57
|
+
end
|
58
|
+
matched_comments.collect(&:content)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
assert_equal(["Groonga is fast!", "Rroonga is the Groonga bindings"],
|
63
|
+
ractor.take)
|
64
|
+
end
|
65
|
+
end
|