rroonga 3.0.5 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/AUTHORS +5 -0
  2. data/Gemfile +20 -0
  3. data/Rakefile +187 -0
  4. data/doc/text/news.textile +10 -2
  5. data/doc/text/tutorial.textile +0 -2
  6. data/ext/groonga/extconf.rb +7 -1
  7. data/ext/groonga/rb-grn-accessor.c +11 -11
  8. data/ext/groonga/rb-grn-array.c +25 -25
  9. data/ext/groonga/rb-grn-column.c +106 -106
  10. data/ext/groonga/rb-grn-context.c +121 -121
  11. data/ext/groonga/rb-grn-database.c +78 -78
  12. data/ext/groonga/rb-grn-double-array-trie.c +92 -92
  13. data/ext/groonga/rb-grn-encoding-support.c +1 -1
  14. data/ext/groonga/rb-grn-encoding.c +28 -28
  15. data/ext/groonga/rb-grn-exception.c +9 -9
  16. data/ext/groonga/rb-grn-expression-builder.c +6 -6
  17. data/ext/groonga/rb-grn-expression.c +87 -87
  18. data/ext/groonga/rb-grn-fix-size-column.c +12 -12
  19. data/ext/groonga/rb-grn-geo-point.c +2 -2
  20. data/ext/groonga/rb-grn-hash.c +38 -38
  21. data/ext/groonga/rb-grn-index-column.c +191 -191
  22. data/ext/groonga/rb-grn-index-cursor.c +29 -29
  23. data/ext/groonga/rb-grn-logger.c +36 -36
  24. data/ext/groonga/rb-grn-normalizer.c +10 -10
  25. data/ext/groonga/rb-grn-patricia-trie.c +196 -196
  26. data/ext/groonga/rb-grn-plugin.c +5 -5
  27. data/ext/groonga/rb-grn-posting.c +2 -2
  28. data/ext/groonga/rb-grn-procedure.c +2 -2
  29. data/ext/groonga/rb-grn-query-logger.c +1 -1
  30. data/ext/groonga/rb-grn-record.c +1 -1
  31. data/ext/groonga/rb-grn-snippet.c +14 -14
  32. data/ext/groonga/rb-grn-table-cursor-key-support.c +4 -4
  33. data/ext/groonga/rb-grn-table-cursor.c +52 -52
  34. data/ext/groonga/rb-grn-table-key-support.c +209 -209
  35. data/ext/groonga/rb-grn-type.c +18 -18
  36. data/ext/groonga/rb-grn-utils.c +332 -314
  37. data/ext/groonga/rb-grn-variable-size-column.c +34 -34
  38. data/ext/groonga/rb-grn-variable.c +2 -2
  39. data/ext/groonga/rb-grn.h +240 -232
  40. data/ext/groonga/rb-groonga.c +10 -10
  41. data/rroonga-build.rb +7 -0
  42. data/rroonga.gemspec +1 -1
  43. data/test/test-hash.rb +4 -4
  44. data/test/test-index-column.rb +271 -257
  45. data/test/test-table-key-support.rb +78 -0
  46. data/test/test-table.rb +78 -51
  47. metadata +195 -164
  48. checksums.yaml +0 -7
@@ -0,0 +1,78 @@
1
+ # Copyright (C) 2013 Kouhei Sutou <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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ class TableKeySupportTest < Test::Unit::TestCase
17
+ include GroongaTestUtils
18
+
19
+ setup :setup_database
20
+
21
+ class TypeTest < self
22
+ def test_int8
23
+ key = -1
24
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "Int8")
25
+ id = ids.add(key)
26
+ assert_equal(key, id.key)
27
+ end
28
+
29
+ def test_uint8
30
+ key = 1
31
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "UInt8")
32
+ id = ids.add(key)
33
+ assert_equal(key, id.key)
34
+ end
35
+
36
+ def test_int16
37
+ key = -(2 ** 8)
38
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "Int16")
39
+ id = ids.add(key)
40
+ assert_equal(key, id.key)
41
+ end
42
+
43
+ def test_uint16
44
+ key = 2 ** 8
45
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "UInt16")
46
+ id = ids.add(key)
47
+ assert_equal(key, id.key)
48
+ end
49
+
50
+ def test_int32
51
+ key = -(2 ** 16)
52
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "Int32")
53
+ id = ids.add(key)
54
+ assert_equal(key, id.key)
55
+ end
56
+
57
+ def test_uint32
58
+ key = 2 ** 16
59
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "UInt32")
60
+ id = ids.add(key)
61
+ assert_equal(key, id.key)
62
+ end
63
+
64
+ def test_int64
65
+ key = -(2 ** 32)
66
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "Int64")
67
+ id = ids.add(key)
68
+ assert_equal(key, id.key)
69
+ end
70
+
71
+ def test_uint64
72
+ key = 2 ** 32
73
+ ids = Groonga::Hash.create(:name => "IDs", :key_type => "UInt64")
74
+ id = ids.add(key)
75
+ assert_equal(key, id.key)
76
+ end
77
+ end
78
+ end
data/test/test-table.rb CHANGED
@@ -423,57 +423,6 @@ class TableTest < Test::Unit::TestCase
423
423
  sorted_bookmarks.collect(&:value))
424
424
  end
425
425
 
426
- def test_group
427
- bookmarks = Groonga::Hash.create(:name => "Bookmarks")
428
- bookmarks.define_column("title", "Text")
429
- comments = Groonga::Array.create(:name => "Comments")
430
- comments.define_column("bookmark", bookmarks)
431
- comments.define_column("content", "Text")
432
- comments.define_column("issued", "Int32")
433
-
434
- groonga = bookmarks.add("http://groonga.org/", :title => "groonga")
435
- ruby = bookmarks.add("http://ruby-lang.org/", :title => "Ruby")
436
-
437
- now = Time.now.to_i
438
- comments.add(:bookmark => groonga,
439
- :content => "full-text search",
440
- :issued => now)
441
- comments.add(:bookmark => groonga,
442
- :content => "column store",
443
- :issued => now)
444
- comments.add(:bookmark => ruby,
445
- :content => "object oriented script language",
446
- :issued => now)
447
-
448
- records = comments.select do |record|
449
- record["issued"] > 0
450
- end
451
- assert_equal([[2, "groonga", "http://groonga.org/"],
452
- [1, "Ruby", "http://ruby-lang.org/"]],
453
- records.group(".bookmark").collect do |record|
454
- bookmark = record.key
455
- [record.n_sub_records,
456
- bookmark["title"],
457
- bookmark.key]
458
- end)
459
- assert_equal([[2, "groonga", "http://groonga.org/"],
460
- [1, "Ruby", "http://ruby-lang.org/"]],
461
- records.group(%w".bookmark").collect do |record|
462
- bookmark = record.key
463
- [record.n_sub_records,
464
- bookmark["title"],
465
- bookmark.key]
466
- end)
467
- end
468
-
469
- def test_group_with_unknown_key
470
- bookmarks = Groonga::Hash.create(:name => "Bookmarks")
471
- message = "unknown group key: <\"nonexistent\">: <#{bookmarks.inspect}>"
472
- assert_raise(ArgumentError.new(message)) do
473
- bookmarks.group("nonexistent")
474
- end
475
- end
476
-
477
426
  def test_union!
478
427
  bookmarks = Groonga::Hash.create(:name => "Bookmarks")
479
428
  bookmarks.define_column("title", "ShortText")
@@ -783,6 +732,84 @@ class TableTest < Test::Unit::TestCase
783
732
  groups)
784
733
  end
785
734
  end
735
+
736
+ class KeyTest < self
737
+ setup
738
+ def setup_schema
739
+ Groonga::Schema.define do |schema|
740
+ schema.create_table("Bookmarks", :type => :hash) do |table|
741
+ table.text("title")
742
+ end
743
+
744
+ schema.create_table("Comments", :type => :array) do |table|
745
+ table.reference("bookmark")
746
+ table.text("content")
747
+ table.int32("rank")
748
+ end
749
+ end
750
+ end
751
+
752
+ setup
753
+ def setup_data
754
+ setup_bookmarks
755
+ setup_comments
756
+ end
757
+
758
+ def setup_bookmarks
759
+ @bookmarks = Groonga["Bookmarks"]
760
+ @groonga = @bookmarks.add("http://groonga.org/", :title => "groonga")
761
+ @ruby = @bookmarks.add("http://ruby-lang.org/", :title => "Ruby")
762
+ end
763
+
764
+ def setup_comments
765
+ @comments = Groonga["Comments"]
766
+ @comments.add(:bookmark => @groonga,
767
+ :content => "full-text search")
768
+ @comments.add(:bookmark => @groonga,
769
+ :content => "column store")
770
+ @comments.add(:bookmark => @ruby,
771
+ :content => "object oriented script language")
772
+ end
773
+
774
+ def test_string
775
+ grouped_records = @comments.group("bookmark").collect do |record|
776
+ bookmark = record.key
777
+ [
778
+ record.n_sub_records,
779
+ bookmark["title"],
780
+ bookmark.key,
781
+ ]
782
+ end
783
+ assert_equal([
784
+ [2, "groonga", "http://groonga.org/"],
785
+ [1, "Ruby", "http://ruby-lang.org/"],
786
+ ],
787
+ grouped_records)
788
+ end
789
+
790
+ def test_array
791
+ grouped_records = @comments.group(["bookmark"]).collect do |record|
792
+ bookmark = record.key
793
+ [
794
+ record.n_sub_records,
795
+ bookmark["title"],
796
+ bookmark.key,
797
+ ]
798
+ end
799
+ assert_equal([
800
+ [2, "groonga", "http://groonga.org/"],
801
+ [1, "Ruby", "http://ruby-lang.org/"],
802
+ ],
803
+ grouped_records)
804
+ end
805
+
806
+ def test_nonexistent
807
+ message = "unknown group key: <\"nonexistent\">: <#{@comments.inspect}>"
808
+ assert_raise(ArgumentError.new(message)) do
809
+ @comments.group("nonexistent")
810
+ end
811
+ end
812
+ end
786
813
  end
787
814
 
788
815
  class OtherProcessTest < self