rroonga 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/NEWS.ja.rdoc +47 -0
  2. data/NEWS.rdoc +48 -0
  3. data/README.ja.rdoc +1 -0
  4. data/README.rdoc +1 -0
  5. data/Rakefile +32 -13
  6. data/benchmark/create-wikipedia-database.rb +212 -0
  7. data/benchmark/repeat-load.rb +213 -0
  8. data/benchmark/select.rb +1052 -0
  9. data/ext/groonga/mkmf.log +99 -0
  10. data/ext/groonga/rb-grn-column.c +57 -6
  11. data/ext/groonga/rb-grn-context.c +15 -9
  12. data/ext/groonga/rb-grn-expression.c +7 -7
  13. data/ext/groonga/{rb-grn-operation.c → rb-grn-operator.c} +89 -87
  14. data/ext/groonga/rb-grn-patricia-trie.c +5 -5
  15. data/ext/groonga/rb-grn-query.c +4 -4
  16. data/ext/groonga/rb-grn-table.c +16 -19
  17. data/ext/groonga/rb-grn.h +3 -3
  18. data/ext/groonga/rb-groonga.c +1 -1
  19. data/html/index.html +4 -4
  20. data/lib/groonga/context.rb +34 -0
  21. data/lib/groonga/expression-builder.rb +34 -2
  22. data/lib/groonga/record.rb +8 -6
  23. data/lib/groonga/schema.rb +40 -4
  24. data/rroonga-build.rb +2 -2
  25. data/test-unit/Rakefile +5 -18
  26. data/test-unit/html/classic.html +15 -0
  27. data/test-unit/html/index.html +13 -235
  28. data/test-unit/html/index.html.ja +15 -258
  29. data/test-unit/lib/test/unit.rb +1 -6
  30. data/test-unit/lib/test/unit/assertions.rb +11 -115
  31. data/test-unit/lib/test/unit/autorunner.rb +2 -5
  32. data/test-unit/lib/test/unit/collector/load.rb +1 -1
  33. data/test-unit/lib/test/unit/color-scheme.rb +2 -6
  34. data/test-unit/lib/test/unit/diff.rb +1 -17
  35. data/test-unit/lib/test/unit/testcase.rb +0 -7
  36. data/test-unit/lib/test/unit/testresult.rb +2 -34
  37. data/test-unit/lib/test/unit/ui/console/testrunner.rb +45 -9
  38. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +12 -2
  39. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -25
  40. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -1
  41. data/test-unit/lib/test/unit/version.rb +1 -1
  42. data/test-unit/test/test-color-scheme.rb +2 -4
  43. data/test-unit/test/test_assertions.rb +5 -51
  44. data/test/test-column.rb +31 -1
  45. data/test/test-context-select.rb +45 -14
  46. data/test/test-context.rb +36 -0
  47. data/test/test-database.rb +13 -0
  48. data/test/test-expression-builder.rb +32 -5
  49. data/test/test-record.rb +34 -1
  50. data/test/test-schema.rb +52 -2
  51. data/test/test-table-select-weight.rb +20 -1
  52. data/test/test-table.rb +58 -0
  53. metadata +13 -41
  54. data/test-unit-notify/Rakefile +0 -47
  55. data/test-unit-notify/lib/test/unit/notify.rb +0 -104
  56. data/test-unit/COPYING +0 -56
  57. data/test-unit/GPL +0 -340
  58. data/test-unit/PSFL +0 -271
  59. data/test-unit/html/bar.svg +0 -153
  60. data/test-unit/html/developer.svg +0 -469
  61. data/test-unit/html/favicon.ico +0 -0
  62. data/test-unit/html/favicon.svg +0 -82
  63. data/test-unit/html/heading-mark.svg +0 -393
  64. data/test-unit/html/install.svg +0 -636
  65. data/test-unit/html/logo.svg +0 -483
  66. data/test-unit/html/test-unit.css +0 -339
  67. data/test-unit/html/tutorial.svg +0 -559
  68. data/test-unit/lib/test/unit/util/output.rb +0 -31
  69. data/test-unit/test/ui/test_tap.rb +0 -33
  70. data/test-unit/test/util/test-output.rb +0 -11
data/test/test-record.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -77,6 +77,39 @@ class RecordTest < Test::Unit::TestCase
77
77
  assert_false(groonga.have_column?(:nonexistent))
78
78
  end
79
79
 
80
+ def test_have_column_id
81
+ groonga = @bookmarks.add
82
+ assert_true(groonga.have_column?(:_id))
83
+ end
84
+
85
+ def test_have_column_key_hash
86
+ mori = @users.add("mori")
87
+ assert_true(mori.have_column?(:_key))
88
+ end
89
+
90
+ def test_have_column_key_array_with_value_type
91
+ groonga = @bookmarks.add
92
+ assert_true(groonga.have_column?(:_key))
93
+ end
94
+
95
+ def test_have_column_key_array_without_value_type
96
+ groonga_ml = @addresses.add
97
+ assert_false(groonga_ml.have_column?(:_key))
98
+ end
99
+
100
+ def test_have_column_nsubrecs_existent
101
+ @users.add("mori")
102
+ bookmarks = @users.select do |record|
103
+ record.key == "mori"
104
+ end
105
+ assert_true(bookmarks.to_a.first.have_column?(:_nsubrecs))
106
+ end
107
+
108
+ def test_have_column_nsubrecs_nonexistent
109
+ groonga = @bookmarks.add
110
+ assert_false(groonga.have_column?(:_nsubrecs))
111
+ end
112
+
80
113
  def test_get_nonexistent_column
81
114
  groonga = @bookmarks.add
82
115
  assert_raise(Groonga::NoSuchColumn) do
data/test/test-schema.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -485,7 +485,9 @@ EOS
485
485
 
486
486
  schema.create_table("Terms",
487
487
  :type => :patricia_trie,
488
- :key_type => "ShortText") do |table|
488
+ :key_type => "ShortText",
489
+ :key_normalize => true,
490
+ :default_tokenizer => "TokenBigram") do |table|
489
491
  table.index("Items", "_key")
490
492
  table.index("Items", "title")
491
493
  end
@@ -502,6 +504,8 @@ end
502
504
  create_table("Terms",
503
505
  :type => :patricia_trie,
504
506
  :key_type => "ShortText",
507
+ :key_normalize => true,
508
+ :default_tokenizer => "TokenBigram",
505
509
  :force => true) do |table|
506
510
  end
507
511
 
@@ -533,4 +537,50 @@ EOS
533
537
  assert_nil(Groonga::Context.default["Items.text"])
534
538
  assert_nil(Groonga::Context.default["TermsText.Items_text"])
535
539
  end
540
+
541
+ def test_columns_directory_removed
542
+ table = "Posts"
543
+ dir = create_table_with_column(table)
544
+
545
+ Groonga::Schema.remove_table(table)
546
+
547
+ assert_table_removed(table)
548
+ assert_directory_removed(dir)
549
+ end
550
+
551
+ def test_columns_directory_not_removed
552
+ table = "Posts"
553
+ dir = create_table_with_column(table)
554
+
555
+ Groonga::Context.default[table].remove
556
+
557
+ assert_table_removed(table)
558
+ assert_directory_not_removed(dir)
559
+ end
560
+
561
+ private
562
+ def columns_directory_path(table)
563
+ "#{table.path}.columns"
564
+ end
565
+
566
+ def create_table_with_column(name)
567
+ Groonga::Schema.create_table(name) do |table|
568
+ table.integer64 :rate
569
+ end
570
+ context = Groonga::Context.default
571
+ columns_directory_path(context[name])
572
+ end
573
+
574
+ def assert_directory_removed(dir)
575
+ assert_false(File.exist?(dir))
576
+ end
577
+
578
+ def assert_directory_not_removed(dir)
579
+ assert_true(File.exist?(dir))
580
+ end
581
+
582
+ def assert_table_removed(name)
583
+ context = Groonga::Context.default
584
+ assert_nil(context[name])
585
+ end
536
586
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2010-2011 Kouhei Sutou <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
@@ -42,6 +42,11 @@ class TableSelectWeightTest < Test::Unit::TestCase
42
42
  table.index("Comments.content", :with_section => true)
43
43
  end
44
44
 
45
+ schema.create_table("Titles",
46
+ :type => :hash) do |table|
47
+ table.index("Comments.title")
48
+ end
49
+
45
50
  schema.change_table("Users") do |table|
46
51
  table.index("Comments.user")
47
52
  end
@@ -101,4 +106,18 @@ class TableSelectWeightTest < Test::Unit::TestCase
101
106
  [record.title, record.score]
102
107
  end
103
108
  end
109
+
110
+ def test_index
111
+ result = @comments.select do |record|
112
+ record.match("Hello") do |match_record|
113
+ (match_record.index("Titles.Comments_title") * 1000) |
114
+ (match_record.index("Terms.Comments_title") * 100) |
115
+ match_record.content
116
+ end
117
+ end
118
+ assert_equal_select_result([["Hello", 1101], ["(no title)", 3]],
119
+ result) do |record|
120
+ [record.title, record.score]
121
+ end
122
+ end
104
123
  end
data/test/test-table.rb CHANGED
@@ -594,6 +594,64 @@ class TableTest < Test::Unit::TestCase
594
594
  assert_false(users.have_column?("description"), "description")
595
595
  end
596
596
 
597
+ def test_have_column_id
598
+ users = Groonga::Array.create(:name => "Users")
599
+ assert_true(users.have_column?(:_id))
600
+ end
601
+
602
+ def test_have_column_key_hash
603
+ users = Groonga::Hash.create(:name => "Users",
604
+ :key_type => "ShortText")
605
+ assert_true(users.have_column?(:_key))
606
+ end
607
+
608
+ def test_have_column_key_array
609
+ users = Groonga::Array.create(:name => "Users")
610
+ assert_false(users.have_column?(:_key))
611
+ end
612
+
613
+ def test_have_column_value_hash_with_value_type
614
+ users = Groonga::Hash.create(:name => "Users",
615
+ :key_type => "ShortText",
616
+ :value_type => "Int32")
617
+ assert_true(users.have_column?(:_value))
618
+ end
619
+
620
+ def test_have_column_value_hash_without_value_type
621
+ users = Groonga::Hash.create(:name => "Users",
622
+ :key_type => "ShortText")
623
+ assert_false(users.have_column?(:_value))
624
+ end
625
+
626
+ def test_have_column_value_array
627
+ users = Groonga::Array.create(:name => "Users")
628
+ assert_false(users.have_column?(:_value))
629
+ end
630
+
631
+ def test_have_column_nsubrecs_existent
632
+ users = Groonga::Hash.create(:name => "Users",
633
+ :key_type => "ShortText")
634
+ assert_true(users.select.have_column?(:_nsubrecs))
635
+ end
636
+
637
+ def test_have_column_nsubrecs_nonexistent
638
+ users = Groonga::Hash.create(:name => "Users",
639
+ :key_type => "ShortText")
640
+ assert_false(users.have_column?(:_nsubrecs))
641
+ end
642
+
643
+ def test_have_column_score_existent
644
+ users = Groonga::Hash.create(:name => "Users",
645
+ :key_type => "ShortText")
646
+ assert_true(users.select.have_column?(:_score))
647
+ end
648
+
649
+ def test_have_column_score_nonexistent
650
+ users = Groonga::Hash.create(:name => "Users",
651
+ :key_type => "ShortText")
652
+ assert_false(users.have_column?(:_score))
653
+ end
654
+
597
655
  def test_exist?
598
656
  users = Groonga::Hash.create(:name => "Users")
599
657
  morita = users.add("morita")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rroonga
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 8
10
- version: 1.0.8
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kouhei Sutou
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-12-25 00:00:00 +09:00
22
+ date: 2011-01-28 00:00:00 +09:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -38,22 +38,6 @@ dependencies:
38
38
  version: 1.0.7
39
39
  type: :runtime
40
40
  version_requirements: *id001
41
- - !ruby/object:Gem::Dependency
42
- name: rubyforge
43
- prerelease: false
44
- requirement: &id002 !ruby/object:Gem::Requirement
45
- none: false
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- hash: 7
50
- segments:
51
- - 2
52
- - 0
53
- - 4
54
- version: 2.0.4
55
- type: :development
56
- version_requirements: *id002
57
41
  description: |-
58
42
  rroonga is a extension library to use groonga's DB-API
59
43
  layer. rroonga provides Rubyish readable and writable
@@ -67,12 +51,12 @@ executables: []
67
51
  extensions:
68
52
  - extconf.rb
69
53
  extra_rdoc_files:
54
+ - README.ja.rdoc
55
+ - NEWS.ja.rdoc
70
56
  - text/tutorial.ja.rdoc
71
57
  - text/expression.rdoc
72
- - NEWS.rdoc
73
58
  - README.rdoc
74
- - README.ja.rdoc
75
- - NEWS.ja.rdoc
59
+ - NEWS.rdoc
76
60
  files:
77
61
  - AUTHORS
78
62
  - NEWS.ja.rdoc
@@ -81,7 +65,10 @@ files:
81
65
  - README.rdoc
82
66
  - Rakefile
83
67
  - benchmark/common.rb
68
+ - benchmark/create-wikipedia-database.rb
84
69
  - benchmark/read-write-many-small-items.rb
70
+ - benchmark/repeat-load.rb
71
+ - benchmark/select.rb
85
72
  - benchmark/write-many-small-items.rb
86
73
  - example/bookmark.rb
87
74
  - example/index-html.rb
@@ -90,6 +77,7 @@ files:
90
77
  - ext/.gitignore
91
78
  - ext/groonga/extconf.rb
92
79
  - ext/groonga/groonga.def
80
+ - ext/groonga/mkmf.log
93
81
  - ext/groonga/rb-grn-accessor.c
94
82
  - ext/groonga/rb-grn-array-cursor.c
95
83
  - ext/groonga/rb-grn-array.c
@@ -107,7 +95,7 @@ files:
107
95
  - ext/groonga/rb-grn-index-column.c
108
96
  - ext/groonga/rb-grn-logger.c
109
97
  - ext/groonga/rb-grn-object.c
110
- - ext/groonga/rb-grn-operation.c
98
+ - ext/groonga/rb-grn-operator.c
111
99
  - ext/groonga/rb-grn-patricia-trie-cursor.c
112
100
  - ext/groonga/rb-grn-patricia-trie.c
113
101
  - ext/groonga/rb-grn-procedure.c
@@ -156,25 +144,12 @@ files:
156
144
  - license/LGPL
157
145
  - misc/grnop2ruby.rb
158
146
  - rroonga-build.rb
159
- - test-unit-notify/Rakefile
160
- - test-unit-notify/lib/test/unit/notify.rb
161
- - test-unit/COPYING
162
- - test-unit/GPL
163
- - test-unit/PSFL
164
147
  - test-unit/Rakefile
165
148
  - test-unit/TODO
166
149
  - test-unit/bin/testrb
167
- - test-unit/html/bar.svg
168
- - test-unit/html/developer.svg
169
- - test-unit/html/favicon.ico
170
- - test-unit/html/favicon.svg
171
- - test-unit/html/heading-mark.svg
150
+ - test-unit/html/classic.html
172
151
  - test-unit/html/index.html
173
152
  - test-unit/html/index.html.ja
174
- - test-unit/html/install.svg
175
- - test-unit/html/logo.svg
176
- - test-unit/html/test-unit.css
177
- - test-unit/html/tutorial.svg
178
153
  - test-unit/lib/test/unit.rb
179
154
  - test-unit/lib/test/unit/assertionfailederror.rb
180
155
  - test-unit/lib/test/unit/assertions.rb
@@ -212,7 +187,6 @@ files:
212
187
  - test-unit/lib/test/unit/util/backtracefilter.rb
213
188
  - test-unit/lib/test/unit/util/method-owner-finder.rb
214
189
  - test-unit/lib/test/unit/util/observable.rb
215
- - test-unit/lib/test/unit/util/output.rb
216
190
  - test-unit/lib/test/unit/util/procwrapper.rb
217
191
  - test-unit/lib/test/unit/version.rb
218
192
  - test-unit/sample/adder.rb
@@ -242,10 +216,8 @@ files:
242
216
  - test-unit/test/test_testresult.rb
243
217
  - test-unit/test/test_testsuite.rb
244
218
  - test-unit/test/testunit-test-util.rb
245
- - test-unit/test/ui/test_tap.rb
246
219
  - test-unit/test/ui/test_testrunmediator.rb
247
220
  - test-unit/test/util/test-method-owner-finder.rb
248
- - test-unit/test/util/test-output.rb
249
221
  - test-unit/test/util/test_backtracefilter.rb
250
222
  - test-unit/test/util/test_observable.rb
251
223
  - test-unit/test/util/test_procwrapper.rb
@@ -1,47 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'pathname'
4
-
5
- base_dir = Pathname(__FILE__).dirname.expand_path
6
- test_unit_dir = (base_dir.parent + "test-unit").expand_path
7
- test_unit_lib_dir = test_unit_dir + "lib"
8
- lib_dir = base_dir + "lib"
9
-
10
- $LOAD_PATH.unshift(test_unit_lib_dir.to_s)
11
- $LOAD_PATH.unshift(lib_dir.to_s)
12
-
13
- require 'test/unit/notify'
14
-
15
- require 'rubygems'
16
- require 'hoe'
17
-
18
- Test::Unit.run = true
19
-
20
- version = Test::Unit::Notify::VERSION
21
- ENV["VERSION"] = version
22
- Hoe.spec('test-unit-notify') do
23
- self.version = version
24
- self.rubyforge_name = "test-unit"
25
-
26
- developer('Kouhei Sutou', 'kou@clear-code.com')
27
-
28
- extra_deps << ["test-unit"]
29
- end
30
-
31
- task :docs do
32
- doc_dir = base_dir + "doc"
33
- doc_screenshot_dir = doc_dir + "screenshot"
34
- mkdir_p(doc_screenshot_dir.to_s)
35
- (base_dir + "screenshot").children.each do |file|
36
- next if file.directory?
37
- cp(file.to_s, doc_screenshot_dir.to_s)
38
- end
39
- end
40
-
41
- task :tag do
42
- message = "Released Test::Unit::Notify #{version}!"
43
- base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit/extensions/test-unit-notify/"
44
- sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
45
- end
46
-
47
- # vim: syntax=Ruby
@@ -1,104 +0,0 @@
1
- #--
2
- #
3
- # Author:: Kouhei Sutou
4
- # Copyright::
5
- # * Copyright (c) 2010 Kouhei Sutou <kou@clear-code.com>
6
- # License:: Ruby license.
7
-
8
- require 'pathname'
9
- require 'erb'
10
- require 'test/unit'
11
-
12
- module Test
13
- module Unit
14
- AutoRunner.setup_option do |auto_runner, options|
15
- options.on("--[no-]notify",
16
- "Notify test result at the last.") do |use_notify|
17
- auto_runner.listeners.reject! do |listener|
18
- listener.is_a?(Notify::Notifier)
19
- end
20
- auto_runner.listeners << Notify::Notifier.new if use_notify
21
- end
22
- end
23
-
24
- module Notify
25
- VERSION = "0.0.2"
26
-
27
- class Notifier
28
- include ERB::Util
29
-
30
- base_dir = Pathname(__FILE__).dirname.parent.parent.parent.expand_path
31
- ICON_DIR = base_dir + "data" + "icons"
32
- def initialize
33
- @theme = "kinotan"
34
- end
35
-
36
- def attach_to_mediator(mediator)
37
- mediator.add_listener(UI::TestRunnerMediator::STARTED,
38
- &method(:started))
39
- mediator.add_listener(UI::TestRunnerMediator::FINISHED,
40
- &method(:finished))
41
- end
42
-
43
- def started(result)
44
- @result = result
45
- end
46
-
47
- def finished(elapsed_time)
48
- case RUBY_PLATFORM
49
- when /mswin|mingw|cygwin/
50
- # how?
51
- when /darwin/
52
- # growl?
53
- else
54
- notify_by_notify_send(elapsed_time)
55
- end
56
- end
57
-
58
- def notify_by_notify_send(elapsed_time)
59
- icon = guess_suitable_icon
60
- args = ["notify-send",
61
- "--expire-time", "5000",
62
- "--urgency", urgency]
63
- args.concat(["--icon", icon.to_s]) if icon
64
- title = "%s [%g%%] (%gs)" % [@result.status,
65
- @result.pass_percentage,
66
- elapsed_time]
67
- args << title
68
- args << h(@result.summary)
69
- system(*args)
70
- end
71
-
72
- def guess_suitable_icon
73
- icon_dir = ICON_DIR + @theme
74
- status = @result.status
75
- icon_base_names = [status]
76
- if @result.passed?
77
- icon_base_names << "pass"
78
- else
79
- case status
80
- when "failure"
81
- icon_base_names << "error"
82
- when "error"
83
- icon_base_names << "failure"
84
- end
85
- end
86
- icon_base_names << "default"
87
- icon_base_names.each do |base_name|
88
- icon = icon_dir + "#{base_name}.png"
89
- return icon if icon.exist?
90
- end
91
- nil
92
- end
93
-
94
- def urgency
95
- if @result.passed?
96
- "normal"
97
- else
98
- "critical"
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end