rroonga 10.0.6 → 11.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +24 -0
  3. data/doc/text/news.md +12 -0
  4. data/ext/groonga/extconf.rb +12 -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 +7 -4
  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/test-index-column.rb +3 -3
  40. data/test/test-ractor.rb +65 -0
  41. data/test/test-remote.rb +2 -0
  42. data/test/test-table-arrow.rb +21 -9
  43. metadata +85 -69
@@ -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} ---"
@@ -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")
@@ -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
@@ -92,6 +92,8 @@ class RemoteTest < Test::Unit::TestCase
92
92
  id, result = _context.receive
93
93
  assert_equal(0, id)
94
94
  values = JSON.load(result)
95
+ values.delete("apache_arrow")
96
+ values.delete("features")
95
97
  assert_equal([
96
98
  "alloc_count",
97
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))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rroonga
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.6
4
+ version: 11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,13 +9,27 @@ authors:
9
9
  - daijiro
10
10
  - Yuto HAYAMIZU
11
11
  - SHIDARA Yoji
12
- autorequire:
12
+ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-09-04 00:00:00.000000000 Z
15
+ date: 2021-02-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
- name: pkg-config
18
+ name: groonga-client
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.3
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: 0.0.3
31
+ - !ruby/object:Gem::Dependency
32
+ name: json
19
33
  requirement: !ruby/object:Gem::Requirement
20
34
  requirements:
21
35
  - - ">="
@@ -29,21 +43,21 @@ dependencies:
29
43
  - !ruby/object:Gem::Version
30
44
  version: '0'
31
45
  - !ruby/object:Gem::Dependency
32
- name: groonga-client
46
+ name: native-package-installer
33
47
  requirement: !ruby/object:Gem::Requirement
34
48
  requirements:
35
49
  - - ">="
36
50
  - !ruby/object:Gem::Version
37
- version: 0.0.3
51
+ version: '0'
38
52
  type: :runtime
39
53
  prerelease: false
40
54
  version_requirements: !ruby/object:Gem::Requirement
41
55
  requirements:
42
56
  - - ">="
43
57
  - !ruby/object:Gem::Version
44
- version: 0.0.3
58
+ version: '0'
45
59
  - !ruby/object:Gem::Dependency
46
- name: json
60
+ name: pkg-config
47
61
  requirement: !ruby/object:Gem::Requirement
48
62
  requirements:
49
63
  - - ">="
@@ -153,9 +167,9 @@ email:
153
167
  - dara@shidara.net
154
168
  executables:
155
169
  - grntest-log-analyze
170
+ - groonga-index-dump
156
171
  - groonga-database-inspect
157
172
  - grndump
158
- - groonga-index-dump
159
173
  extensions:
160
174
  - ext/groonga/extconf.rb
161
175
  extra_rdoc_files:
@@ -322,6 +336,7 @@ files:
322
336
  - test/test-plugin.rb
323
337
  - test/test-procedure.rb
324
338
  - test/test-query-logger.rb
339
+ - test/test-ractor.rb
325
340
  - test/test-record.rb
326
341
  - test/test-remote.rb
327
342
  - test/test-request-canceler.rb
@@ -355,8 +370,8 @@ homepage: http://ranguba.org/#about-rroonga
355
370
  licenses:
356
371
  - LGPL-2.1
357
372
  metadata:
358
- msys2_mingw_dependencies: groonga>=10.0.1
359
- post_install_message:
373
+ msys2_mingw_dependencies: groonga>=11.0.0
374
+ post_install_message:
360
375
  rdoc_options: []
361
376
  require_paths:
362
377
  - lib
@@ -372,79 +387,80 @@ required_rubygems_version: !ruby/object:Gem::Requirement
372
387
  - !ruby/object:Gem::Version
373
388
  version: '0'
374
389
  requirements: []
375
- rubygems_version: 3.1.4
376
- signing_key:
390
+ rubygems_version: 3.1.2
391
+ signing_key:
377
392
  specification_version: 4
378
393
  summary: Ruby bindings for Groonga that provide full text search and column store
379
394
  features.
380
395
  test_files:
381
- - test/test-remote.rb
382
- - test/test-table-arrow.rb
383
- - test/test-encoding.rb
384
- - test/test-column-cache.rb
385
- - test/test-table-traverse.rb
396
+ - test/test-table-dumper.rb
397
+ - test/test-query-logger.rb
398
+ - test/test-variable-size-column.rb
399
+ - test/test-schema-dumper.rb
400
+ - test/test-double-array-trie.rb
401
+ - test/test-expression-builder.rb
402
+ - test/test-array.rb
403
+ - test/test-id.rb
404
+ - test/test-table-key-support.rb
405
+ - test/test-database-dumper.rb
406
+ - test/test-expression.rb
386
407
  - test/test-logger.rb
387
- - test/test-exception.rb
388
- - test/test-vector-column.rb
389
408
  - test/run-test.rb
390
- - test/test-memory-pool.rb
391
- - test/test-context.rb
392
- - test/test-default-cache.rb
393
409
  - test/test-windows-event-logger.rb
394
- - test/test-schema-create-table.rb
410
+ - test/test-vector-column.rb
411
+ - test/test-operator.rb
412
+ - test/test-table.rb
395
413
  - test/test-table-group.rb
414
+ - test/test-column.rb
415
+ - test/test-pagination.rb
416
+ - test/test-error-message.rb
417
+ - test/test-fix-size-column.rb
418
+ - test/test-table-arrow.rb
419
+ - test/test-sub-records.rb
420
+ - test/test-table-select-normalize.rb
421
+ - test/test-config.rb
422
+ - test/test-patricia-trie.rb
423
+ - test/test-gqtp.rb
424
+ - test/test-memory-pool.rb
425
+ - test/test-schema-create-table.rb
426
+ - test/test-schema.rb
427
+ - test/test-column-cache.rb
428
+ - test/test-command-select.rb
429
+ - test/test-lock-timeout.rb
430
+ - test/test-request-canceler.rb
431
+ - test/test-default-cache.rb
396
432
  - test/test-database.rb
433
+ - test/test-token-regexp.rb
434
+ - test/test-table-select-weight.rb
435
+ - test/test-database-inspector.rb
436
+ - test/test-encoding.rb
397
437
  - test/test-hash.rb
398
- - test/test-command-select.rb
399
- - test/test-table-offset-and-limit.rb
400
438
  - test/test-schema-type.rb
401
- - test/test-sub-records.rb
402
- - test/test-data-column.rb
439
+ - test/test-type.rb
440
+ - test/test-context.rb
403
441
  - test/test-flushable.rb
404
- - test/test-double-array-trie.rb
405
- - test/groonga-test-utils.rb
406
- - test/test-name.rb
407
- - test/test-lock-timeout.rb
408
- - test/test-database-inspector.rb
409
- - test/test-expression.rb
410
- - test/test-table-dumper.rb
411
- - test/test-plugin.rb
412
- - test/test-procedure.rb
413
- - test/test-error-message.rb
414
- - test/test-table-select-mecab.rb
415
- - test/test-expression-builder.rb
416
- - test/test-operator.rb
417
- - test/test-query-logger.rb
418
- - test/test-table-select-normalize.rb
442
+ - test/test-normalizer.rb
419
443
  - test/test-table-select.rb
444
+ - test/test-index-cursor.rb
445
+ - test/test-remote.rb
420
446
  - test/test-snippet.rb
421
- - test/test-variable-size-column.rb
422
- - test/test-variable.rb
423
- - test/test-id.rb
424
- - test/test-patricia-trie.rb
425
- - test/test-request-timer.rb
426
- - test/test-pagination.rb
427
- - test/test-request-canceler.rb
447
+ - test/test-exception.rb
448
+ - test/groonga-test-utils.rb
449
+ - test/test-table-traverse.rb
450
+ - test/test-convert.rb
428
451
  - test/test-thread.rb
429
- - test/test-version.rb
430
- - test/test-column.rb
431
- - test/test-database-dumper.rb
452
+ - test/test-plugin.rb
432
453
  - test/test-accessor.rb
433
- - test/test-index-cursor.rb
434
- - test/test-table.rb
435
- - test/test-normalizer.rb
436
- - test/test-table-select-weight.rb
437
- - test/test-fix-size-column.rb
438
- - test/test-convert.rb
439
- - test/test-record.rb
440
- - test/test-package-label.rb
441
- - test/test-array.rb
442
- - test/test-schema.rb
443
- - test/test-config.rb
444
454
  - test/test-index-column.rb
445
- - test/test-table-key-support.rb
446
- - test/test-schema-dumper.rb
447
- - test/test-gqtp.rb
448
- - test/test-token-regexp.rb
449
- - test/test-type.rb
455
+ - test/test-data-column.rb
456
+ - test/test-ractor.rb
450
457
  - test/test-geo-point.rb
458
+ - test/test-request-timer.rb
459
+ - test/test-table-select-mecab.rb
460
+ - test/test-version.rb
461
+ - test/test-package-label.rb
462
+ - test/test-variable.rb
463
+ - test/test-record.rb
464
+ - test/test-table-offset-and-limit.rb
465
+ - test/test-procedure.rb
466
+ - test/test-name.rb