rroonga 5.1.1 → 6.0.0
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/bin/grndump +9 -0
- data/doc/text/cross-compile.md +72 -0
- data/doc/text/install.md +121 -0
- data/doc/text/news.md +1451 -0
- data/doc/text/release.md +135 -0
- data/doc/text/tutorial.md +402 -0
- data/ext/groonga/rb-grn-column.c +54 -24
- data/ext/groonga/rb-grn-config.c +131 -10
- data/ext/groonga/rb-grn-context.c +0 -10
- data/ext/groonga/rb-grn-encoding.c +0 -2
- data/ext/groonga/rb-grn-expression.c +63 -3
- data/ext/groonga/rb-grn-index.c +34 -0
- data/ext/groonga/rb-grn-object.c +10 -10
- data/ext/groonga/rb-grn-operator.c +7 -0
- data/ext/groonga/rb-grn-plugin.c +39 -0
- data/ext/groonga/rb-grn-utils.c +5 -65
- data/ext/groonga/rb-grn.h +9 -9
- data/ext/groonga/rb-groonga.c +31 -1
- data/lib/groonga/column.rb +13 -0
- data/lib/groonga/dumper.rb +3 -1
- data/lib/groonga/expression-builder.rb +66 -18
- data/lib/groonga/{expression-builder-19.rb → index.rb} +11 -19
- data/lib/groonga/record.rb +1 -1
- data/lib/groonga.rb +1 -0
- data/lib/rroonga.rb +16 -0
- data/rroonga-build.rb +6 -6
- data/rroonga.gemspec +1 -1
- data/test/groonga-test-utils.rb +0 -8
- data/test/test-column.rb +107 -1
- data/test/test-config.rb +18 -0
- data/test/test-database.rb +0 -2
- data/test/test-error-message.rb +20 -0
- data/test/test-expression-builder.rb +172 -29
- data/test/test-plugin.rb +25 -1
- data/test/test-table-dumper.rb +35 -6
- data/test/test-table-select.rb +0 -1
- metadata +62 -53
data/ext/groonga/rb-grn.h
CHANGED
@@ -21,10 +21,8 @@
|
|
21
21
|
#define __RB_GRN_H__
|
22
22
|
|
23
23
|
#include <ruby.h>
|
24
|
+
#include <ruby/encoding.h>
|
24
25
|
|
25
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
26
|
-
# include <ruby/encoding.h>
|
27
|
-
#endif
|
28
26
|
#ifdef HAVE_RUBY_INTERN_H
|
29
27
|
# include <ruby/intern.h>
|
30
28
|
#endif
|
@@ -99,9 +97,9 @@ RB_GRN_BEGIN_DECLS
|
|
99
97
|
# define debug(...)
|
100
98
|
#endif
|
101
99
|
|
102
|
-
#define RB_GRN_MAJOR_VERSION
|
103
|
-
#define RB_GRN_MINOR_VERSION
|
104
|
-
#define RB_GRN_MICRO_VERSION
|
100
|
+
#define RB_GRN_MAJOR_VERSION 6
|
101
|
+
#define RB_GRN_MINOR_VERSION 0
|
102
|
+
#define RB_GRN_MICRO_VERSION 0
|
105
103
|
|
106
104
|
#define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
|
107
105
|
|
@@ -301,6 +299,7 @@ RB_GRN_VAR VALUE rb_cGrnRecordExpressionBuilder;
|
|
301
299
|
RB_GRN_VAR VALUE rb_cGrnColumnExpressionBuilder;
|
302
300
|
RB_GRN_VAR VALUE rb_cGrnPlugin;
|
303
301
|
RB_GRN_VAR VALUE rb_cGrnNormalizer;
|
302
|
+
RB_GRN_VAR VALUE rb_cGrnIndex;
|
304
303
|
|
305
304
|
void rb_grn_init_utils (VALUE mGrn);
|
306
305
|
void rb_grn_init_exception (VALUE mGrn);
|
@@ -355,6 +354,7 @@ void rb_grn_init_plugin (VALUE mGrn);
|
|
355
354
|
void rb_grn_init_normalizer (VALUE mGrn);
|
356
355
|
void rb_grn_init_thread (VALUE mGrn);
|
357
356
|
void rb_grn_init_config (VALUE mGrn);
|
357
|
+
void rb_grn_init_index (VALUE mGrn);
|
358
358
|
|
359
359
|
VALUE rb_grn_rc_to_exception (grn_rc rc);
|
360
360
|
const char *rb_grn_rc_to_message (grn_rc rc);
|
@@ -383,7 +383,6 @@ void rb_grn_context_object_created (VALUE rb_context,
|
|
383
383
|
VALUE rb_object);
|
384
384
|
|
385
385
|
const char *rb_grn_inspect (VALUE object);
|
386
|
-
const char *rb_grn_inspect_type (unsigned char type);
|
387
386
|
void rb_grn_scan_options (VALUE options, ...)
|
388
387
|
RB_GRN_GNUC_NULL_TERMINATED;
|
389
388
|
grn_bool rb_grn_equal_option (VALUE option,
|
@@ -634,6 +633,9 @@ VALUE rb_grn_column_expression_builder_new (VALUE column,
|
|
634
633
|
VALUE rb_grn_column_expression_builder_build
|
635
634
|
(VALUE self);
|
636
635
|
|
636
|
+
VALUE rb_grn_index_new (VALUE rb_index_column,
|
637
|
+
VALUE rb_section);
|
638
|
+
|
637
639
|
|
638
640
|
#define RB_GRN_INTERN(c_string) (rb_to_symbol(rb_str_new_cstr(c_string)))
|
639
641
|
|
@@ -740,11 +742,9 @@ VALUE rb_grn_column_expression_builder_build
|
|
740
742
|
grn_encoding rb_grn_encoding_from_ruby_object (VALUE object,
|
741
743
|
grn_ctx *context);
|
742
744
|
VALUE rb_grn_encoding_to_ruby_object (grn_encoding encoding);
|
743
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
744
745
|
rb_encoding *rb_grn_encoding_to_ruby_encoding (grn_encoding encoding);
|
745
746
|
VALUE rb_grn_encoding_to_ruby_encoding_object
|
746
747
|
(grn_encoding encoding);
|
747
|
-
#endif
|
748
748
|
|
749
749
|
grn_ctx *rb_grn_context_from_ruby_object (VALUE object);
|
750
750
|
VALUE rb_grn_context_to_ruby_object (grn_ctx *context);
|
data/ext/groonga/rb-groonga.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -30,6 +30,34 @@ finish_groonga (VALUE data)
|
|
30
30
|
debug("finish: done\n");
|
31
31
|
}
|
32
32
|
|
33
|
+
/*
|
34
|
+
* @overload error_message
|
35
|
+
* @return [String, nil] The process global error message.
|
36
|
+
*
|
37
|
+
* @since 6.0.0
|
38
|
+
*/
|
39
|
+
static VALUE
|
40
|
+
rb_grn_s_get_error_message (VALUE klass)
|
41
|
+
{
|
42
|
+
const char *message;
|
43
|
+
|
44
|
+
message = grn_get_global_error_message();
|
45
|
+
if (message[0] == '\0') {
|
46
|
+
return Qnil;
|
47
|
+
} else {
|
48
|
+
grn_encoding encoding = grn_get_default_encoding();
|
49
|
+
return rb_enc_str_new_cstr(message,
|
50
|
+
rb_grn_encoding_to_ruby_encoding(encoding));
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
static void
|
55
|
+
rb_grn_init_error_message (VALUE mGrn)
|
56
|
+
{
|
57
|
+
rb_define_singleton_method(mGrn, "error_message",
|
58
|
+
rb_grn_s_get_error_message, 0);
|
59
|
+
}
|
60
|
+
|
33
61
|
static void
|
34
62
|
rb_grn_init_runtime_version (VALUE mGrn)
|
35
63
|
{
|
@@ -180,6 +208,7 @@ Init_groonga (void)
|
|
180
208
|
|
181
209
|
mGrn = rb_define_module("Groonga");
|
182
210
|
|
211
|
+
rb_grn_init_error_message(mGrn);
|
183
212
|
rb_grn_init_exception(mGrn);
|
184
213
|
|
185
214
|
rb_grn_rc_check(grn_init(), Qnil);
|
@@ -219,4 +248,5 @@ Init_groonga (void)
|
|
219
248
|
rb_grn_init_normalizer(mGrn);
|
220
249
|
rb_grn_init_thread(mGrn);
|
221
250
|
rb_grn_init_config(mGrn);
|
251
|
+
rb_grn_init_index(mGrn);
|
222
252
|
}
|
data/lib/groonga/column.rb
CHANGED
@@ -21,5 +21,18 @@ module Groonga
|
|
21
21
|
measurer = StatisticMeasurer.new
|
22
22
|
measurer.measure_disk_usage(path)
|
23
23
|
end
|
24
|
+
|
25
|
+
# @param [Groonga::Operator] operator (Groonga::Operator::MATCH)
|
26
|
+
# @return [Array<Groonga::IndexColumn>] Indexes on `column` which can
|
27
|
+
# execute `operator`.
|
28
|
+
# @since 1.0.9
|
29
|
+
#
|
30
|
+
# @deprecated since 6.0.0. Use {Groonga::Column#find_indexes} instead.
|
31
|
+
def indexes(operator=nil)
|
32
|
+
operator ||= Operator::MATCH
|
33
|
+
find_indexes(:operator => operator).collect do |index|
|
34
|
+
index.column
|
35
|
+
end
|
36
|
+
end
|
24
37
|
end
|
25
38
|
end
|
data/lib/groonga/dumper.rb
CHANGED
@@ -666,6 +666,7 @@ module Groonga
|
|
666
666
|
@have_output = !@output.nil?
|
667
667
|
@output ||= Dumper.default_output
|
668
668
|
@error_output = @options[:error_output]
|
669
|
+
@max_records = @options[:max_records]
|
669
670
|
end
|
670
671
|
|
671
672
|
def dump
|
@@ -709,7 +710,8 @@ module Groonga
|
|
709
710
|
when Groonga::Array, Groonga::Hash
|
710
711
|
order_by = nil if order_by == :key
|
711
712
|
end
|
712
|
-
@
|
713
|
+
limit = @options[:max_records]
|
714
|
+
@table.each(:order_by => order_by, :limit => limit) do |record|
|
713
715
|
write(",\n")
|
714
716
|
values = columns.collect do |column|
|
715
717
|
resolve_value(record, column, column[record.id])
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
# Copyright (C) 2015 Masafumi Yokoyama <yokoyama@clear-code.com>
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
|
5
5
|
#
|
6
6
|
# This library is free software; you can redistribute it and/or
|
7
7
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -56,6 +56,10 @@ module Groonga
|
|
56
56
|
other
|
57
57
|
end
|
58
58
|
|
59
|
+
def -(other)
|
60
|
+
other
|
61
|
+
end
|
62
|
+
|
59
63
|
private
|
60
64
|
def default_parse_options
|
61
65
|
{
|
@@ -110,6 +114,10 @@ module Groonga
|
|
110
114
|
def |(other)
|
111
115
|
OrExpressionBuilder.new(self, other)
|
112
116
|
end
|
117
|
+
|
118
|
+
def -(other)
|
119
|
+
AndNotExpressionBuilder.new(self, other)
|
120
|
+
end
|
113
121
|
end
|
114
122
|
|
115
123
|
# @private
|
@@ -143,6 +151,13 @@ module Groonga
|
|
143
151
|
end
|
144
152
|
end
|
145
153
|
|
154
|
+
# @private
|
155
|
+
class AndNotExpressionBuilder < SetExpressionBuilder
|
156
|
+
def initialize(*expression_builders)
|
157
|
+
super(Groonga::Operation::AND_NOT, *expression_builders)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
146
161
|
# @private
|
147
162
|
class ColumnValueExpressionBuilder < ExpressionBuilder
|
148
163
|
def initialize(column, options={})
|
@@ -168,6 +183,10 @@ module Groonga
|
|
168
183
|
EqualExpressionBuilder.new(self, normalize(other))
|
169
184
|
end
|
170
185
|
|
186
|
+
def !=(other)
|
187
|
+
NotEqualExpressionBuilder.new(self, normalize(other))
|
188
|
+
end
|
189
|
+
|
171
190
|
def =~(other)
|
172
191
|
if other.nil?
|
173
192
|
full_column_name = "#{@table.name}.#{@column_name}"
|
@@ -249,25 +268,45 @@ module Groonga
|
|
249
268
|
|
250
269
|
private
|
251
270
|
def normalize(other)
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
end
|
258
|
-
return Groonga::Record.new(@range, id) if id.is_a?(Integer)
|
271
|
+
return other unless @range.is_a?(Table)
|
272
|
+
return other if other.is_a?(Record)
|
273
|
+
|
274
|
+
if other.respond_to?(:record_raw_id)
|
275
|
+
return Record.new(@range, other.record_raw_id)
|
259
276
|
end
|
277
|
+
|
278
|
+
if other.respond_to?(:record_id)
|
279
|
+
return @range[other.record_id]
|
280
|
+
end
|
281
|
+
|
260
282
|
other
|
261
283
|
end
|
262
284
|
|
285
|
+
def callable_object?(object)
|
286
|
+
return false unless object.respond_to?(:function_procedure?)
|
287
|
+
|
288
|
+
object.function_procedure?
|
289
|
+
end
|
290
|
+
|
263
291
|
def method_missing(name, *args, &block)
|
264
292
|
return super if block
|
265
|
-
|
266
|
-
if VALID_COLUMN_NAME_RE =~ name.to_s
|
267
|
-
|
268
|
-
|
269
|
-
|
293
|
+
|
294
|
+
if args.empty? and VALID_COLUMN_NAME_RE =~ name.to_s
|
295
|
+
accessor_name = "#{@column_name}.#{name}"
|
296
|
+
accessor = @table.column(accessor_name)
|
297
|
+
if accessor
|
298
|
+
return self.class.new(accessor,
|
299
|
+
:table => @table,
|
300
|
+
:column_name => accessor_name)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
object = @table.context[name]
|
305
|
+
if callable_object?(object)
|
306
|
+
return CallExpressionBuilder.new(object, self, *args)
|
270
307
|
end
|
308
|
+
|
309
|
+
super
|
271
310
|
end
|
272
311
|
end
|
273
312
|
|
@@ -331,6 +370,13 @@ module Groonga
|
|
331
370
|
end
|
332
371
|
end
|
333
372
|
|
373
|
+
# @private
|
374
|
+
class NotEqualExpressionBuilder < BinaryExpressionBuilder
|
375
|
+
def initialize(column_value_builder, value)
|
376
|
+
super(Groonga::Operation::NOT_EQUAL, column_value_builder, value)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
334
380
|
# @private
|
335
381
|
class MatchExpressionBuilder < BinaryExpressionBuilder
|
336
382
|
def initialize(column_value_builder, value)
|
@@ -461,8 +507,10 @@ module Groonga
|
|
461
507
|
expression.append_object(@function)
|
462
508
|
@arguments.each do |argument|
|
463
509
|
case argument
|
464
|
-
when String
|
510
|
+
when String, Integer, Time
|
465
511
|
expression.append_constant(argument)
|
512
|
+
when ::Hash
|
513
|
+
expression.append_object(argument)
|
466
514
|
else
|
467
515
|
argument.build(expression, variable)
|
468
516
|
end
|
@@ -595,6 +643,10 @@ module Groonga
|
|
595
643
|
column_expression_builder == other
|
596
644
|
end
|
597
645
|
|
646
|
+
def !=(other)
|
647
|
+
column_expression_builder != other
|
648
|
+
end
|
649
|
+
|
598
650
|
def =~(other)
|
599
651
|
column_expression_builder =~ other
|
600
652
|
end
|
@@ -666,7 +718,3 @@ module Groonga
|
|
666
718
|
end
|
667
719
|
end
|
668
720
|
end
|
669
|
-
|
670
|
-
if RUBY_VERSION >= "1.9"
|
671
|
-
require "groonga/expression-builder-19"
|
672
|
-
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -16,25 +14,19 @@
|
|
16
14
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
17
15
|
|
18
16
|
module Groonga
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
NotEqualExpressionBuilder.new(self, normalize(other))
|
23
|
-
end
|
24
|
-
end
|
17
|
+
class Index
|
18
|
+
attr_reader :column
|
19
|
+
attr_reader :section
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
super(Groonga::Operation::NOT_EQUAL, column_value_builder, value)
|
30
|
-
end
|
21
|
+
def initialize(column, section)
|
22
|
+
@column = column
|
23
|
+
@section = section
|
31
24
|
end
|
32
|
-
end
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
def ==(other)
|
27
|
+
other.is_a?(self.class) and
|
28
|
+
@column == other.column and
|
29
|
+
@section == other.section
|
38
30
|
end
|
39
31
|
end
|
40
32
|
end
|
data/lib/groonga/record.rb
CHANGED
data/lib/groonga.rb
CHANGED
data/lib/rroonga.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Copyright (C) 2016 Fumiaki MATSUSHIMA <mtsmfm@gmail.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
|
+
require "groonga"
|
data/rroonga-build.rb
CHANGED
@@ -18,17 +18,17 @@
|
|
18
18
|
|
19
19
|
module RroongaBuild
|
20
20
|
module RequiredGroongaVersion
|
21
|
-
MAJOR =
|
22
|
-
MINOR =
|
21
|
+
MAJOR = 6
|
22
|
+
MINOR = 0
|
23
23
|
MICRO = 0
|
24
24
|
VERSION = [MAJOR, MINOR, MICRO]
|
25
|
-
RELEASED_DATE = Time.utc(
|
25
|
+
RELEASED_DATE = Time.utc(2016, 2, 29)
|
26
26
|
end
|
27
27
|
|
28
28
|
module LatestGroongaVersion
|
29
|
-
MAJOR =
|
30
|
-
MINOR =
|
31
|
-
MICRO =
|
29
|
+
MAJOR = 6
|
30
|
+
MINOR = 0
|
31
|
+
MICRO = 0
|
32
32
|
VERSION = [MAJOR, MINOR, MICRO]
|
33
33
|
end
|
34
34
|
|
data/rroonga.gemspec
CHANGED
@@ -60,7 +60,7 @@ Gem::Specification.new do |s|
|
|
60
60
|
s.summary, s.description, = description.split(/\n\n+/, 3)
|
61
61
|
|
62
62
|
s.files = ["README.md", "AUTHORS", "Rakefile", "Gemfile", ".yardopts"]
|
63
|
-
s.files += Dir.glob("doc/text/*.
|
63
|
+
s.files += Dir.glob("doc/text/*.md")
|
64
64
|
s.files += Dir.glob("doc/images/*")
|
65
65
|
s.files += ["#{s.name}.gemspec"]
|
66
66
|
s.files += ["rroonga-build.rb", "extconf.rb"]
|
data/test/groonga-test-utils.rb
CHANGED
@@ -158,14 +158,6 @@ module GroongaTestUtils
|
|
158
158
|
actual.expression.inspect)
|
159
159
|
end
|
160
160
|
|
161
|
-
def ruby19?
|
162
|
-
RUBY_VERSION >= "1.9"
|
163
|
-
end
|
164
|
-
|
165
|
-
def only_ruby19
|
166
|
-
omit("Ruby 1.9 is needed.") unless ruby19?
|
167
|
-
end
|
168
|
-
|
169
161
|
def linux?
|
170
162
|
/linux/ =~ RUBY_PLATFORM
|
171
163
|
end
|
data/test/test-column.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
2
3
|
#
|
3
4
|
# This library is free software; you can redistribute it and/or
|
4
5
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -584,4 +585,109 @@ class ColumnTest < Test::Unit::TestCase
|
|
584
585
|
assert_equal(["title1"], select.call)
|
585
586
|
end
|
586
587
|
end
|
588
|
+
|
589
|
+
class FindIndexesTest < self
|
590
|
+
class NoOperatorTest < self
|
591
|
+
def setup
|
592
|
+
super
|
593
|
+
Groonga::Schema.define do |schema|
|
594
|
+
schema.create_table("Comments") do |table|
|
595
|
+
table.short_text("title")
|
596
|
+
table.short_text("body")
|
597
|
+
end
|
598
|
+
end
|
599
|
+
@title = Groonga["Comments.title"]
|
600
|
+
end
|
601
|
+
|
602
|
+
def test_nothing
|
603
|
+
assert_equal([], @title.find_indexes)
|
604
|
+
end
|
605
|
+
|
606
|
+
def test_one_index
|
607
|
+
Groonga::Schema.define do |schema|
|
608
|
+
schema.create_table("Terms",
|
609
|
+
:type => :patricia_trie,
|
610
|
+
:key_type => :short_text,
|
611
|
+
:default_tokenizer => "TokenBigram") do |table|
|
612
|
+
table.index("Comments.title")
|
613
|
+
end
|
614
|
+
end
|
615
|
+
assert_equal([
|
616
|
+
Groonga::Index.new(Groonga["Terms.Comments_title"], 0),
|
617
|
+
],
|
618
|
+
@title.find_indexes)
|
619
|
+
end
|
620
|
+
|
621
|
+
def test_multiple_indexes
|
622
|
+
Groonga::Schema.define do |schema|
|
623
|
+
schema.create_table("Terms",
|
624
|
+
:type => :patricia_trie,
|
625
|
+
:key_type => :short_text,
|
626
|
+
:default_tokenizer => "TokenBigram") do |table|
|
627
|
+
table.index("Comments.title")
|
628
|
+
end
|
629
|
+
|
630
|
+
schema.create_table("Titles",
|
631
|
+
:type => :hash,
|
632
|
+
:key_type => :short_text) do |table|
|
633
|
+
table.index("Comments.title")
|
634
|
+
end
|
635
|
+
end
|
636
|
+
assert_equal([
|
637
|
+
Groonga::Index.new(Groonga["Terms.Comments_title"], 0),
|
638
|
+
Groonga::Index.new(Groonga["Titles.Comments_title"], 0),
|
639
|
+
],
|
640
|
+
@title.find_indexes.sort_by {|index| index.column.name})
|
641
|
+
end
|
642
|
+
|
643
|
+
def test_multiple_column_index
|
644
|
+
Groonga::Schema.define do |schema|
|
645
|
+
schema.create_table("Terms",
|
646
|
+
:type => :patricia_trie,
|
647
|
+
:default_tokenizer => "TokenBigram") do |table|
|
648
|
+
table.index("Comments", "body", "title",
|
649
|
+
:name => "comments")
|
650
|
+
end
|
651
|
+
end
|
652
|
+
assert_equal([
|
653
|
+
Groonga::Index.new(Groonga["Terms.comments"], 2),
|
654
|
+
],
|
655
|
+
@title.find_indexes)
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
class OperatorTest < self
|
660
|
+
def setup
|
661
|
+
super
|
662
|
+
Groonga::Schema.define do |schema|
|
663
|
+
schema.create_table("Comments") do |table|
|
664
|
+
table.short_text("title")
|
665
|
+
table.short_text("body")
|
666
|
+
end
|
667
|
+
end
|
668
|
+
@title = Groonga["Comments.title"]
|
669
|
+
end
|
670
|
+
|
671
|
+
def test_equal
|
672
|
+
Groonga::Schema.define do |schema|
|
673
|
+
schema.create_table("Terms",
|
674
|
+
:type => :patricia_trie,
|
675
|
+
:key_type => :short_text,
|
676
|
+
:default_tokenizer => "TokenBigram") do |table|
|
677
|
+
table.index("Comments.title")
|
678
|
+
end
|
679
|
+
|
680
|
+
schema.create_table("Titles",
|
681
|
+
:type => :patricia_trie,
|
682
|
+
:key_type => :short_text) do |table|
|
683
|
+
table.index("Comments.title")
|
684
|
+
end
|
685
|
+
end
|
686
|
+
assert_equal([
|
687
|
+
Groonga::Index.new(Groonga["Titles.Comments_title"], 0),
|
688
|
+
],
|
689
|
+
@title.find_indexes(:operator => :equal))
|
690
|
+
end
|
691
|
+
end
|
692
|
+
end
|
587
693
|
end
|
data/test/test-config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Copyright (C) 2015-2016 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
2
3
|
#
|
3
4
|
# This library is free software; you can redistribute it and/or
|
4
5
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -28,4 +29,21 @@ class ConfigTest < Test::Unit::TestCase
|
|
28
29
|
assert_nil(context.config["nonexistent"])
|
29
30
|
end
|
30
31
|
end
|
32
|
+
|
33
|
+
test "#delete" do
|
34
|
+
context.config["rroonga.key"] = "value"
|
35
|
+
assert_equal("value", context.config["rroonga.key"])
|
36
|
+
context.config.delete("rroonga.key")
|
37
|
+
assert_nil(context.config["rroonga.key"])
|
38
|
+
end
|
39
|
+
|
40
|
+
test "#each" do
|
41
|
+
context.config["rroonga.key1"] = "value1"
|
42
|
+
context.config["rroonga.key2"] = "value2"
|
43
|
+
assert_equal([
|
44
|
+
["rroonga.key1", "value1"],
|
45
|
+
["rroonga.key2", "value2"],
|
46
|
+
],
|
47
|
+
context.config.to_a)
|
48
|
+
end
|
31
49
|
end
|
data/test/test-database.rb
CHANGED
@@ -71,8 +71,6 @@ class DatabaseTest < Test::Unit::TestCase
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_new
|
74
|
-
# TODO: remove the line when Groonga 5.0.5 released.
|
75
|
-
omit("This test is failing on Groonga 5.0.4.") if Groonga.version == "5.0.4"
|
76
74
|
assert_raise(Groonga::NoSuchFileOrDirectory) do
|
77
75
|
new_context = Groonga::Context.new
|
78
76
|
Groonga::Database.new(@database_path.to_s, :context => new_context)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Copyright (C) 2016 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 ErrorMessageTest < Test::Unit::TestCase
|
17
|
+
def test_nonexistent
|
18
|
+
assert_nil(Groonga.error_message)
|
19
|
+
end
|
20
|
+
end
|