rroonga 9.0.3 → 11.0.0
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 +26 -135
- data/doc/text/news.md +79 -1
- data/doc/text/tutorial.md +1 -1
- data/ext/groonga/extconf.rb +19 -74
- 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 +109 -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 +9 -1
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +30 -2
- data/ext/groonga/rb-grn-index-cursor.c +21 -2
- data/ext/groonga/rb-grn-inverted-index-cursor.c +3 -3
- data/ext/groonga/rb-grn-logger.c +17 -3
- data/ext/groonga/rb-grn-object.c +266 -31
- 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 +28 -9
- data/ext/groonga/rb-grn-table.c +180 -130
- 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 +11 -14
- data/ext/groonga/rb-groonga.c +6 -2
- data/lib/groonga.rb +3 -7
- data/lib/groonga/context.rb +32 -0
- data/lib/groonga/dumper.rb +3 -0
- data/lib/groonga/record.rb +2 -2
- data/rroonga-build.rb +5 -4
- data/rroonga.gemspec +8 -6
- data/test/groonga-test-utils.rb +37 -5
- data/test/run-test.rb +1 -3
- data/test/test-accessor.rb +63 -7
- data/test/test-column.rb +12 -1
- data/test/test-context.rb +25 -0
- data/test/test-exception.rb +5 -0
- data/test/test-flushable.rb +51 -6
- data/test/test-index-column.rb +70 -9
- data/test/test-index-cursor.rb +26 -0
- data/test/test-logger.rb +56 -11
- data/test/test-plugin.rb +1 -0
- data/test/test-query-logger.rb +4 -3
- data/test/test-ractor.rb +65 -0
- data/test/test-record.rb +2 -1
- data/test/test-remote.rb +58 -10
- data/test/test-schema-dumper.rb +13 -0
- data/test/test-schema.rb +9 -1
- data/test/test-table-arrow.rb +22 -10
- data/test/test-table.rb +21 -1
- data/test/test-variable.rb +23 -7
- metadata +72 -97
@@ -1,7 +1,7 @@
|
|
1
1
|
/* -*- coding: utf-8; 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-2021 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
|
@@ -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_cGrnPatriciaTrie;
|
25
25
|
|
data/ext/groonga/rb-grn-plugin.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) 2011-
|
3
|
+
Copyright (C) 2011-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
|
@@ -17,34 +17,19 @@
|
|
17
17
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
*/
|
19
19
|
|
20
|
-
#include "rb-grn.h"
|
21
|
-
|
22
|
-
#define SELF(object) (RVAL2GRNCONTEXT(object))
|
23
|
-
|
24
|
-
static VALUE cGrnPlugin;
|
25
|
-
|
26
20
|
/*
|
27
21
|
* Document-class: Groonga::Plugin
|
28
22
|
*
|
29
|
-
* プラグイン。現在のところ、Rubyで
|
23
|
+
* プラグイン。現在のところ、RubyでGroongaのプラグインを作成
|
30
24
|
* することはできず、Cで作成された既存のプラグインを登録する
|
31
25
|
* ことができるだけです。
|
32
26
|
*/
|
33
27
|
|
34
|
-
|
35
|
-
rb_grn_plugin_from_ruby_object (VALUE object)
|
36
|
-
{
|
37
|
-
RbGrnPlugin *rb_grn_plugin;
|
28
|
+
#include "rb-grn.h"
|
38
29
|
|
39
|
-
|
40
|
-
rb_raise(rb_eTypeError, "not a groonga plugin");
|
41
|
-
}
|
30
|
+
#define SELF(object) (RVAL2GRNCONTEXT(object))
|
42
31
|
|
43
|
-
|
44
|
-
if (!rb_grn_plugin)
|
45
|
-
rb_raise(rb_eGrnError, "groonga plugin is NULL");
|
46
|
-
return rb_grn_plugin->id;
|
47
|
-
}
|
32
|
+
static VALUE cGrnPlugin;
|
48
33
|
|
49
34
|
void
|
50
35
|
rb_grn_plugin_fin (grn_id id)
|
@@ -59,10 +44,37 @@ rb_grn_plugin_free (void *pointer)
|
|
59
44
|
xfree(rb_grn_plugin);
|
60
45
|
}
|
61
46
|
|
47
|
+
static rb_data_type_t data_type = {
|
48
|
+
"Groonga::Plugin",
|
49
|
+
{
|
50
|
+
NULL,
|
51
|
+
rb_grn_plugin_free,
|
52
|
+
NULL,
|
53
|
+
},
|
54
|
+
NULL,
|
55
|
+
NULL,
|
56
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
57
|
+
};
|
58
|
+
|
59
|
+
grn_id
|
60
|
+
rb_grn_plugin_from_ruby_object (VALUE object)
|
61
|
+
{
|
62
|
+
RbGrnPlugin *rb_grn_plugin;
|
63
|
+
|
64
|
+
if (!RVAL2CBOOL(rb_obj_is_kind_of(object, cGrnPlugin))) {
|
65
|
+
rb_raise(rb_eTypeError, "not a groonga plugin");
|
66
|
+
}
|
67
|
+
|
68
|
+
TypedData_Get_Struct(object, RbGrnPlugin, &data_type, rb_grn_plugin);
|
69
|
+
if (!rb_grn_plugin)
|
70
|
+
rb_raise(rb_eGrnError, "groonga plugin is NULL");
|
71
|
+
return rb_grn_plugin->id;
|
72
|
+
}
|
73
|
+
|
62
74
|
static VALUE
|
63
75
|
rb_grn_plugin_alloc (VALUE klass)
|
64
76
|
{
|
65
|
-
return
|
77
|
+
return TypedData_Wrap_Struct(klass, &data_type, NULL);
|
66
78
|
}
|
67
79
|
|
68
80
|
/*
|
@@ -245,7 +257,7 @@ rb_grn_plugin_s_names (int argc, VALUE *argv, VALUE klass)
|
|
245
257
|
void
|
246
258
|
rb_grn_init_plugin (VALUE mGrn)
|
247
259
|
{
|
248
|
-
cGrnPlugin = rb_define_class_under(mGrn, "Plugin",
|
260
|
+
cGrnPlugin = rb_define_class_under(mGrn, "Plugin", rb_cObject);
|
249
261
|
rb_define_alloc_func(cGrnPlugin, rb_grn_plugin_alloc);
|
250
262
|
|
251
263
|
rb_define_singleton_method(cGrnPlugin, "register",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2016 Kouhei
|
3
|
+
Copyright (C) 2016-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
|
@@ -60,5 +60,5 @@ void
|
|
60
60
|
rb_grn_init_request_timer_id (VALUE mGrn)
|
61
61
|
{
|
62
62
|
rb_cGrnRequestTimerID =
|
63
|
-
rb_define_class_under(mGrn, "RequestTimerID",
|
63
|
+
rb_define_class_under(mGrn, "RequestTimerID", rb_cObject);
|
64
64
|
}
|
@@ -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) ((RbGrnSnippet *)
|
21
|
+
#define SELF(object) ((RbGrnSnippet *)RTYPEDDATA_DATA(object))
|
22
22
|
|
23
23
|
VALUE rb_cGrnSnippet;
|
24
24
|
|
@@ -149,7 +149,7 @@ rb_grn_snippet_initialize (int argc, VALUE *argv, VALUE self)
|
|
149
149
|
rb_grn_context_check(context, rb_ary_new_from_values(argc, argv));
|
150
150
|
|
151
151
|
rb_grn_object_assign(Qnil, self, rb_context, context, snippet);
|
152
|
-
rb_grn_context_register_floating_object(
|
152
|
+
rb_grn_context_register_floating_object(RTYPEDDATA_DATA(self));
|
153
153
|
|
154
154
|
rb_iv_set(self, "@context", rb_context);
|
155
155
|
|
@@ -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) ((RbGrnTableCursor *)
|
21
|
+
#define SELF(object) ((RbGrnTableCursor *)RTYPEDDATA_DATA(object))
|
22
22
|
|
23
23
|
VALUE rb_mGrnTableCursorKeySupport;
|
24
24
|
|
@@ -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
|
}
|
@@ -911,7 +913,9 @@ rb_grn_table_key_support_get_normalizer (VALUE self)
|
|
911
913
|
* # Specifies normalizer object.
|
912
914
|
* table.normalizer = Groonga::Context["NormalizerNFKC51"]
|
913
915
|
* # Uses auto normalizer that is a normalizer for backward compatibility.
|
914
|
-
* table.normalizer = "
|
916
|
+
* table.normalizer = "NormalizerAuto"
|
917
|
+
* # Uses a normalizer with options.
|
918
|
+
* table.normalizer = "NormalizerNFKC121('unify_kana', true)"
|
915
919
|
*
|
916
920
|
* @overload normalizer=(name)
|
917
921
|
* @param [String] name Set a nomalizer named @name@.
|
@@ -927,7 +931,6 @@ rb_grn_table_key_support_set_normalizer (VALUE self, VALUE rb_normalizer)
|
|
927
931
|
{
|
928
932
|
grn_ctx *context;
|
929
933
|
grn_obj *table;
|
930
|
-
grn_obj *normalizer;
|
931
934
|
grn_rc rc;
|
932
935
|
|
933
936
|
rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
|
@@ -935,9 +938,25 @@ rb_grn_table_key_support_set_normalizer (VALUE self, VALUE rb_normalizer)
|
|
935
938
|
NULL, NULL, NULL,
|
936
939
|
NULL);
|
937
940
|
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
+
if (RB_TYPE_P(rb_normalizer, RUBY_T_STRING)) {
|
942
|
+
grn_obj normalizer;
|
943
|
+
VALUE exception;
|
944
|
+
GRN_TEXT_INIT(&normalizer, GRN_OBJ_DO_SHALLOW_COPY);
|
945
|
+
GRN_TEXT_SET(context,
|
946
|
+
&normalizer,
|
947
|
+
RSTRING_PTR(rb_normalizer),
|
948
|
+
RSTRING_LEN(rb_normalizer));
|
949
|
+
rc = grn_obj_set_info(context, table, GRN_INFO_NORMALIZER, &normalizer);
|
950
|
+
exception = rb_grn_context_to_exception(context, self);
|
951
|
+
GRN_OBJ_FIN(context, &normalizer);
|
952
|
+
if (!NIL_P(exception)) {
|
953
|
+
rb_exc_raise(exception);
|
954
|
+
}
|
955
|
+
} else {
|
956
|
+
grn_obj *normalizer = RVAL2GRNOBJECT(rb_normalizer, &context);
|
957
|
+
rc = grn_obj_set_info(context, table, GRN_INFO_NORMALIZER, normalizer);
|
958
|
+
rb_grn_context_check(context, self);
|
959
|
+
}
|
941
960
|
rb_grn_rc_check(rc, self);
|
942
961
|
|
943
962
|
return Qnil;
|
data/ext/groonga/rb-grn-table.c
CHANGED
@@ -1,7 +1,8 @@
|
|
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
|
+
Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
|
5
6
|
|
6
7
|
This library is free software; you can redistribute it and/or
|
7
8
|
modify it under the terms of the GNU Lesser General Public
|
@@ -19,20 +20,66 @@
|
|
19
20
|
|
20
21
|
#include "rb-grn.h"
|
21
22
|
|
22
|
-
|
23
|
+
/*
|
24
|
+
* Document-class: Groonga::Table < Groonga::Object
|
25
|
+
*
|
26
|
+
* This class is base class which represents Rroonga's table.
|
27
|
+
* {Groonga::Array} , {Groonga::Hash} , {Groonga::PatriciaTrie}
|
28
|
+
* are extended from this class.
|
29
|
+
*/
|
30
|
+
|
31
|
+
#define SELF(object) ((RbGrnTable *)RTYPEDDATA_DATA(object))
|
23
32
|
|
24
33
|
VALUE rb_cGrnTable;
|
25
34
|
|
26
35
|
static ID id_array_reference;
|
27
36
|
static ID id_array_set;
|
28
37
|
|
29
|
-
|
30
|
-
*
|
31
|
-
|
32
|
-
*
|
33
|
-
*
|
34
|
-
*
|
35
|
-
|
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
|
+
};
|
36
83
|
|
37
84
|
grn_obj *
|
38
85
|
rb_grn_table_from_ruby_object (VALUE object, grn_ctx **context)
|
@@ -100,38 +147,10 @@ rb_grn_table_deconstruct (RbGrnTable *rb_grn_table,
|
|
100
147
|
*columns = rb_grn_table->columns;
|
101
148
|
}
|
102
149
|
|
103
|
-
static void
|
104
|
-
rb_grn_table_mark (void *data)
|
105
|
-
{
|
106
|
-
RbGrnObject *rb_grn_object = data;
|
107
|
-
RbGrnTable *rb_grn_table = data;
|
108
|
-
grn_ctx *context;
|
109
|
-
grn_obj *table;
|
110
|
-
|
111
|
-
if (!rb_grn_object)
|
112
|
-
return;
|
113
|
-
|
114
|
-
rb_gc_mark(rb_grn_table->columns);
|
115
|
-
|
116
|
-
context = rb_grn_object->context;
|
117
|
-
table = rb_grn_object->object;
|
118
|
-
if (!context || !table)
|
119
|
-
return;
|
120
|
-
|
121
|
-
rb_grn_context_mark_grn_id(context, table->header.domain);
|
122
|
-
rb_grn_context_mark_grn_id(context, grn_obj_get_range(context, table));
|
123
|
-
|
124
|
-
if (!grn_obj_path(context, table))
|
125
|
-
return;
|
126
|
-
|
127
|
-
if (grn_obj_name(context, table, NULL, 0) == 0)
|
128
|
-
return;
|
129
|
-
}
|
130
|
-
|
131
150
|
static VALUE
|
132
151
|
rb_grn_table_alloc (VALUE klass)
|
133
152
|
{
|
134
|
-
return
|
153
|
+
return TypedData_Wrap_Struct(klass, &data_type, NULL);
|
135
154
|
}
|
136
155
|
|
137
156
|
static VALUE
|
@@ -183,7 +202,8 @@ rb_grn_table_inspect_content (VALUE self, VALUE inspected)
|
|
183
202
|
}
|
184
203
|
|
185
204
|
/*
|
186
|
-
*
|
205
|
+
* This function return contents of a table as a string.
|
206
|
+
* It's easy to understand for human.
|
187
207
|
*
|
188
208
|
* @overload inspect
|
189
209
|
* @return [String]
|
@@ -203,31 +223,33 @@ rb_grn_table_inspect (VALUE self)
|
|
203
223
|
}
|
204
224
|
|
205
225
|
/*
|
206
|
-
*
|
207
|
-
*
|
226
|
+
* Defines a column that name is `name` and type is `value_type`. It
|
227
|
+
* returns the newly defined column.
|
208
228
|
*
|
209
229
|
* @overload define_column(name, value_type, options={})
|
210
230
|
* @param options [::Hash] The name and value
|
211
231
|
* pairs. Omitted names are initialized as the default value.
|
212
|
-
* @option options :path
|
213
|
-
*
|
214
|
-
*
|
215
|
-
*
|
216
|
-
*
|
217
|
-
*
|
232
|
+
* @option options :path [String, nil] (nil)
|
233
|
+
* The path to store the content of the column.
|
234
|
+
* If this is omitted, path is generated automatically.
|
235
|
+
* @option options :persistent [Boolean] (true)
|
236
|
+
* Whether the column is a persistent column or not.
|
237
|
+
* If this is `true` and `:path` is omitted, path is generated
|
238
|
+
* automatically.
|
218
239
|
* @option options :type (:scalar)
|
219
|
-
*
|
220
|
-
* +:scalar+
|
240
|
+
* This option specifies how to store a value of a column.
|
241
|
+
* If this option is omitted, +:scalar+ is used.
|
221
242
|
*
|
222
|
-
* - +:scalar+ :=
|
223
|
-
* - +:vector+ :=
|
243
|
+
* - +:scalar+ := Store scalar value.
|
244
|
+
* - +:vector+ := Store array value.
|
224
245
|
* @option options [Boolean] :with_weight (false)
|
225
246
|
* It specifies whether making the column weight vector column or not.
|
226
247
|
* Weight vector column can store weight for each element.
|
227
248
|
*
|
228
249
|
* You can't use this option for scalar column.
|
229
250
|
* @option options :compress
|
230
|
-
*
|
251
|
+
* This option specifies how to compress values.
|
252
|
+
* If we omit this option, values are not compressed.
|
231
253
|
*
|
232
254
|
* * `:zlib`: Compressed by zlib.
|
233
255
|
* * `:lz4`: Compressed by LZ4.
|
@@ -338,39 +360,44 @@ rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
|
|
338
360
|
|
339
361
|
rb_column = GRNCOLUMN2RVAL(Qnil, context, column, GRN_TRUE);
|
340
362
|
rb_ary_push(columns, rb_column);
|
341
|
-
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)),
|
342
364
|
name, name_size);
|
343
365
|
|
344
366
|
return rb_column;
|
345
367
|
}
|
346
368
|
|
347
369
|
/*
|
348
|
-
*
|
349
|
-
*
|
370
|
+
* Defines an index column that name is `name` and type is
|
371
|
+
* `value_type`. It returns the newly defined index column.
|
350
372
|
*
|
351
373
|
* @overload define_index_column(name, value_type, options={})
|
352
374
|
* @param options [::Hash] The name and value
|
353
375
|
* pairs. Omitted names are initialized as the default value.
|
354
|
-
* @option options :path
|
355
|
-
*
|
356
|
-
*
|
357
|
-
*
|
358
|
-
*
|
359
|
-
*
|
360
|
-
*
|
361
|
-
*
|
362
|
-
*
|
363
|
-
*
|
364
|
-
*
|
365
|
-
*
|
366
|
-
*
|
367
|
-
*
|
368
|
-
*
|
369
|
-
*
|
370
|
-
*
|
371
|
-
*
|
372
|
-
*
|
373
|
-
*
|
376
|
+
* @option options :path [String, nil] (nil)
|
377
|
+
* The path to store the content of the index column.
|
378
|
+
* If this is omitted, path is generated automatically.
|
379
|
+
* @option options :persistent [Boolean] (true)
|
380
|
+
* Whether the index column is a persistent indent column or not.
|
381
|
+
* If this is `true` and `:path` is omitted, path is generated
|
382
|
+
* automatically.
|
383
|
+
* @option options :with_section [Boolean] (false)
|
384
|
+
* Whether section information is stored to the index column or not.
|
385
|
+
* @option options :with_weight [Boolean] (false)
|
386
|
+
* Whether weight information is stored to the index column or not.
|
387
|
+
* @option options :with_position [Boolean] (false)
|
388
|
+
* Whether position information is stored to the index column or not.
|
389
|
+
* @option options :size [Symbol, nil] (nil)
|
390
|
+
* The size of index column. It must be `nil`, `:small`,
|
391
|
+
* `:medium` or `:large`. `nil` means the default size.
|
392
|
+
* `:small` means small size. `:medium` means medium size. Medium size
|
393
|
+
* is smaller than the default size. `:large` means large size.
|
394
|
+
* Large size is larger than the default size.
|
395
|
+
* @option options :source [Groonga::Column, nil] (nil)
|
396
|
+
* Specifies the source column of the index column.
|
397
|
+
* This option can't be used with `:sources`.
|
398
|
+
* @option options :sources [::Array<Groonga::Column>, nil] (nil)
|
399
|
+
* Specifies the source columns of the index column.
|
400
|
+
* This option can't be used with `:source`.
|
374
401
|
*
|
375
402
|
* @return [Groonga::IndexColumn]
|
376
403
|
*/
|
@@ -461,9 +488,11 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
|
|
461
488
|
flags |= GRN_OBJ_INDEX_SMALL;
|
462
489
|
} else if (rb_grn_equal_option(rb_size, "medium")) {
|
463
490
|
flags |= GRN_OBJ_INDEX_MEDIUM;
|
491
|
+
} else if (rb_grn_equal_option(rb_size, "large")) {
|
492
|
+
flags |= GRN_OBJ_INDEX_LARGE;
|
464
493
|
} else {
|
465
494
|
rb_raise(rb_eArgError,
|
466
|
-
":size must be nil, :small or :
|
495
|
+
":size must be nil, :small, :medium or :large: <%" PRIsVALUE ">",
|
467
496
|
rb_size);
|
468
497
|
}
|
469
498
|
|
@@ -486,7 +515,7 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
|
|
486
515
|
rb_funcall(rb_column, rb_intern("sources="), 1, rb_sources);
|
487
516
|
|
488
517
|
rb_ary_push(columns, rb_column);
|
489
|
-
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)),
|
490
519
|
name, name_size);
|
491
520
|
|
492
521
|
return rb_column;
|
@@ -514,8 +543,8 @@ ruby_object_to_column_name (VALUE rb_name,
|
|
514
543
|
}
|
515
544
|
|
516
545
|
/*
|
517
|
-
*
|
518
|
-
*
|
546
|
+
* It returns the column has the specified name.
|
547
|
+
* If the specified column does not exist, it returns `nil`.
|
519
548
|
*
|
520
549
|
* @overload column(name)
|
521
550
|
* @return [Groonga::Column, nil]
|
@@ -547,7 +576,7 @@ rb_grn_table_get_column (VALUE self, VALUE rb_name)
|
|
547
576
|
VALUE rb_column = raw_columns[i];
|
548
577
|
RbGrnNamedObject *rb_grn_named_object;
|
549
578
|
|
550
|
-
rb_grn_named_object = RB_GRN_NAMED_OBJECT(
|
579
|
+
rb_grn_named_object = RB_GRN_NAMED_OBJECT(RTYPEDDATA_DATA(rb_column));
|
551
580
|
if (name_size == rb_grn_named_object->name_size &&
|
552
581
|
memcmp(name, rb_grn_named_object->name, name_size) == 0) {
|
553
582
|
return rb_column;
|
@@ -572,9 +601,9 @@ rb_grn_table_get_column (VALUE self, VALUE rb_name)
|
|
572
601
|
owner = column->header.type == GRN_ACCESSOR;
|
573
602
|
rb_column = GRNCOLUMN2RVAL(Qnil, context, column, owner);
|
574
603
|
if (owner) {
|
575
|
-
rb_grn_context_register_floating_object(
|
604
|
+
rb_grn_context_register_floating_object(RTYPEDDATA_DATA(rb_column));
|
576
605
|
}
|
577
|
-
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)),
|
578
607
|
name, name_size);
|
579
608
|
|
580
609
|
return rb_column;
|
@@ -595,11 +624,15 @@ rb_grn_table_get_column_surely (VALUE self, VALUE rb_name)
|
|
595
624
|
}
|
596
625
|
|
597
626
|
/*
|
598
|
-
*
|
599
|
-
*
|
627
|
+
* @overload columns(prefix=nil)
|
628
|
+
* It returns the specified columns in the table.
|
629
|
+
*
|
630
|
+
* @param prefix [String, nil]
|
631
|
+
* If this is `nil`, it returns the all columns in table.
|
632
|
+
*
|
633
|
+
* Otherwise it returns columns which have name starts with `prefix`.
|
600
634
|
*
|
601
|
-
*
|
602
|
-
* @return [Groonga::Columnの配列]
|
635
|
+
* @return [::Array<Groonga::Column>]
|
603
636
|
*/
|
604
637
|
static VALUE
|
605
638
|
rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
|
@@ -611,9 +644,9 @@ rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
|
|
611
644
|
grn_rc rc;
|
612
645
|
int n;
|
613
646
|
grn_table_cursor *cursor;
|
614
|
-
VALUE
|
615
|
-
char *
|
616
|
-
unsigned
|
647
|
+
VALUE rb_prefix, rb_columns;
|
648
|
+
char *prefix = NULL;
|
649
|
+
unsigned prefix_size = 0;
|
617
650
|
VALUE exception;
|
618
651
|
|
619
652
|
rb_grn_table_deconstruct(SELF(self), &table, &context,
|
@@ -621,18 +654,18 @@ rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
|
|
621
654
|
NULL, NULL, NULL,
|
622
655
|
NULL);
|
623
656
|
|
624
|
-
rb_scan_args(argc, argv, "01", &
|
657
|
+
rb_scan_args(argc, argv, "01", &rb_prefix);
|
625
658
|
|
626
|
-
if (!NIL_P(
|
627
|
-
|
628
|
-
|
659
|
+
if (!NIL_P(rb_prefix)) {
|
660
|
+
prefix = StringValuePtr(rb_prefix);
|
661
|
+
prefix_size = RSTRING_LEN(rb_prefix);
|
629
662
|
}
|
630
663
|
|
631
664
|
key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
|
632
665
|
columns = grn_table_create(context, NULL, 0, NULL, GRN_TABLE_HASH_KEY,
|
633
666
|
key_type, 0);
|
634
667
|
rb_grn_context_check(context, self);
|
635
|
-
n = grn_table_columns(context, table,
|
668
|
+
n = grn_table_columns(context, table, prefix, prefix_size, columns);
|
636
669
|
rb_grn_context_check(context, self);
|
637
670
|
|
638
671
|
rb_columns = rb_ary_new2(n);
|
@@ -673,7 +706,7 @@ rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
|
|
673
706
|
RbGrnNamedObject *rb_grn_named_object;
|
674
707
|
name_size = grn_column_name(context, column,
|
675
708
|
name, GRN_TABLE_MAX_KEY_SIZE);
|
676
|
-
rb_grn_named_object = RB_GRN_NAMED_OBJECT(
|
709
|
+
rb_grn_named_object = RB_GRN_NAMED_OBJECT(RTYPEDDATA_DATA(rb_column));
|
677
710
|
rb_grn_named_object_set_name(rb_grn_named_object, name, name_size);
|
678
711
|
}
|
679
712
|
|
@@ -690,9 +723,10 @@ rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
|
|
690
723
|
}
|
691
724
|
|
692
725
|
/*
|
693
|
-
*
|
726
|
+
* Checks whether the table has a specified column or not.
|
694
727
|
*
|
695
728
|
* @overload have_column?(name)
|
729
|
+
* @return [Boolean] `true` if the table has a `name` column, `false` otherwise.
|
696
730
|
*/
|
697
731
|
static VALUE
|
698
732
|
rb_grn_table_have_column (VALUE self, VALUE rb_name)
|
@@ -873,11 +907,10 @@ rb_grn_table_open_cursor (int argc, VALUE *argv, VALUE self)
|
|
873
907
|
}
|
874
908
|
|
875
909
|
/*
|
876
|
-
* テーブルに登録されている全てのレコードが入っている配列を
|
877
|
-
* 返す。
|
878
|
-
*
|
879
910
|
* @overload records
|
880
|
-
*
|
911
|
+
* It returns all records in the table.
|
912
|
+
*
|
913
|
+
* @return [::Array<Groonga::Record>]
|
881
914
|
*/
|
882
915
|
static VALUE
|
883
916
|
rb_grn_table_get_records (int argc, VALUE *argv, VALUE self)
|
@@ -898,9 +931,9 @@ rb_grn_table_get_records (int argc, VALUE *argv, VALUE self)
|
|
898
931
|
}
|
899
932
|
|
900
933
|
/*
|
901
|
-
* テーブルに登録されているレコード数を返す。
|
902
|
-
*
|
903
934
|
* @overload size
|
935
|
+
* It returns the number of records in the table.
|
936
|
+
*
|
904
937
|
* @return [Integer]
|
905
938
|
*/
|
906
939
|
static VALUE
|
@@ -919,9 +952,10 @@ rb_grn_table_get_size (VALUE self)
|
|
919
952
|
}
|
920
953
|
|
921
954
|
/*
|
922
|
-
* テーブルにレコードが登録されていなければ +true+ を返す。
|
923
|
-
*
|
924
955
|
* @overload empty?
|
956
|
+
*
|
957
|
+
* @return [Boolean] `true` if the table has no records,
|
958
|
+
* `false` otherwise.
|
925
959
|
*/
|
926
960
|
static VALUE
|
927
961
|
rb_grn_table_empty_p (VALUE self)
|
@@ -939,9 +973,11 @@ rb_grn_table_empty_p (VALUE self)
|
|
939
973
|
}
|
940
974
|
|
941
975
|
/*
|
942
|
-
*
|
976
|
+
* Deletes all records in the table at once.
|
943
977
|
*
|
944
978
|
* @overload truncate
|
979
|
+
*
|
980
|
+
* @return [void]
|
945
981
|
*/
|
946
982
|
static VALUE
|
947
983
|
rb_grn_table_truncate (VALUE self)
|
@@ -1074,7 +1110,7 @@ rb_grn_table_delete_by_expression (VALUE self)
|
|
1074
1110
|
|
1075
1111
|
rb_builder = rb_grn_record_expression_builder_new(self, Qnil);
|
1076
1112
|
rb_expression = rb_grn_record_expression_builder_build(rb_builder);
|
1077
|
-
rb_grn_object_deconstruct(RB_GRN_OBJECT(
|
1113
|
+
rb_grn_object_deconstruct(RB_GRN_OBJECT(RTYPEDDATA_DATA(rb_expression)),
|
1078
1114
|
&expression, NULL,
|
1079
1115
|
NULL, NULL, NULL, NULL);
|
1080
1116
|
|
@@ -1112,7 +1148,7 @@ rb_grn_table_delete_by_expression (VALUE self)
|
|
1112
1148
|
*
|
1113
1149
|
* @param id [Integer] The ID of delete target record.
|
1114
1150
|
*
|
1115
|
-
* @return void
|
1151
|
+
* @return [void]
|
1116
1152
|
*
|
1117
1153
|
* @overload delete
|
1118
1154
|
* Delete records that are matched with the given condition
|
@@ -1130,7 +1166,7 @@ rb_grn_table_delete_by_expression (VALUE self)
|
|
1130
1166
|
* @yieldreturn [Groonga::ExpressionBuilder]
|
1131
1167
|
* TODO: See #select.
|
1132
1168
|
*
|
1133
|
-
* @return void
|
1169
|
+
* @return [void]
|
1134
1170
|
*/
|
1135
1171
|
static VALUE
|
1136
1172
|
rb_grn_table_delete (int argc, VALUE *argv, VALUE self)
|
@@ -1613,9 +1649,10 @@ rb_grn_table_each_sub_record (VALUE self, VALUE rb_id)
|
|
1613
1649
|
}
|
1614
1650
|
|
1615
1651
|
/*
|
1616
|
-
*
|
1652
|
+
* It returns the {Groonga::Record} for the `id` in the `table`.
|
1617
1653
|
*
|
1618
|
-
*
|
1654
|
+
* The return value has been changed to {Groonga::Record} from `id`
|
1655
|
+
* itself since 0.9.0.
|
1619
1656
|
*
|
1620
1657
|
* @overload [](id)
|
1621
1658
|
* @return [Groonga::Record]
|
@@ -1653,16 +1690,16 @@ rb_grn_table_get_value (VALUE self, VALUE rb_id)
|
|
1653
1690
|
}
|
1654
1691
|
|
1655
1692
|
/*
|
1656
|
-
*
|
1693
|
+
* It returns the value for the `id` in the `table`.
|
1657
1694
|
*
|
1658
|
-
*
|
1659
|
-
* {Groonga::Array}
|
1660
|
-
*
|
1695
|
+
* You can specify `id: true` for the convenience. `id: true` works
|
1696
|
+
* with {Groonga::Array} like for {Groonga::Hash},
|
1697
|
+
* {Groonga::PatriciaTrie} and so on.
|
1661
1698
|
*
|
1662
1699
|
* @overload value(id)
|
1663
|
-
* @return [
|
1664
|
-
* @overload value(id, :
|
1665
|
-
* @return [
|
1700
|
+
* @return [value]
|
1701
|
+
* @overload value(id, id: true)
|
1702
|
+
* @return [value]
|
1666
1703
|
*/
|
1667
1704
|
static VALUE
|
1668
1705
|
rb_grn_table_get_value_convenience (int argc, VALUE *argv, VALUE self)
|
@@ -2375,7 +2412,7 @@ rb_grn_table_select (int argc, VALUE *argv, VALUE self)
|
|
2375
2412
|
rb_funcall(builder, rb_intern("default_column="), 1, rb_default_column);
|
2376
2413
|
rb_expression = rb_grn_record_expression_builder_build(builder);
|
2377
2414
|
}
|
2378
|
-
rb_grn_object_deconstruct(RB_GRN_OBJECT(
|
2415
|
+
rb_grn_object_deconstruct(RB_GRN_OBJECT(RTYPEDDATA_DATA(rb_expression)),
|
2379
2416
|
&expression, NULL,
|
2380
2417
|
NULL, NULL, NULL, NULL);
|
2381
2418
|
|
@@ -2482,8 +2519,8 @@ rb_grn_table_support_key_p (VALUE self)
|
|
2482
2519
|
/*
|
2483
2520
|
* @overload support_value?
|
2484
2521
|
*
|
2485
|
-
* @return
|
2486
|
-
*
|
2522
|
+
* @return [Boolean] `true` if the table is created with value type,
|
2523
|
+
* `false` otherwise.
|
2487
2524
|
*/
|
2488
2525
|
static VALUE
|
2489
2526
|
rb_grn_table_support_value_p (VALUE self)
|
@@ -2498,11 +2535,11 @@ rb_grn_table_support_value_p (VALUE self)
|
|
2498
2535
|
}
|
2499
2536
|
|
2500
2537
|
/*
|
2501
|
-
* グループ化したとき、テーブルにグループに含まれるレコード
|
2502
|
-
* 数を格納できる場合は +true+ 、格納できない場合は +false+ を返
|
2503
|
-
* す。
|
2504
|
-
*
|
2505
2538
|
* @overload support_sub_records?
|
2539
|
+
*
|
2540
|
+
* @return [Boolean] `true` if the table can store the number of
|
2541
|
+
* records for each group when the table is grouped, `false`
|
2542
|
+
* otherwise.
|
2506
2543
|
*/
|
2507
2544
|
static VALUE
|
2508
2545
|
rb_grn_table_support_sub_records_p (VALUE self)
|
@@ -2517,6 +2554,19 @@ rb_grn_table_support_sub_records_p (VALUE self)
|
|
2517
2554
|
return CBOOL2RVAL(grn_table_is_grouped(context, table));
|
2518
2555
|
}
|
2519
2556
|
|
2557
|
+
/*
|
2558
|
+
* @overload support_score?
|
2559
|
+
*
|
2560
|
+
* @return [Boolean] `true` if the table has `_score` column,
|
2561
|
+
* `false` otherwise.
|
2562
|
+
*/
|
2563
|
+
static VALUE
|
2564
|
+
rb_grn_table_support_score_p (VALUE self)
|
2565
|
+
{
|
2566
|
+
return CBOOL2RVAL(rb_grn_table_have_column(self,
|
2567
|
+
rb_str_new_literal("_score")));
|
2568
|
+
}
|
2569
|
+
|
2520
2570
|
/*
|
2521
2571
|
* {Groonga::Table#group} returns a table that contains grouped
|
2522
2572
|
* records. If grouped table has a space to store the number of
|
@@ -2554,13 +2604,11 @@ rb_grn_table_have_n_sub_records_space_p (VALUE self)
|
|
2554
2604
|
}
|
2555
2605
|
|
2556
2606
|
/*
|
2557
|
-
* _table_ に _id_ で指定したIDのレコードが存在する場合は +true+ 、
|
2558
|
-
* 存在しない場合は +false+ を返す。
|
2559
|
-
*
|
2560
|
-
* 注意: 実行には相応のコストがかかるのであまり頻繁に呼ばな
|
2561
|
-
* いようにして下さい。
|
2562
|
-
*
|
2563
2607
|
* @overload exist?(id)
|
2608
|
+
* @return [Boolean] `true` if the table has a record specified ID
|
2609
|
+
* by `id`, `false` otherwise.
|
2610
|
+
*
|
2611
|
+
* @note This method is heavy. You should not call this as much as possible.
|
2564
2612
|
*/
|
2565
2613
|
static VALUE
|
2566
2614
|
rb_grn_table_exist_p (VALUE self, VALUE id)
|
@@ -2890,6 +2938,8 @@ rb_grn_init_table (VALUE mGrn)
|
|
2890
2938
|
rb_grn_table_support_value_p, 0);
|
2891
2939
|
rb_define_method(rb_cGrnTable, "support_sub_records?",
|
2892
2940
|
rb_grn_table_support_sub_records_p, 0);
|
2941
|
+
rb_define_method(rb_cGrnTable, "support_score?",
|
2942
|
+
rb_grn_table_support_score_p, 0);
|
2893
2943
|
rb_define_method(rb_cGrnTable, "have_n_sub_records_space?",
|
2894
2944
|
rb_grn_table_have_n_sub_records_space_p, 0);
|
2895
2945
|
|