rroonga 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. data/AUTHORS +5 -0
  2. data/Gemfile +1 -12
  3. data/Rakefile +4 -57
  4. data/bin/grndump +11 -1
  5. data/ext/groonga/extconf.rb +125 -54
  6. data/ext/groonga/rb-grn-context.c +25 -7
  7. data/ext/groonga/rb-grn-database.c +25 -0
  8. data/ext/groonga/rb-grn-object.c +19 -7
  9. data/ext/groonga/rb-grn-table.c +8 -10
  10. data/ext/groonga/rb-grn.h +9 -2
  11. data/lib/groonga/dumper.rb +2 -2
  12. data/lib/groonga/expression-builder.rb +33 -18
  13. data/rroonga-build.rb +1 -1
  14. metadata +97 -180
  15. data/TODO +0 -0
  16. data/test/groonga-test-utils.rb +0 -139
  17. data/test/run-test.rb +0 -60
  18. data/test/test-accessor.rb +0 -36
  19. data/test/test-array.rb +0 -123
  20. data/test/test-column.rb +0 -350
  21. data/test/test-command-select.rb +0 -147
  22. data/test/test-context.rb +0 -130
  23. data/test/test-database-dumper.rb +0 -259
  24. data/test/test-database.rb +0 -148
  25. data/test/test-double-array-trie.rb +0 -164
  26. data/test/test-encoding.rb +0 -33
  27. data/test/test-exception.rb +0 -96
  28. data/test/test-expression-builder.rb +0 -269
  29. data/test/test-expression.rb +0 -134
  30. data/test/test-fix-size-column.rb +0 -77
  31. data/test/test-gqtp.rb +0 -70
  32. data/test/test-hash.rb +0 -344
  33. data/test/test-index-column.rb +0 -180
  34. data/test/test-index-cursor.rb +0 -93
  35. data/test/test-logger.rb +0 -37
  36. data/test/test-pagination.rb +0 -249
  37. data/test/test-patricia-trie.rb +0 -415
  38. data/test/test-plugin.rb +0 -35
  39. data/test/test-procedure.rb +0 -37
  40. data/test/test-query-log.rb +0 -258
  41. data/test/test-record.rb +0 -569
  42. data/test/test-remote.rb +0 -63
  43. data/test/test-schema-create-table.rb +0 -267
  44. data/test/test-schema-dumper.rb +0 -235
  45. data/test/test-schema-type.rb +0 -208
  46. data/test/test-schema-view.rb +0 -90
  47. data/test/test-schema.rb +0 -886
  48. data/test/test-snippet.rb +0 -130
  49. data/test/test-table-cursor.rb +0 -187
  50. data/test/test-table-dumper.rb +0 -83
  51. data/test/test-table-offset-and-limit.rb +0 -100
  52. data/test/test-table-select-mecab.rb +0 -80
  53. data/test/test-table-select-normalize.rb +0 -57
  54. data/test/test-table-select-weight.rb +0 -123
  55. data/test/test-table-select.rb +0 -191
  56. data/test/test-table.rb +0 -675
  57. data/test/test-type.rb +0 -79
  58. data/test/test-variable-size-column.rb +0 -147
  59. data/test/test-variable.rb +0 -28
  60. data/test/test-vector-column.rb +0 -76
  61. data/test/test-version.rb +0 -61
  62. data/test/test-view.rb +0 -72
data/test/test-type.rb DELETED
@@ -1,79 +0,0 @@
1
- # Copyright (C) 2009-2012 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 TypeTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :setup_database
20
-
21
- def test_new
22
- type = Groonga::Type.new("user_id", :type => :integer)
23
- assert_equal("user_id", type.name)
24
- end
25
-
26
- def test_new_with_space_name
27
- exception = assert_raise(Groonga::InvalidArgument) do
28
- Groonga::Type.new("user id", :type => :integer)
29
- end
30
- message =
31
- "name can't start with '_' and contains only 0-9, A-Z, a-z, #, @, - or _"
32
- assert_match(/#{Regexp.escape(message)}/,
33
- exception.message)
34
- end
35
-
36
- def test_builtins
37
- assert_equal_type("Object", Groonga::Type::OBJECT) # FIXME!!!
38
- assert_equal_type("Bool", Groonga::Type::BOOLEAN)
39
- assert_equal_type("Bool", Groonga::Type::BOOL)
40
- assert_equal_type("Int8", Groonga::Type::INT8)
41
- assert_equal_type("UInt8", Groonga::Type::UINT8)
42
- assert_equal_type("Int16", Groonga::Type::INT16)
43
- assert_equal_type("UInt16", Groonga::Type::UINT16)
44
- assert_equal_type("Int32", Groonga::Type::INT32)
45
- assert_equal_type("UInt32", Groonga::Type::UINT32)
46
- assert_equal_type("Int64", Groonga::Type::INT64)
47
- assert_equal_type("UInt64", Groonga::Type::UINT64)
48
- assert_equal_type("Float", Groonga::Type::FLOAT)
49
- assert_equal_type("Time", Groonga::Type::TIME)
50
- assert_equal_type("ShortText", Groonga::Type::SHORT_TEXT)
51
- assert_equal_type("Text", Groonga::Type::TEXT)
52
- assert_equal_type("LongText", Groonga::Type::LONG_TEXT)
53
- end
54
-
55
- def test_inspect
56
- assert_equal("#<Groonga::Type id: <#{Groonga::Type::LONG_TEXT}>, " +
57
- "name: <LongText>, " +
58
- "path: (temporary), " +
59
- "domain: (nil), " +
60
- "range: <2147483648>, " +
61
- "flags: <>>",
62
- context["<longtext>"].inspect)
63
- end
64
-
65
- data("builtin - Int32" => "Int32",
66
- "builtin - ShortText" => "ShortText",
67
- "builtin - Time" => "Time")
68
- def test_builtin?(name)
69
- type = Groonga[name]
70
- assert_predicate(type, :builtin?)
71
- end
72
-
73
- private
74
- def assert_equal_type(expected_name, id)
75
- type = Groonga[id]
76
- assert_equal(expected_name,
77
- type ? type.name : type)
78
- end
79
- end
@@ -1,147 +0,0 @@
1
- # Copyright (C) 2009-2011 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 VariableSizeColumnTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- def setup
20
- setup_database
21
-
22
- setup_users_table
23
- setup_users
24
- end
25
-
26
- def setup_users_table
27
- @users_path = @tables_dir + "users"
28
- @users = Groonga::Array.create(:name => "Users",
29
- :path => @users_path.to_s)
30
-
31
- @users_name_column_path = @columns_dir + "name"
32
- @name = @users.define_column("name", "ShortText",
33
- :path => @users_name_column_path.to_s)
34
-
35
- @users_friends_column_path = @columns_dir + "friends"
36
- @friends = @users.define_column("friends", @users,
37
- :type => :vector,
38
- :path => @users_friends_column_path.to_s)
39
-
40
- @users_nick_names_column_path = @columns_dir + "nick_names"
41
- @nick_names =
42
- @users.define_column("nick_names", "ShortText",
43
- :type => :vector,
44
- :path => @users_nick_names_column_path.to_s)
45
- end
46
-
47
- def setup_users
48
- @morita = @users.add(:name => "mori daijiro")
49
- @gunyara_kun = @users.add(:name => "Tasuku SUENAGA")
50
- @yu = @users.add(:name => "Yutaro Shimamura")
51
- end
52
-
53
- def test_index?
54
- assert_not_predicate(@nick_names, :index?)
55
- end
56
-
57
- def test_vector?
58
- assert_predicate(@nick_names, :vector?)
59
- end
60
-
61
- def test_scalar?
62
- assert_not_predicate(@nick_names, :scalar?)
63
- end
64
-
65
- def test_compressed?
66
- description = @users.define_column("description", "ShortText",
67
- :compress => :zlib)
68
- if context.support_zlib?
69
- assert_predicate(description, :compressed?)
70
- else
71
- assert_not_predicate(description, :compressed?)
72
- end
73
- end
74
-
75
- def test_compressed_zlib?
76
- description = @users.define_column("description", "ShortText",
77
- :compress => :zlib)
78
- if context.support_zlib?
79
- assert_send([description, :compressed?, :zlib])
80
- else
81
- assert_not_send([description, :compressed?, :zlib])
82
- end
83
- end
84
-
85
- def test_compressed_lzo?
86
- description = @users.define_column("description", "ShortText",
87
- :compress => :lzo)
88
- if context.support_lzo?
89
- assert_send([description, :compressed?, :lzo])
90
- else
91
- assert_not_send([description, :compressed?, :lzo])
92
- end
93
- end
94
-
95
- def test_inspect
96
- assert_equal("#<Groonga::VariableSizeColumn " +
97
- "id: <#{@name.id}>, " +
98
- "name: <Users.name>, " +
99
- "path: <#{@users_name_column_path}>, " +
100
- "domain: <Users>, " +
101
- "range: <ShortText>, " +
102
- "flags: <>" +
103
- ">",
104
- @name.inspect)
105
- end
106
-
107
- def test_domain
108
- assert_equal(@users, @name.domain)
109
- end
110
-
111
- def test_table
112
- assert_equal(@users, @name.table)
113
- end
114
-
115
- def test_vector_append
116
- assert_equal([], @morita["friends"])
117
- @morita.append("friends", @yu)
118
- assert_equal([@yu], @morita["friends"])
119
- @morita.append("friends", @gunyara_kun)
120
- assert_equal([@yu, @gunyara_kun], @morita["friends"])
121
- end
122
-
123
- def test_vector_prepend
124
- assert_equal([], @morita["friends"])
125
- @morita.prepend("friends", @yu)
126
- assert_equal([@yu], @morita["friends"])
127
- @morita.prepend("friends", @gunyara_kun)
128
- assert_equal([@gunyara_kun, @yu], @morita["friends"])
129
- end
130
-
131
- def test_string_vector
132
- omit("append/prepend for non table domain column " +
133
- "isn't supported by groonga.")
134
- assert_equal([], @morita["nick_names"])
135
- @morita.append("nick_names", "morita")
136
- assert_equal(["morita"], @morita["nick_names"])
137
- @morita.prepend("nick_names", "moritapo")
138
- assert_equal(["moritapo", "morita"], @morita["nick_names"])
139
- end
140
-
141
- def test_defrag
142
- 1000.times do |i|
143
- @users.add(:name => "user #{i}" * 1000)
144
- end
145
- assert_equal(3, @name.defrag)
146
- end
147
- end
@@ -1,28 +0,0 @@
1
- # Copyright (C) 2009 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 VariableTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :setup_database
20
-
21
- def test_value
22
- expression = Groonga::Expression.new
23
- variable = expression.define_variable
24
- assert_nil(variable.value)
25
- variable.value = "morita"
26
- assert_equal("morita", variable.value)
27
- end
28
- end
@@ -1,76 +0,0 @@
1
- # Copyright (C) 2010 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 VectorColumnTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- def setup
20
- setup_database
21
- setup_tables
22
- end
23
-
24
- def setup_tables
25
- Groonga::Schema.define do |schema|
26
- schema.create_table("Users",
27
- :type => :hash,
28
- :key_type => "UInt32") do |table|
29
- end
30
-
31
- schema.create_table("Communities",
32
- :type => :hash,
33
- :key_type => "ShortText") do |table|
34
- table.reference("users", "Users", :type => :vector)
35
- end
36
-
37
- schema.create_table("Areas",
38
- :type => :hash,
39
- :key_type => "ShortText") do |table|
40
- table.reference("communities", "Communities", :type => :vector)
41
- end
42
- end
43
-
44
- @users = Groonga::Context.default["Users"]
45
- @communities = Groonga::Context.default["Communities"]
46
- @areas = Groonga::Context.default["Areas"]
47
- end
48
-
49
- def test_set_records
50
- groonga = @communities.add("groonga")
51
- morita = @users.add(29)
52
- groonga["users"] = [morita]
53
-
54
- assert_equal([29], @users.collect {|record| record.key})
55
- assert_equal([29], groonga["users"].collect {|record| record.key})
56
- end
57
-
58
- def test_set_nonexistent_keys
59
- shinjuku = @areas.add("Shinjuku")
60
- shinjuku["communities"] = ["groonga", "Senna"]
61
-
62
- assert_equal(["groonga", "Senna"],
63
- @communities.collect {|record| record.key})
64
- assert_equal(["groonga", "Senna"],
65
- shinjuku["communities"].collect {|record| record.key})
66
- end
67
-
68
- def test_set_nil
69
- groonga = @communities.add("groonga")
70
- assert_equal([], groonga["users"])
71
- groonga["users"] = nil
72
- assert_equal([], groonga["users"]) # should return nil?
73
- # Can groonga tell us
74
- # that the value is empty?
75
- end
76
- end
data/test/test-version.rb DELETED
@@ -1,61 +0,0 @@
1
- # Copyright (C) 2009-2012 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 VersionTest < Test::Unit::TestCase
17
- def test_build_version_format
18
- assert_equal("X.X.X", normalize(Groonga.build_version))
19
- end
20
-
21
- def test_build_version_value
22
- assert_equal(Groonga.build_version, Groonga::BUILD_VERSION.join("."))
23
- end
24
-
25
- def test_version_format
26
- if /-/ =~ Groonga.version
27
- assert_equal("X.X.X-XXX", normalize(Groonga.version))
28
- else
29
- assert_equal("X.X.X", normalize(Groonga.version))
30
- end
31
- end
32
-
33
- def test_version_value
34
- major, minor, micro, tag = Groonga::VERSION
35
- versions = [major, minor, micro]
36
- assert_equal(Groonga.version, [versions.join("."), tag].compact.join("-"))
37
- end
38
-
39
- def test_bindings_version_format
40
- assert_equal("X.X.X", normalize(Groonga.bindings_version))
41
- end
42
-
43
- def test_bindings_version_value
44
- assert_equal(Groonga.bindings_version, Groonga::BINDINGS_VERSION.join("."))
45
- end
46
-
47
- private
48
- def normalize(version)
49
- versions_component, tag_component = version.split(/-/, 2)
50
- versions = versions_component.split(/\./)
51
- normalized_versions = versions.collect do |component|
52
- component.gsub(/\d+/, "X")
53
- end
54
- if tag_component
55
- normalized_tag = "XXX"
56
- else
57
- normalized_tag = nil
58
- end
59
- [normalized_versions.join("."), normalized_tag].compact.join("-")
60
- end
61
- end
data/test/test-view.rb DELETED
@@ -1,72 +0,0 @@
1
- # Copyright (C) 2010 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 ViewTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :setup_database
20
-
21
- def test_inspect
22
- path = @tables_dir + "users.groonga"
23
- view = Groonga::View.create(:name => "Users", :path => path.to_s)
24
- assert_equal("#<Groonga::View " +
25
- "id: <#{view.id}>, " +
26
- "name: <Users>, " +
27
- "path: <#{path}>, " +
28
- "domain: (nil), " +
29
- "range: (nil), " +
30
- "flags: <>, " +
31
- "encoding: <:default>, " +
32
- "size: <0>>",
33
- view.inspect)
34
- end
35
-
36
- def test_encoding
37
- view = Groonga::View.create
38
- assert_false(view.respond_to?(:encoding))
39
- end
40
-
41
- def test_add_table
42
- users = Groonga::Array.create(:name => "Users")
43
- dogs = Groonga::Array.create(:name => "Dogs")
44
- entries = Groonga::View.create(:name => "Entries")
45
- entries.add_table(users)
46
- entries.add_table(dogs)
47
-
48
- assert_equal(0, entries.size)
49
- users.add
50
- assert_equal(1, entries.size)
51
- dogs.add
52
- assert_equal(2, entries.size)
53
- end
54
-
55
- def test_sort
56
- users = Groonga::Hash.create(:name => "Users", :key_type => "ShortText")
57
- dogs = Groonga::Hash.create(:name => "Dogs", :key_type => "ShortText")
58
- entries = Groonga::View.create(:name => "Entries")
59
- entries.add_table(users)
60
- entries.add_table(dogs)
61
-
62
- users.add("morita")
63
- users.add("tasuku")
64
- users.add("yu")
65
- dogs.add("pochi")
66
- dogs.add("bob")
67
- dogs.add("fuga")
68
- omit("View#sort is broken!!!")
69
- assert_equal(["XXX"],
70
- entries.sort(["_key"], :limit => 2).collect {|entry| entry["_key"]})
71
- end
72
- end