rroonga 9.0.3 → 11.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/.yardopts +1 -0
- data/Rakefile +26 -135
- data/doc/text/news.md +79 -1
- data/doc/text/tutorial.md +1 -1
- data/ext/groonga/extconf.rb +19 -74
- data/ext/groonga/rb-grn-accessor.c +2 -2
- data/ext/groonga/rb-grn-column-cache.c +3 -3
- data/ext/groonga/rb-grn-column.c +4 -4
- data/ext/groonga/rb-grn-context.c +109 -58
- data/ext/groonga/rb-grn-data-column.c +4 -4
- data/ext/groonga/rb-grn-database.c +45 -26
- data/ext/groonga/rb-grn-double-array-trie.c +2 -2
- data/ext/groonga/rb-grn-encoding-support.c +2 -2
- data/ext/groonga/rb-grn-exception.c +14 -0
- data/ext/groonga/rb-grn-expression-builder.c +3 -3
- data/ext/groonga/rb-grn-expression.c +3 -3
- data/ext/groonga/rb-grn-fix-size-column.c +2 -2
- data/ext/groonga/rb-grn-flushable.c +9 -1
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +30 -2
- data/ext/groonga/rb-grn-index-cursor.c +21 -2
- data/ext/groonga/rb-grn-inverted-index-cursor.c +3 -3
- data/ext/groonga/rb-grn-logger.c +17 -3
- data/ext/groonga/rb-grn-object.c +266 -31
- data/ext/groonga/rb-grn-operator.c +100 -259
- data/ext/groonga/rb-grn-patricia-trie.c +2 -2
- data/ext/groonga/rb-grn-plugin.c +34 -22
- data/ext/groonga/rb-grn-request-timer-id.c +2 -2
- data/ext/groonga/rb-grn-snippet.c +3 -3
- data/ext/groonga/rb-grn-table-cursor-key-support.c +2 -2
- data/ext/groonga/rb-grn-table-cursor.c +3 -3
- data/ext/groonga/rb-grn-table-key-support.c +28 -9
- data/ext/groonga/rb-grn-table.c +180 -130
- data/ext/groonga/rb-grn-type.c +5 -1
- data/ext/groonga/rb-grn-utils.c +17 -1
- data/ext/groonga/rb-grn-variable-size-column.c +2 -2
- data/ext/groonga/rb-grn-variable.c +2 -2
- data/ext/groonga/rb-grn.h +11 -14
- data/ext/groonga/rb-groonga.c +6 -2
- data/lib/groonga.rb +3 -7
- data/lib/groonga/context.rb +32 -0
- data/lib/groonga/dumper.rb +3 -0
- data/lib/groonga/record.rb +2 -2
- data/rroonga-build.rb +5 -4
- data/rroonga.gemspec +8 -6
- data/test/groonga-test-utils.rb +37 -5
- data/test/run-test.rb +1 -3
- data/test/test-accessor.rb +63 -7
- data/test/test-column.rb +12 -1
- data/test/test-context.rb +25 -0
- data/test/test-exception.rb +5 -0
- data/test/test-flushable.rb +51 -6
- data/test/test-index-column.rb +70 -9
- data/test/test-index-cursor.rb +26 -0
- data/test/test-logger.rb +56 -11
- data/test/test-plugin.rb +1 -0
- data/test/test-query-logger.rb +4 -3
- data/test/test-ractor.rb +65 -0
- data/test/test-record.rb +2 -1
- data/test/test-remote.rb +58 -10
- data/test/test-schema-dumper.rb +13 -0
- data/test/test-schema.rb +9 -1
- data/test/test-table-arrow.rb +22 -10
- data/test/test-table.rb +21 -1
- data/test/test-variable.rb +23 -7
- metadata +72 -97
data/ext/groonga/rb-grn-type.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-2020 Sutou Kouhei <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
|
@@ -304,6 +304,10 @@ rb_grn_init_type (VALUE mGrn)
|
|
304
304
|
rb_define_const(rb_cGrnType, "INT64", INT2NUM(GRN_DB_INT64));
|
305
305
|
/* 64bit符号なし整数。 */
|
306
306
|
rb_define_const(rb_cGrnType, "UINT64", INT2NUM(GRN_DB_UINT64));
|
307
|
+
#if RB_GRN_HAVE_FLOAT32
|
308
|
+
/* 32bit floating pointer number in IEEE754 format. */
|
309
|
+
rb_define_const(rb_cGrnType, "FLOAT32", INT2NUM(GRN_DB_FLOAT32));
|
310
|
+
#endif
|
307
311
|
/* ieee754形式の64bit浮動小数点数。 */
|
308
312
|
rb_define_const(rb_cGrnType, "FLOAT", INT2NUM(GRN_DB_FLOAT));
|
309
313
|
/* 1970年1月1日0時0分0秒からの経過マイクロ秒数を64bit符
|
data/ext/groonga/rb-grn-utils.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/* vim: set sts=4 sw=4 ts=8 noet: */
|
3
3
|
/*
|
4
|
-
Copyright (C) 2009-
|
4
|
+
Copyright (C) 2009-2020 Sutou Kouhei <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
|
@@ -201,6 +201,11 @@ rb_grn_bulk_to_ruby_object_by_range_id (grn_ctx *context, grn_obj *bulk,
|
|
201
201
|
case GRN_DB_UINT64:
|
202
202
|
*rb_value = ULL2NUM(GRN_UINT64_VALUE(bulk));
|
203
203
|
break;
|
204
|
+
#if RB_GRN_HAVE_FLOAT32
|
205
|
+
case GRN_DB_FLOAT32:
|
206
|
+
*rb_value = rb_float_new(GRN_FLOAT32_VALUE(bulk));
|
207
|
+
break;
|
208
|
+
#endif
|
204
209
|
case GRN_DB_FLOAT:
|
205
210
|
*rb_value = rb_float_new(GRN_FLOAT_VALUE(bulk));
|
206
211
|
break;
|
@@ -447,6 +452,7 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
447
452
|
int64_t int64_value;
|
448
453
|
uint64_t uint64_value;
|
449
454
|
int64_t time_value;
|
455
|
+
float float_value;
|
450
456
|
double double_value;
|
451
457
|
grn_geo_point geo_point_value;
|
452
458
|
grn_id record_id;
|
@@ -525,6 +531,16 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
525
531
|
string = (const char *)&(value.uint64_value);
|
526
532
|
size = sizeof(value.uint64_value);
|
527
533
|
break;
|
534
|
+
#if RB_GRN_HAVE_FLOAT32
|
535
|
+
case GRN_DB_FLOAT32:
|
536
|
+
if (string_p) {
|
537
|
+
object = rb_Float(object);
|
538
|
+
}
|
539
|
+
value.float_value = NUM2DBL(object);
|
540
|
+
string = (const char *)&(value.float_value);
|
541
|
+
size = sizeof(value.float_value);
|
542
|
+
break;
|
543
|
+
#endif
|
528
544
|
case GRN_DB_FLOAT:
|
529
545
|
if (string_p) {
|
530
546
|
object = rb_Float(object);
|
@@ -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-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include "rb-grn.h"
|
21
21
|
|
22
|
-
#define SELF(object) ((RbGrnVariableSizeColumn *)
|
22
|
+
#define SELF(object) ((RbGrnVariableSizeColumn *)RTYPEDDATA_DATA(object))
|
23
23
|
|
24
24
|
VALUE rb_cGrnVariableSizeColumn;
|
25
25
|
|
@@ -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 Kouhei
|
3
|
+
Copyright (C) 2009-2021 Sutou Kouhei <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
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "rb-grn.h"
|
20
20
|
|
21
|
-
#define SELF(object) ((RbGrnVariable *)
|
21
|
+
#define SELF(object) ((RbGrnVariable *)RTYPEDDATA_DATA(object))
|
22
22
|
|
23
23
|
VALUE rb_cGrnVariable;
|
24
24
|
|
data/ext/groonga/rb-grn.h
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-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2015-2017 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -73,17 +73,9 @@ RB_GRN_BEGIN_DECLS
|
|
73
73
|
# define RB_GRN_GNUC_NULL_TERMINATED
|
74
74
|
#endif
|
75
75
|
|
76
|
-
#
|
77
|
-
# define RB_GRN_PLATFORM_WIN32 RUBY_GRN_PLATFORM_WIN32
|
78
|
-
#endif
|
79
|
-
|
80
|
-
#if defined(RUBY_GRN_STATIC_COMPILATION) && !defined(RB_GRN_STATIC_COMPILATION)
|
81
|
-
# define RB_GRN_STATIC_COMPILATION RUBY_GRN_STATIC_COMPILATION
|
82
|
-
#endif
|
83
|
-
|
84
|
-
#if defined(RB_GRN_PLATFORM_WIN32) && !defined(RB_GRN_STATIC_COMPILATION)
|
76
|
+
#ifdef __WIN32__
|
85
77
|
# ifdef RB_GRN_COMPILATION
|
86
|
-
# define RB_GRN_VAR __declspec(dllexport)
|
78
|
+
# define RB_GRN_VAR extern __declspec(dllexport)
|
87
79
|
# else
|
88
80
|
# define RB_GRN_VAR extern __declspec(dllimport)
|
89
81
|
# endif
|
@@ -97,9 +89,11 @@ RB_GRN_BEGIN_DECLS
|
|
97
89
|
# define debug(...)
|
98
90
|
#endif
|
99
91
|
|
100
|
-
#define
|
92
|
+
#define RB_GRN_HAVE_FLOAT32 GRN_VERSION_OR_LATER(10, 0, 2)
|
93
|
+
|
94
|
+
#define RB_GRN_MAJOR_VERSION 11
|
101
95
|
#define RB_GRN_MINOR_VERSION 0
|
102
|
-
#define RB_GRN_MICRO_VERSION
|
96
|
+
#define RB_GRN_MICRO_VERSION 0
|
103
97
|
|
104
98
|
#define RB_GRN_OBJECT(object) ((RbGrnObject *)(object))
|
105
99
|
#define RB_GRN_NAMED_OBJECT(object) ((RbGrnNamedObject *)(object))
|
@@ -320,6 +314,8 @@ RB_GRN_VAR VALUE rb_mGrnRequestTimer;
|
|
320
314
|
RB_GRN_VAR VALUE rb_cGrnRequestTimerID;
|
321
315
|
RB_GRN_VAR VALUE rb_cGrnColumnCache;
|
322
316
|
|
317
|
+
RB_GRN_VAR rb_data_type_t rb_grn_object_data_type;
|
318
|
+
|
323
319
|
void rb_grn_init_utils (VALUE mGrn);
|
324
320
|
void rb_grn_init_exception (VALUE mGrn);
|
325
321
|
void rb_grn_init_encoding (VALUE mGrn);
|
@@ -785,7 +781,8 @@ rb_encoding *rb_grn_encoding_to_ruby_encoding (grn_encoding encoding);
|
|
785
781
|
VALUE rb_grn_encoding_to_ruby_encoding_object
|
786
782
|
(grn_encoding encoding);
|
787
783
|
|
788
|
-
|
784
|
+
RbGrnContext *rb_grn_context_get_struct (VALUE rb_context);
|
785
|
+
grn_ctx *rb_grn_context_from_ruby_object (VALUE rb_context);
|
789
786
|
VALUE rb_grn_context_to_ruby_object (grn_ctx *context);
|
790
787
|
VALUE rb_grn_context_rb_string_new (grn_ctx *context,
|
791
788
|
const char *string,
|
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-2021 Sutou Kouhei <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
|
@@ -22,7 +22,7 @@
|
|
22
22
|
grn_bool rb_grn_exited = GRN_FALSE;
|
23
23
|
|
24
24
|
static VALUE
|
25
|
-
finish_groonga (
|
25
|
+
finish_groonga (RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
|
26
26
|
{
|
27
27
|
debug("finish\n");
|
28
28
|
grn_fin();
|
@@ -205,6 +205,10 @@ rb_grn_init_package_label (VALUE mGrn)
|
|
205
205
|
void
|
206
206
|
Init_groonga (void)
|
207
207
|
{
|
208
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
209
|
+
rb_ext_ractor_safe(true);
|
210
|
+
#endif
|
211
|
+
|
208
212
|
VALUE mGrn;
|
209
213
|
|
210
214
|
mGrn = rb_define_module("Groonga");
|
data/lib/groonga.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2020 Sutou Kouhei <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
|
@@ -44,12 +44,8 @@ require "groonga/record"
|
|
44
44
|
require "groonga/expression-builder"
|
45
45
|
require "groonga/posting"
|
46
46
|
require "groonga/index"
|
47
|
-
|
48
|
-
|
49
|
-
require "#{major}.#{minor}/groonga.so"
|
50
|
-
rescue LoadError
|
51
|
-
require "groonga.so"
|
52
|
-
end
|
47
|
+
|
48
|
+
require "groonga.so"
|
53
49
|
|
54
50
|
##
|
55
51
|
# rroonga用のネームスペース。rroongaのクラスやメソッ
|
data/lib/groonga/context.rb
CHANGED
@@ -20,6 +20,38 @@ require "groonga/context/command-executor"
|
|
20
20
|
|
21
21
|
module Groonga
|
22
22
|
class Context
|
23
|
+
class << self
|
24
|
+
# Opens a new context. If block is given, the opened context is
|
25
|
+
# closed automatically after the given block is evaluated.
|
26
|
+
#
|
27
|
+
# @overload open(*args, &block)
|
28
|
+
# @param args [::Array<Object>] Passed through to
|
29
|
+
# {Groonga::Context#initialize}.
|
30
|
+
# @yieldparam context [Groonga::Context] The newly created context.
|
31
|
+
# @return [Object] The return value of the given block is the
|
32
|
+
# return value of the call.
|
33
|
+
#
|
34
|
+
# @overload open(*args)
|
35
|
+
# @param args [::Array<Object>] Passed through to
|
36
|
+
# {Groonga::Context#initialize}.
|
37
|
+
# @yieldparam context [Groonga::Context] The newly created context.
|
38
|
+
# @return [Groonga::Context] The newly created context.
|
39
|
+
#
|
40
|
+
# @see Groonga::Context#initialize
|
41
|
+
def open(*args, **kwargs)
|
42
|
+
context = new(*args, **kwargs)
|
43
|
+
if block_given?
|
44
|
+
begin
|
45
|
+
yield(context)
|
46
|
+
ensure
|
47
|
+
context.close
|
48
|
+
end
|
49
|
+
else
|
50
|
+
context
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
23
55
|
# _path_ にある既存のデータベースを開く。ブロックを指定した場
|
24
56
|
# 合はブロックに開いたデータベースを渡し、ブロックを抜けると
|
25
57
|
# きに閉じる。
|
data/lib/groonga/dumper.rb
CHANGED
@@ -491,6 +491,8 @@ module Groonga
|
|
491
491
|
options[:size] = :small
|
492
492
|
elsif column.medium?
|
493
493
|
options[:size] = :medium
|
494
|
+
elsif column.large?
|
495
|
+
options[:size] = :large
|
494
496
|
end
|
495
497
|
arguments = [
|
496
498
|
dump_object(target_table_name),
|
@@ -652,6 +654,7 @@ module Groonga
|
|
652
654
|
flags << "WITH_POSITION" if column.with_position?
|
653
655
|
flags << "INDEX_SMALL" if column.small?
|
654
656
|
flags << "INDEX_MEDIUM" if column.medium?
|
657
|
+
flags << "INDEX_LARGE" if column.large?
|
655
658
|
parameters << "#{flags.join('|')}"
|
656
659
|
parameters << "#{column.range.name}"
|
657
660
|
source_names = column.sources.collect do |source|
|
data/lib/groonga/record.rb
CHANGED
@@ -205,10 +205,10 @@ module Groonga
|
|
205
205
|
self["_score"] = new_score
|
206
206
|
end
|
207
207
|
|
208
|
-
# {Groonga::Record#score} が利用できる場合は
|
208
|
+
# {Groonga::Record#score} が利用できる場合は `true` を
|
209
209
|
# 返す。
|
210
210
|
def support_score?
|
211
|
-
@table.
|
211
|
+
@table.support_score?
|
212
212
|
end
|
213
213
|
|
214
214
|
# 主キーの値が同一であったレコードの件数を返す。検索結果とし
|
data/rroonga-build.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2021 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
# Copyright (C) 2015-2017 Masafumi Yokoyama <yokoyama@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
@@ -16,11 +16,12 @@
|
|
16
16
|
|
17
17
|
module RroongaBuild
|
18
18
|
module RequiredGroongaVersion
|
19
|
-
MAJOR =
|
19
|
+
MAJOR = 11
|
20
20
|
MINOR = 0
|
21
|
-
MICRO =
|
21
|
+
MICRO = 0
|
22
22
|
VERSION = [MAJOR, MINOR, MICRO]
|
23
|
-
|
23
|
+
STRING = VERSION.join(".")
|
24
|
+
RELEASED_DATE = Time.utc(2021, 2, 9)
|
24
25
|
end
|
25
26
|
|
26
27
|
module_function
|
data/rroonga.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# -*-
|
1
|
+
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012-
|
3
|
+
# Copyright (C) 2012-2020 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
# Copyright (C) 2017 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
#
|
6
6
|
# This library is free software; you can redistribute it and/or
|
@@ -17,6 +17,7 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
require "English"
|
20
|
+
require_relative "rroonga-build"
|
20
21
|
|
21
22
|
base_dir = File.dirname(__FILE__)
|
22
23
|
ext_dir = File.join(base_dir, "ext", "groonga")
|
@@ -82,17 +83,18 @@ Gem::Specification.new do |s|
|
|
82
83
|
|
83
84
|
s.required_ruby_version = ">= 1.9.3"
|
84
85
|
|
85
|
-
s.add_runtime_dependency("pkg-config")
|
86
86
|
s.add_runtime_dependency("groonga-client", ">= 0.0.3")
|
87
87
|
s.add_runtime_dependency("json")
|
88
|
-
s.add_runtime_dependency("
|
88
|
+
s.add_runtime_dependency("native-package-installer")
|
89
|
+
s.add_runtime_dependency("pkg-config")
|
89
90
|
s.add_development_dependency("test-unit", [">= 3.0.0"])
|
90
91
|
s.add_development_dependency("rake")
|
91
|
-
s.add_development_dependency("rake-compiler", [">= 0.9.5"])
|
92
|
-
s.add_development_dependency("rake-compiler-dock", [">= 0.6.2"])
|
93
92
|
s.add_development_dependency("bundler")
|
94
93
|
s.add_development_dependency("yard")
|
95
94
|
s.add_development_dependency("packnga", [">= 1.0.0"])
|
96
95
|
s.add_development_dependency("kramdown")
|
96
|
+
|
97
|
+
required_groonga_version = RroongaBuild::RequiredGroongaVersion::STRING
|
98
|
+
s.metadata["msys2_mingw_dependencies"] = "groonga>=#{required_groonga_version}"
|
97
99
|
end
|
98
100
|
|
data/test/groonga-test-utils.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2015 Masafumi Yokoyama <yokoyama@clear-code.com>
|
2
|
-
# Copyright (C) 2009-
|
2
|
+
# Copyright (C) 2009-2019 Kouhei Sutou <kou@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
5
5
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -14,13 +14,16 @@
|
|
14
14
|
# License along with this library; if not, write to the Free Software
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
|
+
require "erb"
|
17
18
|
require "fileutils"
|
19
|
+
require "json"
|
18
20
|
require "pathname"
|
21
|
+
require "stringio"
|
19
22
|
require "tempfile"
|
20
23
|
require "time"
|
21
|
-
require "
|
22
|
-
|
23
|
-
require "
|
24
|
+
require "timeout"
|
25
|
+
|
26
|
+
require "groonga/client"
|
24
27
|
require "pkg-config"
|
25
28
|
|
26
29
|
require "groonga"
|
@@ -44,7 +47,7 @@ module GroongaTestUtils
|
|
44
47
|
setup_context
|
45
48
|
|
46
49
|
@database = nil
|
47
|
-
name_for_path = name
|
50
|
+
name_for_path = escape_path(name)
|
48
51
|
@database_path = @tmp_dir + "#{name_for_path}.db"
|
49
52
|
end
|
50
53
|
|
@@ -69,9 +72,11 @@ module GroongaTestUtils
|
|
69
72
|
|
70
73
|
@log_path = @tmp_dir + "groonga.log"
|
71
74
|
Groonga::Logger.path = @log_path.to_s
|
75
|
+
Groonga::Logger.reopen
|
72
76
|
|
73
77
|
@query_log_path = @tmp_dir + "groonga-query.log"
|
74
78
|
Groonga::QueryLogger.path = @query_log_path.to_s
|
79
|
+
Groonga::QueryLogger.reopen
|
75
80
|
end
|
76
81
|
|
77
82
|
def setup_tables_directory
|
@@ -107,6 +112,14 @@ module GroongaTestUtils
|
|
107
112
|
end
|
108
113
|
end
|
109
114
|
|
115
|
+
def collect_query_log
|
116
|
+
@query_log_path.open do |file|
|
117
|
+
file.seek(0, IO::SEEK_END)
|
118
|
+
yield
|
119
|
+
file.read
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
110
123
|
def setup_database
|
111
124
|
@database = Groonga::Database.create(:path => @database_path.to_s)
|
112
125
|
end
|
@@ -127,6 +140,9 @@ module GroongaTestUtils
|
|
127
140
|
end
|
128
141
|
|
129
142
|
def teardown_log_path
|
143
|
+
Groonga::Logger.path = nil
|
144
|
+
Groonga::QueryLogger.path = nil
|
145
|
+
|
130
146
|
return unless @dump_log
|
131
147
|
if @log_path.exist?(log_path)
|
132
148
|
header = "--- log: #{@log_path} ---"
|
@@ -155,6 +171,12 @@ module GroongaTestUtils
|
|
155
171
|
actual.expression.inspect)
|
156
172
|
end
|
157
173
|
|
174
|
+
def escape_path(path)
|
175
|
+
path.gsub(/[: ?!\(\)\[\]]/) do
|
176
|
+
"_"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
158
180
|
def linux?
|
159
181
|
/linux/ =~ RUBY_PLATFORM
|
160
182
|
end
|
@@ -167,6 +189,10 @@ module GroongaTestUtils
|
|
167
189
|
/cygwin|mingw|mswin/ === RUBY_PLATFORM
|
168
190
|
end
|
169
191
|
|
192
|
+
def only_not_windows
|
193
|
+
omit("This test is only for non Windows system.") if windows?
|
194
|
+
end
|
195
|
+
|
170
196
|
def support_self_recursive_equal?
|
171
197
|
self_recursive_hash1 = {}
|
172
198
|
self_recursive_hash1["next"] = self_recursive_hash1
|
@@ -186,4 +212,10 @@ module GroongaTestUtils
|
|
186
212
|
def check_mecab_availability
|
187
213
|
omit("MeCab isn't available") if context["TokenMecab"].nil?
|
188
214
|
end
|
215
|
+
|
216
|
+
def need_groonga(major, minor, micro)
|
217
|
+
if (Groonga::BUILD_VERSION[0, 3] <=> [major, minor, micro]) < 0
|
218
|
+
omit("Groonga #{major}.#{minor}.#{micro} or later is required")
|
219
|
+
end
|
220
|
+
end
|
189
221
|
end
|