rroonga 2.0.4 → 2.0.5
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.
- data/Rakefile +21 -2
- data/bin/grndump +3 -2
- data/ext/groonga/extconf.rb +1 -6
- data/ext/groonga/rb-grn-array.c +58 -31
- data/ext/groonga/rb-grn-column.c +220 -148
- data/ext/groonga/rb-grn-context.c +46 -32
- data/ext/groonga/rb-grn-database.c +102 -90
- data/ext/groonga/rb-grn-double-array-trie.c +205 -163
- data/ext/groonga/rb-grn-encoding-support.c +2 -3
- data/ext/groonga/rb-grn-encoding.c +13 -8
- data/ext/groonga/rb-grn-exception.c +1 -1
- data/ext/groonga/rb-grn-expression.c +110 -133
- data/ext/groonga/rb-grn-fix-size-column.c +5 -4
- data/ext/groonga/rb-grn-geo-point.c +55 -0
- data/ext/groonga/rb-grn-hash.c +120 -82
- data/ext/groonga/rb-grn-index-column.c +66 -70
- data/ext/groonga/rb-grn-index-cursor.c +3 -0
- data/ext/groonga/rb-grn-logger.c +33 -51
- data/ext/groonga/rb-grn-object.c +2 -0
- data/ext/groonga/rb-grn-operator.c +1 -1
- data/ext/groonga/rb-grn-patricia-trie.c +287 -232
- data/ext/groonga/rb-grn-plugin.c +11 -14
- data/ext/groonga/rb-grn-snippet.c +37 -54
- data/ext/groonga/rb-grn-table-cursor-key-support.c +3 -3
- data/ext/groonga/rb-grn-table-cursor.c +8 -6
- data/ext/groonga/rb-grn-table-key-support.c +22 -29
- data/ext/groonga/rb-grn-table.c +355 -279
- data/ext/groonga/rb-grn-type.c +18 -25
- data/ext/groonga/rb-grn-utils.c +77 -7
- data/ext/groonga/rb-grn-variable-size-column.c +12 -20
- data/ext/groonga/rb-grn-view.c +56 -51
- data/ext/groonga/rb-grn.h +28 -1
- data/ext/groonga/rb-groonga.c +1 -0
- data/lib/groonga.rb +2 -0
- data/lib/groonga/command.rb +3 -1
- data/lib/groonga/database.rb +27 -0
- data/lib/groonga/dumper.rb +96 -17
- data/lib/groonga/geo-point.rb +216 -0
- data/lib/groonga/schema.rb +29 -46
- data/rroonga-build.rb +1 -1
- data/rroonga.gemspec +90 -0
- data/test/groonga-test-utils.rb +168 -0
- data/test/run-test.rb +60 -0
- data/test/test-accessor.rb +36 -0
- data/test/test-array.rb +146 -0
- data/test/test-column.rb +350 -0
- data/test/test-command-select.rb +181 -0
- data/test/test-context.rb +130 -0
- data/test/test-database-dumper.rb +259 -0
- data/test/test-database.rb +173 -0
- data/test/test-double-array-trie.rb +189 -0
- data/test/test-encoding.rb +33 -0
- data/test/test-exception.rb +230 -0
- data/test/test-expression-builder.rb +602 -0
- data/test/test-expression.rb +134 -0
- data/test/test-fix-size-column.rb +77 -0
- data/test/test-geo-point.rb +190 -0
- data/test/test-gqtp.rb +70 -0
- data/test/test-hash.rb +367 -0
- data/test/test-index-column.rb +180 -0
- data/test/test-index-cursor.rb +123 -0
- data/test/test-logger.rb +37 -0
- data/test/test-pagination.rb +249 -0
- data/test/test-patricia-trie.rb +440 -0
- data/test/test-plugin.rb +35 -0
- data/test/test-procedure.rb +37 -0
- data/test/test-query-log.rb +258 -0
- data/test/test-record.rb +577 -0
- data/test/test-remote.rb +63 -0
- data/test/test-schema-create-table.rb +267 -0
- data/test/test-schema-dumper.rb +235 -0
- data/test/test-schema-type.rb +208 -0
- data/test/test-schema-view.rb +90 -0
- data/test/test-schema.rb +886 -0
- data/test/test-snippet.rb +130 -0
- data/test/test-table-dumper.rb +353 -0
- data/test/test-table-offset-and-limit.rb +100 -0
- data/test/test-table-select-mecab.rb +80 -0
- data/test/test-table-select-normalize.rb +57 -0
- data/test/test-table-select-weight.rb +123 -0
- data/test/test-table-select.rb +191 -0
- data/test/test-table-traverse.rb +304 -0
- data/test/test-table.rb +711 -0
- data/test/test-type.rb +79 -0
- data/test/test-variable-size-column.rb +147 -0
- data/test/test-variable.rb +28 -0
- data/test/test-vector-column.rb +76 -0
- data/test/test-version.rb +61 -0
- data/test/test-view.rb +72 -0
- metadata +330 -202
@@ -0,0 +1,134 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License version 2.1 as published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this library; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
class ExpressionTest < Test::Unit::TestCase
|
19
|
+
include GroongaTestUtils
|
20
|
+
|
21
|
+
setup :setup_database
|
22
|
+
|
23
|
+
def test_array_reference
|
24
|
+
expression = Groonga::Expression.new
|
25
|
+
ryoqun = expression.define_variable({:name => "user"})
|
26
|
+
ryoqun.value = "ryoqun"
|
27
|
+
mori = expression.define_variable
|
28
|
+
mori.value = "mori"
|
29
|
+
|
30
|
+
expression.append_object(ryoqun)
|
31
|
+
expression.append_object(mori)
|
32
|
+
|
33
|
+
assert_equal("ryoqun", expression["user"])
|
34
|
+
assert_equal("ryoqun", expression[0])
|
35
|
+
assert_equal("mori", expression[1])
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_get_value
|
39
|
+
users = Groonga::Hash.create(:name => "Users")
|
40
|
+
name = users.define_column("name", "ShortText")
|
41
|
+
|
42
|
+
morita = users.add("morita", :name => "mori daijiro")
|
43
|
+
|
44
|
+
expression = Groonga::Expression.new
|
45
|
+
expression.append_constant(morita)
|
46
|
+
expression.append_constant("name")
|
47
|
+
expression.append_operation(Groonga::Operation::GET_VALUE, 2)
|
48
|
+
expression.compile
|
49
|
+
assert_equal("mori daijiro", expression.execute)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_get_value_with_variable
|
53
|
+
users = Groonga::Hash.create(:name => "Users")
|
54
|
+
name = users.define_column("name", "ShortText")
|
55
|
+
|
56
|
+
morita = users.add("morita", :name => "mori daijiro")
|
57
|
+
gunyara_kun = users.add("gunyara-kun", :name => "Tasuku SUENAGA")
|
58
|
+
|
59
|
+
expression = Groonga::Expression.new
|
60
|
+
variable = expression.define_variable
|
61
|
+
variable.value = morita
|
62
|
+
expression.append_object(variable)
|
63
|
+
expression.append_constant("name")
|
64
|
+
expression.append_operation(Groonga::Operation::GET_VALUE, 2)
|
65
|
+
expression.compile
|
66
|
+
assert_equal("mori daijiro", expression.execute)
|
67
|
+
|
68
|
+
variable.value = gunyara_kun.id
|
69
|
+
assert_equal("Tasuku SUENAGA", expression.execute)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_inspect
|
73
|
+
expression = Groonga::Expression.new
|
74
|
+
expression.append_constant(1)
|
75
|
+
expression.append_constant(1)
|
76
|
+
expression.append_operation(Groonga::Operation::PLUS, 2)
|
77
|
+
expression.compile
|
78
|
+
|
79
|
+
assert_equal("#<Groonga::Expression noname(){21,01,0PLUS}>",
|
80
|
+
expression.inspect)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_snippet
|
84
|
+
users = Groonga::Array.create(:name => "Users")
|
85
|
+
users.define_column("name", "ShortText")
|
86
|
+
Groonga::Hash.create(:name => "Terms",
|
87
|
+
:key_type => "ShortText",
|
88
|
+
:default_tokenizer => "TokenBigram")
|
89
|
+
users.define_index_column("user_name", users,
|
90
|
+
:source => "Users.name",
|
91
|
+
:with_position => true)
|
92
|
+
|
93
|
+
expression = Groonga::Expression.new
|
94
|
+
variable = expression.define_variable(:domain => users)
|
95
|
+
expression.append_object(variable)
|
96
|
+
expression.parse("ラングバ OR Ruby OR groonga", :default_column => name)
|
97
|
+
expression.compile
|
98
|
+
|
99
|
+
snippet = expression.snippet([["[[", "]]"], ["<", ">"]],
|
100
|
+
:width => 30)
|
101
|
+
assert_equal(["[[ラングバ]]プロジェクト",
|
102
|
+
"ン[[groonga]]の機能を<Ruby>か",
|
103
|
+
"。[[groonga]]の機能を<Ruby>ら"],
|
104
|
+
snippet.execute("ラングバプロジェクトはカラムストア機能も" +
|
105
|
+
"備える高速・高機能な全文検索エンジンgroonga" +
|
106
|
+
"の機能をRubyから利用するためのライブラリを" +
|
107
|
+
"提供するプロジェクトです。groongaの機能を" +
|
108
|
+
"Rubyらしい読み書きしやすい構文で利用できる" +
|
109
|
+
"ことが利点です。"))
|
110
|
+
snippet.close
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_snippet_without_tags
|
114
|
+
users = Groonga::Array.create(:name => "Users")
|
115
|
+
users.define_column("name", "ShortText")
|
116
|
+
Groonga::Hash.create(:name => "Terms",
|
117
|
+
:key_type => "ShortText",
|
118
|
+
:default_tokenizer => "TokenBigram")
|
119
|
+
users.define_index_column("user_name", users,
|
120
|
+
:source => "Users.name",
|
121
|
+
:with_position => true)
|
122
|
+
|
123
|
+
expression = Groonga::Expression.new
|
124
|
+
variable = expression.define_variable(:domain => users)
|
125
|
+
expression.append_object(variable)
|
126
|
+
expression.parse("ラングバ", :default_column => name)
|
127
|
+
expression.compile
|
128
|
+
|
129
|
+
snippet = expression.snippet([], :width => 30)
|
130
|
+
assert_equal(["ラングバプロジェクト"],
|
131
|
+
snippet.execute("ラングバプロジェクトはカラムストア機能も"))
|
132
|
+
snippet.close
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,77 @@
|
|
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 FixSizeColumnTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
def setup
|
20
|
+
setup_database
|
21
|
+
|
22
|
+
setup_bookmarks_table
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_bookmarks_table
|
26
|
+
@bookmarks_path = @tables_dir + "bookmarks"
|
27
|
+
@bookmarks = Groonga::Array.create(:name => "Bookmarks",
|
28
|
+
:path => @bookmarks_path.to_s)
|
29
|
+
|
30
|
+
@viewed_column_path = @columns_dir + "viewed"
|
31
|
+
@viewed = @bookmarks.define_column("viewed", "Int32",
|
32
|
+
:path => @viewed_column_path.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_index?
|
36
|
+
assert_not_predicate(@viewed, :index?)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_vector?
|
40
|
+
assert_not_predicate(@viewed, :vector?)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_scalar?
|
44
|
+
assert_predicate(@viewed, :scalar?)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_inspect
|
48
|
+
assert_equal("#<Groonga::FixSizeColumn " +
|
49
|
+
"id: <#{@viewed.id}>, " +
|
50
|
+
"name: <Bookmarks.viewed>, " +
|
51
|
+
"path: <#{@viewed_column_path}>, " +
|
52
|
+
"domain: <Bookmarks>, " +
|
53
|
+
"range: <Int32>, " +
|
54
|
+
"flags: <KEY_INT>" +
|
55
|
+
">",
|
56
|
+
@viewed.inspect)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_domain
|
60
|
+
assert_equal(@bookmarks, @viewed.domain)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_table
|
64
|
+
assert_equal(@bookmarks, @viewed.table)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_assign_time
|
68
|
+
comments = Groonga::Array.create(:name => "Comments")
|
69
|
+
comments.define_column("title", "ShortText")
|
70
|
+
comments.define_column("issued", "Time")
|
71
|
+
title = "Good"
|
72
|
+
issued = 1187430026
|
73
|
+
record = comments.add(:title => title, :issued => issued)
|
74
|
+
assert_equal([title, Time.at(issued)],
|
75
|
+
[record["title"], record["issued"]])
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
# Copyright (C) 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 GeoPointTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
class ValueConverterTest < self
|
20
|
+
def test_msec_to_degree
|
21
|
+
assert_equal(35.6813819, msec_to_degree(128452975))
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_degree_to_msec
|
25
|
+
assert_equal(128452975, degree_to_msec(35.6813819))
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def msec_to_degree(msec)
|
30
|
+
Groonga::GeoPointValueConverter.msec_to_degree(msec)
|
31
|
+
end
|
32
|
+
|
33
|
+
def degree_to_msec(msec)
|
34
|
+
Groonga::GeoPointValueConverter.degree_to_msec(msec)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class BaseTest < self
|
39
|
+
class NewTest < self
|
40
|
+
class StringTest < self
|
41
|
+
class UnitTest < self
|
42
|
+
def test_msec
|
43
|
+
geo_point = Groonga::GeoPoint.new("128452975x503157902")
|
44
|
+
assert_equal("128452975x503157902", geo_point.to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_degree
|
48
|
+
geo_point = Groonga::GeoPoint.new("35.6813819x139.7660839")
|
49
|
+
assert_equal("35.6813819x139.7660839", geo_point.to_s)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class SeparatorTest < self
|
54
|
+
def test_x
|
55
|
+
geo_point = Groonga::GeoPoint.new("128452975x503157902")
|
56
|
+
assert_equal("128452975x503157902", geo_point.to_s)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_comma
|
60
|
+
geo_point = Groonga::GeoPoint.new("128452975,503157902")
|
61
|
+
assert_equal("128452975x503157902", geo_point.to_s)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_same_geodetic_system
|
67
|
+
geo_point_base = Groonga::TokyoGeoPoint.new("128452975x503157902")
|
68
|
+
geo_point = Groonga::TokyoGeoPoint.new(geo_point_base)
|
69
|
+
assert_equal("128452975x503157902", geo_point.to_s)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_different_geodetic_system
|
73
|
+
geo_point_base = Groonga::WGS84GeoPoint.new(35.6813819, 139.7660839)
|
74
|
+
geo_point = Groonga::TokyoGeoPoint.new(geo_point_base)
|
75
|
+
assert_equal("128441358x503169456", geo_point.to_msec.to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class MsecTest < self
|
80
|
+
def test_to_s
|
81
|
+
geo_point = Groonga::GeoPoint.new(128452975, 503157902)
|
82
|
+
assert_equal("128452975x503157902", geo_point.to_s)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_to_msec
|
86
|
+
geo_point = Groonga::GeoPoint.new(128452975, 503157902)
|
87
|
+
assert_equal("128452975x503157902", geo_point.to_msec.to_s)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_to_degree
|
91
|
+
geo_point = Groonga::GeoPoint.new(128452975, 503157902)
|
92
|
+
assert_equal("35.6813819x139.7660839", geo_point.to_degree.to_s)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_msec?
|
96
|
+
geo_point = Groonga::GeoPoint.new(128452975, 503157902)
|
97
|
+
assert_true(geo_point.msec?)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_degree?
|
101
|
+
geo_point = Groonga::GeoPoint.new(128452975, 503157902)
|
102
|
+
assert_false(geo_point.degree?)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class DegreeTest < self
|
107
|
+
def test_to_s
|
108
|
+
geo_point = Groonga::GeoPoint.new(35.6813819, 139.7660839)
|
109
|
+
assert_equal("35.6813819x139.7660839", geo_point.to_s)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_to_msec
|
113
|
+
geo_point = Groonga::GeoPoint.new(35.6813819, 139.7660839)
|
114
|
+
assert_equal("128452975x503157902", geo_point.to_msec.to_s)
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_to_degree
|
118
|
+
geo_point = Groonga::GeoPoint.new(35.6813819, 139.7660839)
|
119
|
+
assert_equal("35.6813819x139.7660839", geo_point.to_degree.to_s)
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_msec?
|
123
|
+
geo_point = Groonga::GeoPoint.new(35.6813819, 139.7660839)
|
124
|
+
assert_false(geo_point.msec?)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_degree?
|
128
|
+
geo_point = Groonga::GeoPoint.new(35.6813819, 139.7660839)
|
129
|
+
assert_true(geo_point.degree?)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class MixTest < self
|
134
|
+
def test_to_s
|
135
|
+
geo_point = Groonga::GeoPoint.new(128452975, 139.7660839)
|
136
|
+
assert_equal("128452975x139.7660839", geo_point.to_s)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_to_msec
|
140
|
+
geo_point = Groonga::GeoPoint.new(128452975, 139.7660839)
|
141
|
+
assert_equal("128452975x503157902", geo_point.to_msec.to_s)
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_to_degree
|
145
|
+
geo_point = Groonga::GeoPoint.new(128452975, 139.7660839)
|
146
|
+
assert_equal("35.6813819x139.7660839", geo_point.to_degree.to_s)
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_msec?
|
150
|
+
geo_point = Groonga::GeoPoint.new(128452975, 139.7660839)
|
151
|
+
assert_false(geo_point.msec?)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_degree?
|
155
|
+
geo_point = Groonga::GeoPoint.new(128452975, 139.7660839)
|
156
|
+
assert_false(geo_point.degree?)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class EqualTest < self
|
161
|
+
class SameGeodeticSystemTest < self
|
162
|
+
def test_same_unit
|
163
|
+
geo_point1 = Groonga::TokyoGeoPoint.new(35.6813819, 139.7660839)
|
164
|
+
geo_point2 = Groonga::TokyoGeoPoint.new(35.6813819, 139.7660839)
|
165
|
+
assert_equal(geo_point1, geo_point2)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_different_unit
|
169
|
+
geo_point1 = Groonga::TokyoGeoPoint.new(35.6813819, 139.7660839)
|
170
|
+
geo_point2 = Groonga::TokyoGeoPoint.new(128452975, 503157902)
|
171
|
+
assert_equal(geo_point1, geo_point2)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class DifferentGeodeticSystemTest < self
|
176
|
+
def test_same_unit
|
177
|
+
geo_point1 = Groonga::TokyoGeoPoint.new(35.6813819, 139.7660839)
|
178
|
+
geo_point2 = Groonga::WGS84GeoPoint.new(35.6846084, 139.7628746)
|
179
|
+
assert_equal(geo_point1, geo_point2)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_different_unit
|
183
|
+
geo_point1 = Groonga::TokyoGeoPoint.new(35.6813819, 139.7660839)
|
184
|
+
geo_point2 = Groonga::WGS84GeoPoint.new(128464590, 503146349)
|
185
|
+
assert_equal(geo_point1, geo_point2)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
data/test/test-gqtp.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2010-2011 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License version 2.1 as published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this library; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
class GQTPTest < Test::Unit::TestCase
|
19
|
+
include GroongaTestUtils
|
20
|
+
|
21
|
+
setup :setup_database
|
22
|
+
|
23
|
+
setup
|
24
|
+
def setup_comments
|
25
|
+
@users = Groonga::Hash.create(:name => "Users", :key_type => "ShortText")
|
26
|
+
|
27
|
+
@comments = Groonga::Array.create(:name => "Comments")
|
28
|
+
@comments.define_column("content", "Text")
|
29
|
+
@comments.define_column("created_at", "Time")
|
30
|
+
@comments.define_column("user", "Users")
|
31
|
+
|
32
|
+
terms = Groonga::PatriciaTrie.create(:name => "Terms",
|
33
|
+
:default_tokenizer => "TokenBigram")
|
34
|
+
terms.define_index_column("comment_content", @comments,
|
35
|
+
:with_section => true,
|
36
|
+
:source => "content")
|
37
|
+
@comment1 = @comments.add(:content => "Hello Good-bye!",
|
38
|
+
:created_at => Time.parse("2009-08-09"),
|
39
|
+
:user => "morita")
|
40
|
+
@comment2 = @comments.add(:content => "Hello World",
|
41
|
+
:created_at => Time.parse("2009-07-09"),
|
42
|
+
:user => "")
|
43
|
+
@comment3 = @comments.add(:content => "test",
|
44
|
+
:created_at => Time.parse("2009-06-09"),
|
45
|
+
:user => "gunyara-kun")
|
46
|
+
@japanese_comment =
|
47
|
+
@comments.add(:content => "うちのボロTVはまだ現役です",
|
48
|
+
:created_at => Time.parse("2009-06-09"),
|
49
|
+
:user => "darashi")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_select_filter_by_existent_user
|
53
|
+
assert_equal([[[1], [["user", "Users"]], ["darashi"]]],
|
54
|
+
process("select Comments --output_columns user " +
|
55
|
+
"--filter 'user == \"darashi\"'"))
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_select_filter_by_nonexistent_user
|
59
|
+
assert_equal([[[0], [["user", "Users"]]]],
|
60
|
+
process("select Comments --output_columns user " +
|
61
|
+
"--filter 'user == \"yu\"'"))
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
def process(gqtp)
|
66
|
+
context.send(gqtp)
|
67
|
+
_, result = context.receive
|
68
|
+
JSON.parse(result)
|
69
|
+
end
|
70
|
+
end
|