rroonga 5.0.8 → 5.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +18 -6
- data/ext/groonga/rb-grn-conf.c +145 -0
- data/ext/groonga/rb-grn-expression.c +34 -0
- data/ext/groonga/rb-grn-table.c +113 -0
- data/ext/groonga/rb-grn-utils.c +5 -1
- data/ext/groonga/rb-grn.h +2 -1
- data/ext/groonga/rb-groonga.c +1 -0
- data/lib/groonga/context.rb +9 -1
- data/lib/groonga/expression-builder.rb +0 -1
- data/rroonga-build.rb +3 -3
- data/test/test-conf.rb +31 -0
- data/test/test-table.rb +36 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec6c3b794a8d1a4e51430b65fbac2af82edb7e2
|
4
|
+
data.tar.gz: eaf0e7543c579f3d279d7dee8e31bd3ffcd80f33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5c0b4c8a6cb3521cb3b8911a58adf1e3a5db700271dcdb92f73fc84a19f6df5e745afc30cb87cd5f7fe0ddab7b62606e39db02ad5a954062c8bdd822e2bde2b
|
7
|
+
data.tar.gz: e026c373a0d75f3f3acb3c6bf6191373985d15650a1712e02a113492de9bda6a679f8d9a32f9c8b74b40d377bf1490d299b41c579439a63df488847ec00b3d87
|
data/Rakefile
CHANGED
@@ -88,6 +88,10 @@ def collect_binary_files(binary_dir)
|
|
88
88
|
binary_files
|
89
89
|
end
|
90
90
|
|
91
|
+
def windows_gem_name(spec, architecture)
|
92
|
+
"#{spec.name}-#{spec.version}-#{architecture}-mingw32.gem"
|
93
|
+
end
|
94
|
+
|
91
95
|
relative_vendor_dir = "vendor"
|
92
96
|
relative_binary_dir = File.join("vendor", "local")
|
93
97
|
vendor_dir = File.join(base_dir, relative_vendor_dir)
|
@@ -149,13 +153,13 @@ namespace :clean do
|
|
149
153
|
end
|
150
154
|
end
|
151
155
|
|
152
|
-
|
153
|
-
architectures = [:x86, :x64]
|
156
|
+
windows_architectures = [:x86, :x64]
|
154
157
|
|
158
|
+
namespace :build do
|
155
159
|
namespace :windows do
|
156
160
|
ruby_versions = "2.0.0:2.1.6:2.2.2"
|
157
161
|
|
158
|
-
|
162
|
+
windows_architectures.each do |architecture|
|
159
163
|
desc "Build gem for Windows #{architecture}"
|
160
164
|
task architecture do
|
161
165
|
build_dir = "tmp/windows"
|
@@ -179,18 +183,26 @@ namespace :build do
|
|
179
183
|
require "rake_compiler_dock"
|
180
184
|
RakeCompilerDock.sh(raw_command_line)
|
181
185
|
|
182
|
-
|
183
|
-
cp("#{build_dir}/pkg/rroonga-#{version}-#{architecture}-mingw32.gem",
|
186
|
+
cp("#{build_dir}/pkg/#{windows_gem_name(spec, architecture)}",
|
184
187
|
"pkg/")
|
185
188
|
end
|
186
189
|
end
|
187
190
|
end
|
188
191
|
|
189
192
|
desc "Build gems for Windows"
|
190
|
-
build_tasks =
|
193
|
+
build_tasks = windows_architectures.collect do |architecture|
|
191
194
|
"windows:#{architecture}"
|
192
195
|
end
|
193
196
|
task :windows => build_tasks
|
194
197
|
end
|
195
198
|
|
199
|
+
namespace :release do
|
200
|
+
desc "Push gems for Windows to RubyGems.org"
|
201
|
+
task :windows do
|
202
|
+
windows_architectures.each do |architecture|
|
203
|
+
ruby("-S", "gem", "push", "pkg/#{windows_gem_name(spec, architecture)}")
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
196
208
|
task :default => :test
|
@@ -0,0 +1,145 @@
|
|
1
|
+
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
|
+
/*
|
3
|
+
Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "rb-grn.h"
|
20
|
+
|
21
|
+
#define SELF(object) (RVAL2GRNCONTEXT(object))
|
22
|
+
|
23
|
+
/*
|
24
|
+
* Document-class: Groonga::Conf
|
25
|
+
*
|
26
|
+
* This class manages database global configurations. Each
|
27
|
+
* configuration is key and value pair.
|
28
|
+
*/
|
29
|
+
|
30
|
+
/*
|
31
|
+
* Creates a new configuration set for `context`.
|
32
|
+
*
|
33
|
+
* @overload initialize(context=nil)
|
34
|
+
* @param [Groonga::Context, nil] context The context to be configured.
|
35
|
+
* If `context` is `nil`, {Groonga::Context.default} is used.
|
36
|
+
*
|
37
|
+
* @since 5.0.9
|
38
|
+
*/
|
39
|
+
static VALUE
|
40
|
+
rb_grn_conf_initialize (VALUE self, VALUE rb_context)
|
41
|
+
{
|
42
|
+
rb_iv_set(self, "@context", rb_context);
|
43
|
+
|
44
|
+
return Qnil;
|
45
|
+
}
|
46
|
+
|
47
|
+
/*
|
48
|
+
* Gets a configuration value for key.
|
49
|
+
*
|
50
|
+
* @overload conf[](key)
|
51
|
+
* @param [String] key The key.
|
52
|
+
* @return [String, nil] The value associated with `key`.
|
53
|
+
*
|
54
|
+
* @since 5.0.9
|
55
|
+
*/
|
56
|
+
static VALUE
|
57
|
+
rb_grn_conf_get (VALUE self, VALUE rb_key)
|
58
|
+
{
|
59
|
+
VALUE rb_context;
|
60
|
+
VALUE rb_value;
|
61
|
+
grn_ctx *context;
|
62
|
+
const char *key;
|
63
|
+
int key_size;
|
64
|
+
const char *value;
|
65
|
+
uint32_t value_size;
|
66
|
+
|
67
|
+
rb_context = rb_iv_get(self, "@context");
|
68
|
+
context = rb_grn_context_ensure(&rb_context);
|
69
|
+
|
70
|
+
rb_key = rb_grn_convert_to_string(rb_key);
|
71
|
+
key = RSTRING_PTR(rb_key);
|
72
|
+
key_size = RSTRING_LEN(rb_key);
|
73
|
+
|
74
|
+
{
|
75
|
+
grn_rc rc;
|
76
|
+
rc = grn_conf_get(context,
|
77
|
+
key, key_size,
|
78
|
+
&value, &value_size);
|
79
|
+
rb_grn_context_check(context, self);
|
80
|
+
rb_grn_rc_check(rc, self);
|
81
|
+
}
|
82
|
+
|
83
|
+
if (value_size == 0) {
|
84
|
+
rb_value = Qnil;
|
85
|
+
} else {
|
86
|
+
rb_value = rb_grn_context_rb_string_new(context, value, value_size);
|
87
|
+
}
|
88
|
+
|
89
|
+
return rb_value;
|
90
|
+
}
|
91
|
+
|
92
|
+
/*
|
93
|
+
* Sets a configuration key and value pair.
|
94
|
+
*
|
95
|
+
* @overload conf[]=(key, value)
|
96
|
+
* @param [String] key The key.
|
97
|
+
* @param [String] value The value to be assigned.
|
98
|
+
* @return [String] `value`.
|
99
|
+
*/
|
100
|
+
static VALUE
|
101
|
+
rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value)
|
102
|
+
{
|
103
|
+
VALUE rb_value_original = rb_value;
|
104
|
+
VALUE rb_context;
|
105
|
+
grn_ctx *context;
|
106
|
+
const char *key;
|
107
|
+
int key_size;
|
108
|
+
const char *value;
|
109
|
+
int value_size;
|
110
|
+
|
111
|
+
rb_context = rb_iv_get(self, "@context");
|
112
|
+
context = rb_grn_context_ensure(&rb_context);
|
113
|
+
|
114
|
+
rb_key = rb_grn_convert_to_string(rb_key);
|
115
|
+
key = RSTRING_PTR(rb_key);
|
116
|
+
key_size = RSTRING_LEN(rb_key);
|
117
|
+
|
118
|
+
rb_value = rb_grn_convert_to_string(rb_value);
|
119
|
+
value = RSTRING_PTR(rb_value);
|
120
|
+
value_size = RSTRING_LEN(rb_value);
|
121
|
+
|
122
|
+
{
|
123
|
+
grn_rc rc;
|
124
|
+
rc = grn_conf_set(context,
|
125
|
+
key, key_size,
|
126
|
+
value, value_size);
|
127
|
+
rb_grn_context_check(context, self);
|
128
|
+
rb_grn_rc_check(rc, self);
|
129
|
+
}
|
130
|
+
|
131
|
+
return rb_value_original;
|
132
|
+
}
|
133
|
+
|
134
|
+
void
|
135
|
+
rb_grn_init_conf (VALUE mGrn)
|
136
|
+
{
|
137
|
+
VALUE cGrnConf;
|
138
|
+
|
139
|
+
cGrnConf = rb_define_class_under(mGrn, "Conf", rb_cObject);
|
140
|
+
|
141
|
+
rb_define_method(cGrnConf, "initialize", rb_grn_conf_initialize, 1);
|
142
|
+
|
143
|
+
rb_define_method(cGrnConf, "[]", rb_grn_conf_get, 1);
|
144
|
+
rb_define_method(cGrnConf, "[]=", rb_grn_conf_set, 2);
|
145
|
+
}
|
@@ -824,6 +824,37 @@ rb_grn_expression_estimate_size (VALUE self)
|
|
824
824
|
return UINT2NUM(size);
|
825
825
|
}
|
826
826
|
|
827
|
+
/*
|
828
|
+
* Rewrites expression.
|
829
|
+
*
|
830
|
+
* @example
|
831
|
+
* expression.parse("age >= 10 AND age < 20",
|
832
|
+
* :syntax => :script)
|
833
|
+
* expression.rewrite # => New rewritten expression.
|
834
|
+
* # It'll use between(age, 10, "include", 20, "exclude")
|
835
|
+
*
|
836
|
+
* @overload rewrite
|
837
|
+
* @return [Groonga::Expression, nil] new rewritten expression when
|
838
|
+
* the expression is rewritten, `nil` otherwise.
|
839
|
+
*
|
840
|
+
* @since 5.1.0
|
841
|
+
*/
|
842
|
+
static VALUE
|
843
|
+
rb_grn_expression_rewrite (VALUE self)
|
844
|
+
{
|
845
|
+
grn_ctx *context = NULL;
|
846
|
+
grn_obj *expression;
|
847
|
+
grn_obj *rewritten_expression;
|
848
|
+
|
849
|
+
rb_grn_expression_deconstruct(SELF(self), &expression, &context,
|
850
|
+
NULL, NULL,
|
851
|
+
NULL, NULL, NULL);
|
852
|
+
|
853
|
+
rewritten_expression = grn_expr_rewrite(context, expression);
|
854
|
+
|
855
|
+
return GRNOBJECT2RVAL(Qnil, context, rewritten_expression, GRN_TRUE);
|
856
|
+
}
|
857
|
+
|
827
858
|
void
|
828
859
|
rb_grn_init_expression (VALUE mGrn)
|
829
860
|
{
|
@@ -865,4 +896,7 @@ rb_grn_init_expression (VALUE mGrn)
|
|
865
896
|
|
866
897
|
rb_define_method(rb_cGrnExpression, "estimate_size",
|
867
898
|
rb_grn_expression_estimate_size, 0);
|
899
|
+
|
900
|
+
rb_define_method(rb_cGrnExpression, "rewrite",
|
901
|
+
rb_grn_expression_rewrite, 0);
|
868
902
|
}
|
data/ext/groonga/rb-grn-table.c
CHANGED
@@ -1313,6 +1313,118 @@ rb_grn_table_sort (int argc, VALUE *argv, VALUE self)
|
|
1313
1313
|
return GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
|
1314
1314
|
}
|
1315
1315
|
|
1316
|
+
/*
|
1317
|
+
* Sorts records in the table by `TokyoGeoPoint` or `WGS84GeoPoint`
|
1318
|
+
* type column value. Order is near to far from base geo point.
|
1319
|
+
*
|
1320
|
+
* @overload geo_sort(column, base_geo_point, options={})
|
1321
|
+
* @param options [::Hash] The name and value
|
1322
|
+
* pairs. Omitted names are initialized as the default value.
|
1323
|
+
*
|
1324
|
+
* @option options :offset (0)
|
1325
|
+
*
|
1326
|
+
* It specifies what number record should be the first record in
|
1327
|
+
* returned table. It's 0-based.
|
1328
|
+
*
|
1329
|
+
* If you specify `0`, the 0th record, the 1st record, the 2nd
|
1330
|
+
* record, ... are returned.
|
1331
|
+
*
|
1332
|
+
* If you specify `0`, the 1st record, the 2nd record, ... are
|
1333
|
+
* returned. The 0th record isn't returned.
|
1334
|
+
*
|
1335
|
+
* The default is `0`.
|
1336
|
+
*
|
1337
|
+
* @option options :limit (-1)
|
1338
|
+
*
|
1339
|
+
* It specifies up to how many records are returned. If `-1` is
|
1340
|
+
* specified, all records are returned.
|
1341
|
+
*
|
1342
|
+
* The default is `-1`.
|
1343
|
+
*
|
1344
|
+
* @return [Groonga::Array] The sorted result. You can get the
|
1345
|
+
* original record by {#value} method of a record in the sorted
|
1346
|
+
* result. Normally, you doesn't need to get the original record
|
1347
|
+
* because you can access via column name method:
|
1348
|
+
*
|
1349
|
+
* If you want to access the key of the original record, you need to
|
1350
|
+
* get the original record.
|
1351
|
+
*
|
1352
|
+
* @since 5.0.9
|
1353
|
+
*/
|
1354
|
+
static VALUE
|
1355
|
+
rb_grn_table_geo_sort (int argc, VALUE *argv, VALUE self)
|
1356
|
+
{
|
1357
|
+
grn_ctx *context = NULL;
|
1358
|
+
grn_obj *table;
|
1359
|
+
VALUE rb_column;
|
1360
|
+
VALUE rb_base_geo_point;
|
1361
|
+
VALUE rb_options;
|
1362
|
+
VALUE rb_offset;
|
1363
|
+
VALUE rb_limit;
|
1364
|
+
grn_obj *column;
|
1365
|
+
grn_id column_range_id;
|
1366
|
+
grn_obj base_geo_point;
|
1367
|
+
int offset = 0;
|
1368
|
+
int limit = -1;
|
1369
|
+
grn_obj *result;
|
1370
|
+
VALUE exception;
|
1371
|
+
|
1372
|
+
rb_grn_table_deconstruct(SELF(self), &table, &context,
|
1373
|
+
NULL, NULL,
|
1374
|
+
NULL, NULL, NULL,
|
1375
|
+
NULL);
|
1376
|
+
|
1377
|
+
rb_scan_args(argc, argv, "21", &rb_column, &rb_base_geo_point, &rb_options);
|
1378
|
+
|
1379
|
+
column = RVAL2GRNCOLUMN(rb_column, &context);
|
1380
|
+
column_range_id = grn_obj_get_range(context, column);
|
1381
|
+
switch (column_range_id) {
|
1382
|
+
case GRN_DB_TOKYO_GEO_POINT:
|
1383
|
+
GRN_TOKYO_GEO_POINT_INIT(&base_geo_point, 0);
|
1384
|
+
break;
|
1385
|
+
case GRN_DB_WGS84_GEO_POINT:
|
1386
|
+
GRN_WGS84_GEO_POINT_INIT(&base_geo_point, 0);
|
1387
|
+
break;
|
1388
|
+
default:
|
1389
|
+
rb_raise(rb_eArgError,
|
1390
|
+
"column's range must be TokyoGeoPoint or WGS84GeoPoint: %s",
|
1391
|
+
rb_grn_inspect(rb_column));
|
1392
|
+
break;
|
1393
|
+
}
|
1394
|
+
RVAL2GRNBULK_WITH_TYPE(rb_base_geo_point,
|
1395
|
+
context,
|
1396
|
+
&base_geo_point,
|
1397
|
+
column_range_id,
|
1398
|
+
grn_ctx_at(context, column_range_id));
|
1399
|
+
|
1400
|
+
rb_grn_scan_options(rb_options,
|
1401
|
+
"offset", &rb_offset,
|
1402
|
+
"limit", &rb_limit,
|
1403
|
+
NULL);
|
1404
|
+
|
1405
|
+
if (!NIL_P(rb_offset))
|
1406
|
+
offset = NUM2INT(rb_offset);
|
1407
|
+
if (!NIL_P(rb_limit))
|
1408
|
+
limit = NUM2INT(rb_limit);
|
1409
|
+
/* TODO: Remove me when Groonga 5.1.0 is released. */
|
1410
|
+
if (limit < 0)
|
1411
|
+
limit = grn_table_size(context, table) + limit + 1;
|
1412
|
+
|
1413
|
+
result = grn_table_create(context, NULL, 0, NULL, GRN_TABLE_NO_KEY,
|
1414
|
+
NULL, table);
|
1415
|
+
grn_geo_table_sort(context, table, offset, limit,
|
1416
|
+
result, column, &base_geo_point);
|
1417
|
+
exception = rb_grn_context_to_exception(context, self);
|
1418
|
+
if (!NIL_P(exception)) {
|
1419
|
+
grn_obj_unlink(context, &base_geo_point);
|
1420
|
+
grn_obj_unlink(context, result);
|
1421
|
+
rb_exc_raise(exception);
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
grn_obj_unlink(context, &base_geo_point);
|
1425
|
+
return GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
|
1426
|
+
}
|
1427
|
+
|
1316
1428
|
/*
|
1317
1429
|
* _table_ のレコードを _key1_ , _key2_ , _..._ で指定したキーの
|
1318
1430
|
* 値でグループ化する。多くの場合、キーにはカラムを指定する。
|
@@ -2608,6 +2720,7 @@ rb_grn_init_table (VALUE mGrn)
|
|
2608
2720
|
rb_define_method(rb_cGrnTable, "delete", rb_grn_table_delete, -1);
|
2609
2721
|
|
2610
2722
|
rb_define_method(rb_cGrnTable, "sort", rb_grn_table_sort, -1);
|
2723
|
+
rb_define_method(rb_cGrnTable, "geo_sort", rb_grn_table_geo_sort, -1);
|
2611
2724
|
rb_define_method(rb_cGrnTable, "group", rb_grn_table_group, -1);
|
2612
2725
|
|
2613
2726
|
rb_define_method(rb_cGrnTable, "[]", rb_grn_table_array_reference, 1);
|
data/ext/groonga/rb-grn-utils.c
CHANGED
@@ -174,7 +174,11 @@ rb_grn_equal_string (const char *string1, const char *string2)
|
|
174
174
|
VALUE
|
175
175
|
rb_grn_convert_to_string (VALUE object)
|
176
176
|
{
|
177
|
-
|
177
|
+
if (rb_type(object) == T_SYMBOL) {
|
178
|
+
return rb_sym2str(object);
|
179
|
+
} else {
|
180
|
+
return rb_convert_type(object, RUBY_T_STRING, "String", "to_str");
|
181
|
+
}
|
178
182
|
}
|
179
183
|
|
180
184
|
VALUE
|
data/ext/groonga/rb-grn.h
CHANGED
@@ -101,7 +101,7 @@ RB_GRN_BEGIN_DECLS
|
|
101
101
|
|
102
102
|
#define RB_GRN_MAJOR_VERSION 5
|
103
103
|
#define RB_GRN_MINOR_VERSION 0
|
104
|
-
#define RB_GRN_MICRO_VERSION
|
104
|
+
#define RB_GRN_MICRO_VERSION 9
|
105
105
|
|
106
106
|
#define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
|
107
107
|
|
@@ -354,6 +354,7 @@ void rb_grn_init_snippet (VALUE mGrn);
|
|
354
354
|
void rb_grn_init_plugin (VALUE mGrn);
|
355
355
|
void rb_grn_init_normalizer (VALUE mGrn);
|
356
356
|
void rb_grn_init_thread (VALUE mGrn);
|
357
|
+
void rb_grn_init_conf (VALUE mGrn);
|
357
358
|
|
358
359
|
VALUE rb_grn_rc_to_exception (grn_rc rc);
|
359
360
|
const char *rb_grn_rc_to_message (grn_rc rc);
|
data/ext/groonga/rb-groonga.c
CHANGED
data/lib/groonga/context.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2015 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
|
@@ -346,5 +346,13 @@ module Groonga
|
|
346
346
|
memory_pool = @memory_pools.last
|
347
347
|
memory_pool.register(object)
|
348
348
|
end
|
349
|
+
|
350
|
+
# @return [Groonga::Conf] The database level configuration sets of
|
351
|
+
# this context.
|
352
|
+
#
|
353
|
+
# @since 5.0.9
|
354
|
+
def conf
|
355
|
+
@conf ||= Conf.new(self)
|
356
|
+
end
|
349
357
|
end
|
350
358
|
end
|
data/rroonga-build.rb
CHANGED
@@ -20,15 +20,15 @@ module RroongaBuild
|
|
20
20
|
module RequiredGroongaVersion
|
21
21
|
MAJOR = 5
|
22
22
|
MINOR = 0
|
23
|
-
MICRO =
|
23
|
+
MICRO = 9
|
24
24
|
VERSION = [MAJOR, MINOR, MICRO]
|
25
|
-
RELEASED_DATE = Time.utc(2015,
|
25
|
+
RELEASED_DATE = Time.utc(2015, 10, 29)
|
26
26
|
end
|
27
27
|
|
28
28
|
module LatestGroongaVersion
|
29
29
|
MAJOR = 5
|
30
30
|
MINOR = 0
|
31
|
-
MICRO =
|
31
|
+
MICRO = 9
|
32
32
|
VERSION = [MAJOR, MINOR, MICRO]
|
33
33
|
end
|
34
34
|
|
data/test/test-conf.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
|
+
|
16
|
+
class ConfTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
setup :setup_database
|
20
|
+
|
21
|
+
sub_test_case "#[]" do
|
22
|
+
test "existent" do
|
23
|
+
context.conf["rroonga.key"] = "value"
|
24
|
+
assert_equal("value", context.conf["rroonga.key"])
|
25
|
+
end
|
26
|
+
|
27
|
+
test "nonexistent" do
|
28
|
+
assert_nil(context.conf["nonexistent"])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/test/test-table.rb
CHANGED
@@ -421,6 +421,42 @@ class TableTest < Test::Unit::TestCase
|
|
421
421
|
sorted_bookmarks.collect(&:value))
|
422
422
|
end
|
423
423
|
|
424
|
+
sub_test_case "#geo_sort" do
|
425
|
+
setup
|
426
|
+
def setup_schema
|
427
|
+
Groonga::Schema.define do |schema|
|
428
|
+
schema.create_table("Posts") do |table|
|
429
|
+
table.wgs84_geo_point("location")
|
430
|
+
end
|
431
|
+
|
432
|
+
schema.create_table("Locations",
|
433
|
+
:type => :patricia_trie,
|
434
|
+
:key_type => "WGS84GeoPoint") do |table|
|
435
|
+
table.index("Posts.location")
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
@posts = Groonga["Posts"]
|
440
|
+
end
|
441
|
+
|
442
|
+
setup
|
443
|
+
def setup_data
|
444
|
+
@posts.add(:location => "35.720253x139.762573")
|
445
|
+
@posts.add(:location => "35.730061x139.796234")
|
446
|
+
@posts.add(:location => "35.685341x139.783981")
|
447
|
+
end
|
448
|
+
|
449
|
+
test "default" do
|
450
|
+
results = @posts.geo_sort(@posts.column("location"), "35.7119x139.7983")
|
451
|
+
assert_equal([
|
452
|
+
Groonga::WGS84GeoPoint.new("35.730061x139.796234"),
|
453
|
+
Groonga::WGS84GeoPoint.new("35.685341x139.783981"),
|
454
|
+
Groonga::WGS84GeoPoint.new("35.720253x139.762573"),
|
455
|
+
],
|
456
|
+
results.collect(&:location))
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
424
460
|
def test_union!
|
425
461
|
bookmarks = Groonga::Hash.create(:name => "Bookmarks")
|
426
462
|
bookmarks.define_column("title", "ShortText")
|
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.0.
|
4
|
+
version: 5.0.9
|
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: 2015-10
|
15
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: pkg-config
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- ext/groonga/rb-grn-array-cursor.c
|
245
245
|
- ext/groonga/rb-grn-array.c
|
246
246
|
- ext/groonga/rb-grn-column.c
|
247
|
+
- ext/groonga/rb-grn-conf.c
|
247
248
|
- ext/groonga/rb-grn-context.c
|
248
249
|
- ext/groonga/rb-grn-database.c
|
249
250
|
- ext/groonga/rb-grn-double-array-trie-cursor.c
|
@@ -327,6 +328,7 @@ files:
|
|
327
328
|
- test/test-array.rb
|
328
329
|
- test/test-column.rb
|
329
330
|
- test/test-command-select.rb
|
331
|
+
- test/test-conf.rb
|
330
332
|
- test/test-context.rb
|
331
333
|
- test/test-convert.rb
|
332
334
|
- test/test-database-dumper.rb
|
@@ -416,6 +418,7 @@ test_files:
|
|
416
418
|
- test/test-windows-event-logger.rb
|
417
419
|
- test/test-table-select-normalize.rb
|
418
420
|
- test/test-lock-timeout.rb
|
421
|
+
- test/test-conf.rb
|
419
422
|
- test/test-record.rb
|
420
423
|
- test/test-plugin.rb
|
421
424
|
- test/groonga-test-utils.rb
|