rroonga 5.1.1 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  # Copyright (C) 2014-2015 Masafumi Yokoyama <yokoyama@clear-code.com>
4
- # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
4
+ # Copyright (C) 2009-2016 Kouhei Sutou <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
@@ -79,8 +79,6 @@ class ExpressionBuilderTest < Test::Unit::TestCase
79
79
  end
80
80
 
81
81
  class NotEqualTest < self
82
- setup :only_ruby19
83
-
84
82
  def test_without_index
85
83
  result = @users.select do |record|
86
84
  record["name"] != "mori daijiro"
@@ -195,6 +193,14 @@ class ExpressionBuilderTest < Test::Unit::TestCase
195
193
  assert_equal(["gunyara-kun", "yu"],
196
194
  result.collect {|record| record.key.key})
197
195
  end
196
+
197
+ def test_and_not
198
+ result = @users.select do |record|
199
+ (record["hp"] > 100) - (record["hp"] == 150)
200
+ end
201
+ assert_equal(["yu"],
202
+ result.collect {|record| record.key.key})
203
+ end
198
204
  end
199
205
 
200
206
  class FullTextSearchTest < self
@@ -524,39 +530,162 @@ EOC
524
530
  end
525
531
 
526
532
  class CallTest < self
527
- def setup_tables
528
- Groonga::Schema.define do |schema|
529
- schema.create_table("Shops",
530
- :type => :hash,
531
- :key_type => "ShortText") do |table|
532
- table.wgs84_geo_point("location")
533
+ class StringTest < self
534
+ def setup_tables
535
+ Groonga::Schema.define do |schema|
536
+ schema.create_table("Shops",
537
+ :type => :hash,
538
+ :key_type => "ShortText") do |table|
539
+ table.wgs84_geo_point("location")
540
+ end
541
+
542
+ schema.create_table("Locations",
543
+ :type => :patricia_trie,
544
+ :key_type => :wgs84_geo_point) do |table|
545
+ table.index("Shops.location")
546
+ end
533
547
  end
534
548
 
535
- schema.create_table("Locations",
536
- :type => :patricia_trie,
537
- :key_type => :wgs84_geo_point) do |table|
538
- table.index("Shops.location")
549
+ @shops = Groonga["Shops"]
550
+ end
551
+
552
+ def setup_data
553
+ @shops.add("Nezu no taiyaki", :location => "35.720253,139.762573")
554
+ @shops.add("Taiyaki Kataoka", :location => "35.712521,139.715591")
555
+ @shops.add("Taiyaki Sharaku", :location => "35.716969,139.794846")
556
+ end
557
+
558
+ def test_call_style
559
+ result = @shops.select do |record|
560
+ record.call("geo_in_rectangle",
561
+ record.location,
562
+ "35.7185,139.7912",
563
+ "35.7065,139.8069")
539
564
  end
565
+ assert_equal(["Taiyaki Sharaku"],
566
+ result.collect(&:_key))
540
567
  end
541
568
 
542
- @shops = Groonga["Shops"]
569
+ def test_method_style
570
+ result = @shops.select do |record|
571
+ record.location.geo_in_rectangle("35.7185,139.7912",
572
+ "35.7065,139.8069")
573
+ end
574
+ assert_equal(["Taiyaki Sharaku"],
575
+ result.collect(&:_key))
576
+ end
543
577
  end
544
578
 
545
- def setup_data
546
- @shops.add("Nezu no taiyaki", :location => "35.720253,139.762573")
547
- @shops.add("Taiyaki Kataoka", :location => "35.712521,139.715591")
548
- @shops.add("Taiyaki Sharaku", :location => "35.716969,139.794846")
579
+ class IntegerTest < self
580
+ def setup_tables
581
+ Groonga::Schema.define do |schema|
582
+ schema.create_table("Users",
583
+ :type => :hash,
584
+ :key_type => "ShortText") do |table|
585
+ table.int32("age")
586
+ end
587
+
588
+ schema.create_table("Ages",
589
+ :type => :patricia_trie,
590
+ :key_type => :int32) do |table|
591
+ table.index("Users.age")
592
+ end
593
+ end
594
+
595
+ @users = Groonga["Users"]
596
+ end
597
+
598
+ def setup_data
599
+ @users.add("Alice", :age => 18)
600
+ @users.add("Bob", :age => 29)
601
+ @users.add("Carlos", :age => 14)
602
+ end
603
+
604
+ def test_search
605
+ result = @users.select do |record|
606
+ record.call("between",
607
+ record.age,
608
+ 18,
609
+ "include",
610
+ 29,
611
+ "exclude")
612
+ end
613
+ assert_equal(["Alice"],
614
+ result.collect(&:_key))
615
+ end
549
616
  end
550
617
 
551
- def test_search
552
- result = @shops.select do |record|
553
- record.call("geo_in_rectangle",
554
- record.location,
555
- "35.7185,139.7912",
556
- "35.7065,139.8069")
618
+ class TimeTest < self
619
+ def setup_tables
620
+ Groonga::Schema.define do |schema|
621
+ schema.create_table("Logs",
622
+ :type => :array) do |table|
623
+ table.time("timestamp")
624
+ end
625
+
626
+ schema.create_table("Times",
627
+ :type => :patricia_trie,
628
+ :key_type => :time) do |table|
629
+ table.index("Logs.timestamp")
630
+ end
631
+ end
632
+
633
+ @logs = Groonga["Logs"]
634
+ end
635
+
636
+ def setup_data
637
+ @logs.add(:timestamp => Time.iso8601("2016-02-21T19:00:01Z"))
638
+ @logs.add(:timestamp => Time.iso8601("2016-02-21T19:00:02Z"))
639
+ @logs.add(:timestamp => Time.iso8601("2016-02-21T19:00:03Z"))
640
+ end
641
+
642
+ def test_search
643
+ result = @logs.select do |record|
644
+ record.call("between",
645
+ record.timestamp,
646
+ Time.iso8601("2016-02-21T19:00:01Z"),
647
+ "include",
648
+ Time.iso8601("2016-02-21T19:00:03Z"),
649
+ "exclude")
650
+ end
651
+ assert_equal([
652
+ Time.iso8601("2016-02-21T19:00:01Z"),
653
+ Time.iso8601("2016-02-21T19:00:02Z"),
654
+ ],
655
+ result.collect(&:timestamp))
656
+ end
657
+ end
658
+
659
+ class HashTest < self
660
+ def setup_tables
661
+ Groonga::Schema.define do |schema|
662
+ schema.create_table("Tags",
663
+ :type => :patricia_trie,
664
+ :key_type => :short_text) do |table|
665
+ end
666
+ end
667
+
668
+ @tags = Groonga["Tags"]
669
+ end
670
+
671
+ def setup_data
672
+ @tags.add("Tom")
673
+ @tags.add("Tomy")
674
+ @tags.add("Ken")
675
+ end
676
+
677
+ def test_search
678
+ omit("TODO: Enable me when Groonga 6.0.1 is released.")
679
+ result = @tags.select do |record|
680
+ record.key.fuzzy_search("Toym", :with_transposition => true)
681
+ end
682
+ sorted_result = result.sort(["_score", "_key"])
683
+ assert_equal([
684
+ ["Tom", 1.0],
685
+ ["Tomy", 1.0],
686
+ ],
687
+ sorted_result.collect {|r| [r._key, r.score]})
557
688
  end
558
- assert_equal(["Taiyaki Sharaku"],
559
- result.collect(&:_key))
560
689
  end
561
690
  end
562
691
 
@@ -596,9 +725,9 @@ EOC
596
725
  result.collect {|record| record.key["uri"]})
597
726
  end
598
727
 
599
- def test_id
728
+ def test_key
600
729
  result = @bookmarks.select do |record|
601
- record["user"] == @morita.id
730
+ record["user"] == @morita.key
602
731
  end
603
732
  assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
604
733
  result.collect {|record| record.key["uri"]})
@@ -607,8 +736,22 @@ EOC
607
736
  def test_record_like_object
608
737
  morita = Object.new
609
738
  morita_singleton_class = (class << morita; self; end)
610
- morita_id = @morita.id
739
+ morita_key = @morita.key
611
740
  morita_singleton_class.send(:define_method, :record_id) do
741
+ morita_key
742
+ end
743
+ result = @bookmarks.select do |record|
744
+ record["user"] == morita
745
+ end
746
+ assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
747
+ result.collect {|record| record.key["uri"]})
748
+ end
749
+
750
+ def test_record_like_object_raw
751
+ morita = Object.new
752
+ morita_singleton_class = (class << morita; self; end)
753
+ morita_id = @morita.id
754
+ morita_singleton_class.send(:define_method, :record_raw_id) do
612
755
  morita_id
613
756
  end
614
757
  result = @bookmarks.select do |record|
data/test/test-plugin.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # Copyright (C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
2
3
  #
3
4
  # This library is free software; you can redistribute it and/or
4
5
  # modify it under the terms of the GNU Lesser General Public
@@ -21,7 +22,6 @@ class PluginTest < Test::Unit::TestCase
21
22
  teardown :teardown_sandbox
22
23
 
23
24
  def test_register
24
- context = Groonga::Context.default
25
25
  assert_nil(context["TokenFilterStopWord"])
26
26
  context.register_plugin("token_filters/stop_word")
27
27
  assert_not_nil(context["TokenFilterStopWord"])
@@ -56,4 +56,28 @@ class PluginTest < Test::Unit::TestCase
56
56
  assert_nil(context["TokenFilterStopWord"])
57
57
  end
58
58
  end
59
+
60
+ class NamesTest < self
61
+ def test_nothing
62
+ assert_equal([], Groonga::Plugin.names)
63
+ end
64
+
65
+ def test_one_plugin
66
+ context.register_plugin("token_filters/stop_word")
67
+ assert_equal(["token_filters/stop_word"],
68
+ Groonga::Plugin.names)
69
+ end
70
+
71
+ def test_multiple_plugins
72
+ context.register_plugin("token_filters/stop_word")
73
+ context.register_plugin("query_expanders/tsv")
74
+ assert_equal(["token_filters/stop_word", "query_expanders/tsv"],
75
+ Groonga::Plugin.names)
76
+ end
77
+
78
+ def test_context_option
79
+ context.register_plugin("token_filters/stop_word")
80
+ assert_equal([], Groonga::Plugin.names(context: Groonga::Context.new))
81
+ end
82
+ end
59
83
  end
@@ -512,9 +512,9 @@ EOS
512
512
  assert_equal(<<-EOS, dump("Users"))
513
513
  load --table Users
514
514
  [
515
- [\"_key\",\"name\"],
516
- [\"mori\",\"mori daijiro\"],
517
- [\"s-yata\",\"Susumu Yata\"]
515
+ ["_key","name"],
516
+ ["mori","mori daijiro"],
517
+ ["s-yata","Susumu Yata"]
518
518
  ]
519
519
  EOS
520
520
  end
@@ -557,9 +557,38 @@ EOS
557
557
  assert_equal(<<-COMMAND, dump("Products"))
558
558
  load --table Products
559
559
  [
560
- [\"_key\",\"tags\"],
561
- [\"Groonga\",{\"groonga\":100}],
562
- [\"Mroonga\",{\"groonga\":10,\"mroonga\":100}]
560
+ ["_key","tags"],
561
+ ["Groonga",{"groonga":100}],
562
+ ["Mroonga",{"groonga":10,"mroonga":100}]
563
+ ]
564
+ COMMAND
565
+ end
566
+ end
567
+
568
+ class MaxRecordsTest < self
569
+ def setup
570
+ Groonga::Schema.define do |schema|
571
+ schema.create_table("Products",
572
+ :type => :hash,
573
+ :key_type => "ShortText") do |table|
574
+ end
575
+ end
576
+ end
577
+
578
+ def products
579
+ Groonga["Products"]
580
+ end
581
+
582
+ def test_small
583
+ products.add("Groonga")
584
+ products.add("Mroonga")
585
+ products.add("Rroonga")
586
+ assert_equal(<<-COMMAND, dump("Products", :max_records => 2))
587
+ load --table Products
588
+ [
589
+ ["_key"],
590
+ ["Groonga"],
591
+ ["Mroonga"]
563
592
  ]
564
593
  COMMAND
565
594
  end
@@ -153,7 +153,6 @@ class TableSelectTest < Test::Unit::TestCase
153
153
  end
154
154
 
155
155
  def test_not_equal_block
156
- only_ruby19
157
156
  @result = @comments.select do |record|
158
157
  record.user != "darashi"
159
158
  end
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: 5.1.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-01-18 00:00:00.000000000 Z
15
+ date: 2016-03-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pkg-config
@@ -208,9 +208,9 @@ email:
208
208
  - y.hayamizu@gmail.com
209
209
  - dara@shidara.net
210
210
  executables:
211
- - grntest-log-analyze
212
211
  - groonga-database-inspect
213
212
  - grndump
213
+ - grntest-log-analyze
214
214
  - groonga-index-dump
215
215
  extensions:
216
216
  - ext/groonga/extconf.rb
@@ -233,6 +233,11 @@ files:
233
233
  - bin/groonga-database-inspect
234
234
  - bin/groonga-index-dump
235
235
  - doc/images/sample-schema.png
236
+ - doc/text/cross-compile.md
237
+ - doc/text/install.md
238
+ - doc/text/news.md
239
+ - doc/text/release.md
240
+ - doc/text/tutorial.md
236
241
  - example/bookmark.rb
237
242
  - example/index-html.rb
238
243
  - example/measure-data-column-disk-usage.rb
@@ -264,6 +269,7 @@ files:
264
269
  - ext/groonga/rb-grn-hash.c
265
270
  - ext/groonga/rb-grn-index-column.c
266
271
  - ext/groonga/rb-grn-index-cursor.c
272
+ - ext/groonga/rb-grn-index.c
267
273
  - ext/groonga/rb-grn-less-equal-operator.c
268
274
  - ext/groonga/rb-grn-less-operator.c
269
275
  - ext/groonga/rb-grn-logger.c
@@ -303,11 +309,11 @@ files:
303
309
  - lib/groonga/database-inspector.rb
304
310
  - lib/groonga/database.rb
305
311
  - lib/groonga/dumper.rb
306
- - lib/groonga/expression-builder-19.rb
307
312
  - lib/groonga/expression-builder.rb
308
313
  - lib/groonga/geo-point.rb
309
314
  - lib/groonga/grntest-log.rb
310
315
  - lib/groonga/index-column.rb
316
+ - lib/groonga/index.rb
311
317
  - lib/groonga/logger.rb
312
318
  - lib/groonga/memory-pool.rb
313
319
  - lib/groonga/pagination.rb
@@ -319,6 +325,7 @@ files:
319
325
  - lib/groonga/statistic-measurer.rb
320
326
  - lib/groonga/sub-records.rb
321
327
  - lib/groonga/table.rb
328
+ - lib/rroonga.rb
322
329
  - misc/grnop2ruby.rb
323
330
  - rroonga-build.rb
324
331
  - rroonga.gemspec
@@ -336,6 +343,7 @@ files:
336
343
  - test/test-database.rb
337
344
  - test/test-double-array-trie.rb
338
345
  - test/test-encoding.rb
346
+ - test/test-error-message.rb
339
347
  - test/test-exception.rb
340
348
  - test/test-expression-builder.rb
341
349
  - test/test-expression.rb
@@ -405,72 +413,73 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
413
  version: '0'
406
414
  requirements: []
407
415
  rubyforge_project:
408
- rubygems_version: 2.4.5.1
416
+ rubygems_version: 2.5.1
409
417
  signing_key:
410
418
  specification_version: 4
411
419
  summary: Ruby bindings for Groonga that provide full text search and column store
412
420
  features.
413
421
  test_files:
414
- - test/test-context.rb
422
+ - test/run-test.rb
423
+ - test/test-error-message.rb
415
424
  - test/test-normalizer.rb
416
- - test/test-double-array-trie.rb
417
- - test/test-token-regexp.rb
418
- - test/test-remote.rb
425
+ - test/test-database.rb
426
+ - test/test-schema-type.rb
427
+ - test/test-convert.rb
428
+ - test/test-memory-pool.rb
429
+ - test/test-gqtp.rb
430
+ - test/test-schema-create-table.rb
431
+ - test/test-query-logger.rb
432
+ - test/test-pagination.rb
433
+ - test/test-expression-builder.rb
434
+ - test/test-table-group.rb
435
+ - test/test-schema.rb
436
+ - test/test-operator.rb
419
437
  - test/test-expression.rb
420
- - test/test-schema-dumper.rb
421
438
  - test/test-patricia-trie.rb
422
- - test/test-table-group.rb
439
+ - test/test-command-select.rb
440
+ - test/test-context.rb
441
+ - test/test-variable-size-column.rb
442
+ - test/test-variable.rb
443
+ - test/test-sub-records.rb
444
+ - test/test-index-cursor.rb
445
+ - test/test-double-array-trie.rb
423
446
  - test/test-table-select.rb
424
- - test/test-encoding.rb
425
447
  - test/test-windows-event-logger.rb
426
- - test/test-plugin.rb
427
- - test/test-table-select-normalize.rb
428
- - test/test-hash.rb
429
- - test/test-gqtp.rb
430
- - test/test-table-dumper.rb
431
- - test/test-pagination.rb
432
- - test/test-column.rb
433
448
  - test/test-table-traverse.rb
434
- - test/test-type.rb
435
- - test/test-package-label.rb
436
- - test/groonga-test-utils.rb
437
- - test/test-thread.rb
438
- - test/test-procedure.rb
439
- - test/test-query-logger.rb
449
+ - test/test-exception.rb
440
450
  - test/test-index-column.rb
451
+ - test/test-geo-point.rb
441
452
  - test/test-vector-column.rb
453
+ - test/test-lock-timeout.rb
454
+ - test/test-array.rb
455
+ - test/test-schema-dumper.rb
442
456
  - test/test-fix-size-column.rb
443
- - test/test-operator.rb
457
+ - test/test-table-select-mecab.rb
458
+ - test/test-procedure.rb
444
459
  - test/test-database-dumper.rb
445
- - test/run-test.rb
446
- - test/test-index-cursor.rb
447
- - test/test-schema-type.rb
448
- - test/test-database.rb
449
- - test/test-logger.rb
450
- - test/test-table.rb
460
+ - test/test-database-inspector.rb
461
+ - test/test-package-label.rb
462
+ - test/test-table-key-support.rb
463
+ - test/test-table-offset-and-limit.rb
464
+ - test/test-accessor.rb
465
+ - test/test-remote.rb
466
+ - test/test-plugin.rb
467
+ - test/groonga-test-utils.rb
468
+ - test/test-column.rb
451
469
  - test/test-record.rb
452
- - test/test-version.rb
453
- - test/test-table-select-mecab.rb
454
- - test/test-lock-timeout.rb
470
+ - test/test-hash.rb
471
+ - test/test-logger.rb
455
472
  - test/test-table-select-weight.rb
456
- - test/test-geo-point.rb
457
- - test/test-array.rb
458
- - test/test-sub-records.rb
459
- - test/test-schema-create-table.rb
460
- - test/test-schema.rb
461
- - test/test-command-select.rb
462
- - test/test-expression-builder.rb
463
- - test/test-convert.rb
464
- - test/test-memory-pool.rb
465
- - test/test-flushable.rb
466
- - test/test-table-offset-and-limit.rb
467
- - test/test-exception.rb
468
- - test/test-variable-size-column.rb
473
+ - test/test-version.rb
474
+ - test/test-table-select-normalize.rb
469
475
  - test/test-config.rb
470
- - test/test-table-key-support.rb
471
- - test/test-database-inspector.rb
472
- - test/test-variable.rb
473
- - test/test-statistic-measurer.rb
476
+ - test/test-flushable.rb
477
+ - test/test-encoding.rb
478
+ - test/test-thread.rb
474
479
  - test/test-snippet.rb
475
- - test/test-accessor.rb
480
+ - test/test-type.rb
481
+ - test/test-table.rb
482
+ - test/test-table-dumper.rb
483
+ - test/test-statistic-measurer.rb
484
+ - test/test-token-regexp.rb
476
485
  has_rdoc: