rroonga 10.0.2 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +24 -0
  3. data/doc/text/news.md +36 -0
  4. data/ext/groonga/extconf.rb +14 -2
  5. data/ext/groonga/rb-grn-accessor.c +2 -2
  6. data/ext/groonga/rb-grn-column-cache.c +3 -3
  7. data/ext/groonga/rb-grn-column.c +4 -4
  8. data/ext/groonga/rb-grn-context.c +82 -58
  9. data/ext/groonga/rb-grn-data-column.c +4 -4
  10. data/ext/groonga/rb-grn-database.c +45 -26
  11. data/ext/groonga/rb-grn-double-array-trie.c +2 -2
  12. data/ext/groonga/rb-grn-encoding-support.c +2 -2
  13. data/ext/groonga/rb-grn-exception.c +14 -0
  14. data/ext/groonga/rb-grn-expression.c +3 -3
  15. data/ext/groonga/rb-grn-fix-size-column.c +2 -2
  16. data/ext/groonga/rb-grn-flushable.c +2 -1
  17. data/ext/groonga/rb-grn-hash.c +2 -2
  18. data/ext/groonga/rb-grn-index-column.c +3 -3
  19. data/ext/groonga/rb-grn-index-cursor.c +2 -2
  20. data/ext/groonga/rb-grn-inverted-index-cursor.c +3 -3
  21. data/ext/groonga/rb-grn-object.c +30 -9
  22. data/ext/groonga/rb-grn-operator.c +100 -259
  23. data/ext/groonga/rb-grn-patricia-trie.c +2 -2
  24. data/ext/groonga/rb-grn-plugin.c +34 -22
  25. data/ext/groonga/rb-grn-request-timer-id.c +2 -2
  26. data/ext/groonga/rb-grn-snippet.c +3 -3
  27. data/ext/groonga/rb-grn-table-cursor-key-support.c +2 -2
  28. data/ext/groonga/rb-grn-table-cursor.c +3 -3
  29. data/ext/groonga/rb-grn-table-key-support.c +3 -3
  30. data/ext/groonga/rb-grn-table.c +63 -45
  31. data/ext/groonga/rb-grn-variable-size-column.c +2 -2
  32. data/ext/groonga/rb-grn-variable.c +2 -2
  33. data/ext/groonga/rb-grn.h +8 -5
  34. data/ext/groonga/rb-groonga.c +5 -1
  35. data/lib/groonga/context.rb +32 -0
  36. data/rroonga-build.rb +5 -4
  37. data/rroonga.gemspec +5 -2
  38. data/test/groonga-test-utils.rb +3 -0
  39. data/test/run-test.rb +1 -1
  40. data/test/test-index-column.rb +3 -3
  41. data/test/test-logger.rb +2 -0
  42. data/test/test-ractor.rb +65 -0
  43. data/test/test-remote.rb +16 -0
  44. data/test/test-table-arrow.rb +21 -9
  45. 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-2013 Kouhei Sutou <kou@clear-code.com>
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 *)DATA_PTR(object))
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", rb_cData);
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-2020 Sutou Kouhei <kou@clear-code.com>
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 *)DATA_PTR(object))
22
+ #define SELF(object) ((RbGrnTableKeySupport *)RTYPEDDATA_DATA(object))
23
23
 
24
24
  VALUE rb_mGrnTableKeySupport;
25
25
 
@@ -498,7 +498,7 @@ set_value (RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
498
498
  rb_grn_inspect(rb_name), rb_grn_inspect(data->self));
499
499
  }
500
500
 
501
- rb_grn_object = RB_GRN_OBJECT(DATA_PTR(rb_column));
501
+ rb_grn_object = RB_GRN_OBJECT(RTYPEDDATA_DATA(rb_column));
502
502
  return rb_grn_object_set_raw(rb_grn_object,
503
503
  data->id, rb_value, GRN_OBJ_SET, data->self);
504
504
  }
@@ -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-2017 Kouhei Sutou <kou@clear-code.com>
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 Data_Wrap_Struct(klass, rb_grn_table_mark, rb_grn_object_free, NULL);
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(DATA_PTR(rb_column)),
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(DATA_PTR(rb_column)),
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(DATA_PTR(rb_column));
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(DATA_PTR(rb_column));
604
+ rb_grn_context_register_floating_object(RTYPEDDATA_DATA(rb_column));
587
605
  }
588
- rb_grn_named_object_set_name(RB_GRN_NAMED_OBJECT(DATA_PTR(rb_column)),
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(DATA_PTR(rb_column));
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(DATA_PTR(rb_expression)),
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(DATA_PTR(rb_expression)),
2415
+ rb_grn_object_deconstruct(RB_GRN_OBJECT(RTYPEDDATA_DATA(rb_expression)),
2398
2416
  &expression, NULL,
2399
2417
  NULL, NULL, NULL, NULL);
2400
2418
 
@@ -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-2016 Kouhei Sutou <kou@clear-code.com>
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 *)DATA_PTR(object))
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 Sutou <kou@clear-code.com>
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 *)DATA_PTR(object))
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-2020 Sutou Kouhei <kou@clear-code.com>
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
@@ -91,9 +91,9 @@ RB_GRN_BEGIN_DECLS
91
91
 
92
92
  #define RB_GRN_HAVE_FLOAT32 GRN_VERSION_OR_LATER(10, 0, 2)
93
93
 
94
- #define RB_GRN_MAJOR_VERSION 10
94
+ #define RB_GRN_MAJOR_VERSION 12
95
95
  #define RB_GRN_MINOR_VERSION 0
96
- #define RB_GRN_MICRO_VERSION 2
96
+ #define RB_GRN_MICRO_VERSION 0
97
97
 
98
98
  #define RB_GRN_OBJECT(object) ((RbGrnObject *)(object))
99
99
  #define RB_GRN_NAMED_OBJECT(object) ((RbGrnNamedObject *)(object))
@@ -314,6 +314,8 @@ RB_GRN_VAR VALUE rb_mGrnRequestTimer;
314
314
  RB_GRN_VAR VALUE rb_cGrnRequestTimerID;
315
315
  RB_GRN_VAR VALUE rb_cGrnColumnCache;
316
316
 
317
+ RB_GRN_VAR rb_data_type_t rb_grn_object_data_type;
318
+
317
319
  void rb_grn_init_utils (VALUE mGrn);
318
320
  void rb_grn_init_exception (VALUE mGrn);
319
321
  void rb_grn_init_encoding (VALUE mGrn);
@@ -779,7 +781,8 @@ rb_encoding *rb_grn_encoding_to_ruby_encoding (grn_encoding encoding);
779
781
  VALUE rb_grn_encoding_to_ruby_encoding_object
780
782
  (grn_encoding encoding);
781
783
 
782
- grn_ctx *rb_grn_context_from_ruby_object (VALUE object);
784
+ RbGrnContext *rb_grn_context_get_struct (VALUE rb_context);
785
+ grn_ctx *rb_grn_context_from_ruby_object (VALUE rb_context);
783
786
  VALUE rb_grn_context_to_ruby_object (grn_ctx *context);
784
787
  VALUE rb_grn_context_rb_string_new (grn_ctx *context,
785
788
  const char *string,
@@ -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-2020 Sutou Kouhei <kou@clear-code.com>
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
@@ -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");
@@ -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-2018 Kouhei Sutou <kou@clear-code.com>
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 = 9
19
+ MAJOR = 11
20
20
  MINOR = 0
21
- MICRO = 2
21
+ MICRO = 0
22
22
  VERSION = [MAJOR, MINOR, MICRO]
23
- RELEASED_DATE = Time.utc(2019, 4, 29)
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
- s.metadata["msys2_mingw_dependencies"] = "groonga>=10.0.1"
97
+ required_groonga_version = RroongaBuild::RequiredGroongaVersion::STRING
98
+ s.metadata["msys2_mingw_dependencies"] = "groonga>=#{required_groonga_version}"
96
99
  end
97
100
 
@@ -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} ---"
data/test/run-test.rb CHANGED
@@ -37,7 +37,7 @@ end
37
37
  require "test-unit"
38
38
  require "test/unit/priority"
39
39
 
40
- Test::Unit::Priority.enable
40
+ Test::Unit::Priority.enable unless ENV["CI"]
41
41
 
42
42
 
43
43
  groonga_command_dir = File.join(base_dir, "..", "groonga-command")
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
@@ -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
data/test/test-remote.rb CHANGED
@@ -26,6 +26,7 @@ class RemoteTest < Test::Unit::TestCase
26
26
  else
27
27
  package_config = PKGConfig.package_config("groonga")
28
28
  groonga = package_config.variable("groonga")
29
+ groonga = normalize_groonga_path(groonga)
29
30
  groonga = "groonga" unless File.exist?(groonga)
30
31
  end
31
32
 
@@ -51,6 +52,19 @@ class RemoteTest < Test::Unit::TestCase
51
52
  end
52
53
  end
53
54
 
55
+ def normalize_groonga_path(groonga)
56
+ return groonga unless groonga
57
+ return groonga unless Object.const_defined?(:RubyInstaller)
58
+
59
+ msys2_installation = RubyInstaller::Runtime.msys2_installation
60
+ mingw_prefix = msys2_installation.mingw_prefix
61
+ mingw_bin_path = "#{mingw_prefix}/bin/"
62
+ mingw_bin_path_windows = "#{msys2_installation.mingw_bin_path}\\"
63
+ groonga.gsub(/\A#{Regexp.escape(mingw_bin_path)}/) do
64
+ mingw_bin_path_windows
65
+ end
66
+ end
67
+
54
68
  teardown
55
69
  def teardown_remote_connection
56
70
  if @process_id
@@ -78,6 +92,8 @@ class RemoteTest < Test::Unit::TestCase
78
92
  id, result = _context.receive
79
93
  assert_equal(0, id)
80
94
  values = JSON.load(result)
95
+ values.delete("apache_arrow")
96
+ values.delete("features")
81
97
  assert_equal([
82
98
  "alloc_count",
83
99
  "cache_hit_rate",
@@ -22,6 +22,15 @@ class TableArrowTest < Test::Unit::TestCase
22
22
  omit("Apache Arrow support is required") unless context.support_arrow?
23
23
  end
24
24
 
25
+ def open_temporary_file(extension)
26
+ tempfile = Tempfile.new(["table-arrow", extension])
27
+ begin
28
+ yield(tempfile)
29
+ ensure
30
+ tempfile.close!
31
+ end
32
+ end
33
+
25
34
  def assert_dump_load(type, n_records)
26
35
  Groonga::Schema.define do |schema|
27
36
  schema.create_table("Source") do |table|
@@ -42,9 +51,10 @@ class TableArrowTest < Test::Unit::TestCase
42
51
  source.add(:data => data)
43
52
  end
44
53
 
45
- tempfile = Tempfile.new(["table-arrow", ".arrow"])
46
- source.dump_arrow(tempfile.path)
47
- destination.load_arrow(tempfile.path)
54
+ open_temporary_file(".arrow") do |tempfile|
55
+ source.dump_arrow(tempfile.path)
56
+ destination.load_arrow(tempfile.path)
57
+ end
48
58
 
49
59
  assert_equal(expected,
50
60
  destination.collect(&:attributes))
@@ -153,9 +163,10 @@ class TableArrowTest < Test::Unit::TestCase
153
163
  source.add(:data1 => data1, :data2 => data2)
154
164
  end
155
165
 
156
- tempfile = Tempfile.new(["table-arrow", ".arrow"])
157
- source.dump_arrow(tempfile.path, :columns => source.columns[0, 1])
158
- destination.load_arrow(tempfile.path)
166
+ open_temporary_file(".arrow") do |tempfile|
167
+ source.dump_arrow(tempfile.path, columns: source.columns[0, 1])
168
+ destination.load_arrow(tempfile.path)
169
+ end
159
170
 
160
171
  assert_equal(expected,
161
172
  destination.collect(&:attributes))
@@ -183,9 +194,10 @@ class TableArrowTest < Test::Unit::TestCase
183
194
  source.add(:data1 => data1, :data2 => data2)
184
195
  end
185
196
 
186
- tempfile = Tempfile.new(["table-arrow", ".arrow"])
187
- source.dump_arrow(tempfile.path, :column_names => ["data1"])
188
- destination.load_arrow(tempfile.path)
197
+ open_temporary_file(".arrow") do |tempfile|
198
+ source.dump_arrow(tempfile.path, column_names: ["data1"])
199
+ destination.load_arrow(tempfile.path)
200
+ end
189
201
 
190
202
  assert_equal(expected,
191
203
  destination.collect(&:attributes))