rroonga 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 450be499e880c47f2314a3857389a9cf8dc09c25
4
- data.tar.gz: b604764debc83c0b075de9becc94c04ac2f2a409
3
+ metadata.gz: 44cd8bad828ac3e88850ece173cadfa91bf63cbe
4
+ data.tar.gz: 2879bf2d247b4d6b316007244a3f17df66b4525c
5
5
  SHA512:
6
- metadata.gz: 4a77d83e9f7f4d53da85d686d334a16fe2c5af57cf475d0774bf8f6477576657512dde969a0e915f79e38e43b68499dbde32784e917e8a33bb5d5a04c06ed2cc
7
- data.tar.gz: 96148756e41053414d8bacc15f69262e6d7f4d0eac8f44ec318619641e29260e0d263430f25b1964f3d4f94225e5617fac5a793c141be3f5f51d1f9a650fe599
6
+ metadata.gz: c034fa1b10202553bb36e4f869921555f09c84fc633ff8ec1c14c9fc3c2631caf659a265dba4c6ec56bb6e63d8f3117aaf70ff1a327a517433b8b5136cb2c9b5
7
+ data.tar.gz: 74c9dc1f95d9fdba1f24aa477fade11fdf8c2d79e9e7d12da350c4bbb8482ce431dc1a2f5a371f96ef0b4622cd878ec8c0d9e2ce3067241772ab50dedcd0cf0c
data/bin/grndump CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
3
  #
4
- # Copyright (C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
4
+ # Copyright (C) 2011-2014 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
@@ -26,6 +26,7 @@ options = OpenStruct.new
26
26
  options.tables = []
27
27
  options.exclude_tables = []
28
28
  options.dump_schema = true
29
+ options.dump_indexes = true
29
30
  options.dump_tables = true
30
31
  options.order_by = "id"
31
32
  option_parser = OptionParser.new do |parser|
@@ -37,6 +38,11 @@ option_parser = OptionParser.new do |parser|
37
38
  options.dump_schema = boolean
38
39
  end
39
40
 
41
+ parser.on("--no-dump-indexes",
42
+ "don't dump indexes.") do |boolean|
43
+ options.dump_indexes = boolean
44
+ end
45
+
40
46
  parser.on("--no-dump-tables",
41
47
  "don't dump tables.") do |boolean|
42
48
  options.dump_tables = boolean
@@ -88,6 +94,7 @@ dumper_options = {
88
94
  :output => $stdout,
89
95
  :error_output => $stderr,
90
96
  :dump_schema => options.dump_schema,
97
+ :dump_indexes => options.dump_indexes,
91
98
  :dump_tables => options.dump_tables,
92
99
  :tables => options.tables,
93
100
  :exclude_tables => options.exclude_tables,
@@ -1,5 +1,25 @@
1
1
  h1. NEWS
2
2
 
3
+ h2(#3-1-2). 3.1.2: 2014-01-29
4
+
5
+ h3. Improvements
6
+
7
+ * Supported Groonga 3.1.2. Groonga 3.1.1 or older are not supported.
8
+ * Added {Groonga::Table#support_value?}.
9
+ * Added {Groonga::Record#support_value?}.
10
+ * Added @_value@ value to {Groonga::Record#attributes} result.
11
+ [groonga-dev,02046] [Suggested by ongaeshi]
12
+ * Added column values to {Groonga::Record#inspect} result.
13
+ [groonga-dev,02048] [Suggested by ongaeshi]
14
+ * grndump: Added @--dump-indexes@ option that controls schema for
15
+ indexes output. It is useful to dump only schema for indexes.
16
+ * Added {Groonga.lock_timeout}.
17
+ * Added {Groonga.lock_timeout=}.
18
+
19
+ h3. Thanks
20
+
21
+ * ongaeshi
22
+
3
23
  h2(#3-1-1). 3.1.1: 2013-12-29
4
24
 
5
25
  h3. Improvements
@@ -2282,6 +2282,24 @@ rb_grn_table_support_key_p (VALUE self)
2282
2282
  return Qfalse;
2283
2283
  }
2284
2284
 
2285
+ /*
2286
+ * @overload support_value?
2287
+ *
2288
+ * @return @true@ if the table is created with value type, @false@
2289
+ * otherwise.
2290
+ */
2291
+ static VALUE
2292
+ rb_grn_table_support_value_p (VALUE self)
2293
+ {
2294
+ grn_id range_id;
2295
+
2296
+ rb_grn_table_deconstruct(SELF(self), NULL, NULL,
2297
+ NULL, NULL,
2298
+ NULL, &range_id, NULL,
2299
+ NULL);
2300
+ return CBOOL2RVAL(range_id != GRN_ID_NIL);
2301
+ }
2302
+
2285
2303
  /*
2286
2304
  * グループ化したとき、テーブルにグループに含まれるレコード
2287
2305
  * 数を格納できる場合は +true+ 、格納できない場合は +false+ を返
@@ -2503,6 +2521,8 @@ rb_grn_init_table (VALUE mGrn)
2503
2521
 
2504
2522
  rb_define_method(rb_cGrnTable, "support_key?",
2505
2523
  rb_grn_table_support_key_p, 0);
2524
+ rb_define_method(rb_cGrnTable, "support_value?",
2525
+ rb_grn_table_support_value_p, 0);
2506
2526
  rb_define_method(rb_cGrnTable, "support_sub_records?",
2507
2527
  rb_grn_table_support_sub_records_p, 0);
2508
2528
  rb_define_method(rb_cGrnTable, "have_n_sub_records_space?",
data/ext/groonga/rb-grn.h CHANGED
@@ -84,7 +84,7 @@ RB_GRN_BEGIN_DECLS
84
84
 
85
85
  #define RB_GRN_MAJOR_VERSION 3
86
86
  #define RB_GRN_MINOR_VERSION 1
87
- #define RB_GRN_MICRO_VERSION 1
87
+ #define RB_GRN_MICRO_VERSION 2
88
88
 
89
89
  #define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
90
90
 
@@ -107,6 +107,47 @@ rb_grn_init_version (VALUE mGrn)
107
107
  rb_define_const(mGrn, "BINDINGS_VERSION", bindings_version);
108
108
  }
109
109
 
110
+ /*
111
+ * Returns the current lock timeout.
112
+ *
113
+ * See
114
+ * http://groonga.org/docs/reference/api/global_configurations.html
115
+ * about lock timeout.
116
+ *
117
+ * @overload lock_timeout
118
+ * @return [Integer] The current lock timeout.
119
+ */
120
+ static VALUE
121
+ rb_grn_s_get_lock_timeout (VALUE klass)
122
+ {
123
+ return INT2NUM(grn_get_lock_timeout());
124
+ }
125
+
126
+ /*
127
+ * Sets the current lock timeout.
128
+ *
129
+ * @overload lock_timeout=(timeout)
130
+ * @param [Integer] timeout The new lock timeout.
131
+ *
132
+ * @see {#lock_timeout}
133
+ * @since 3.1.2
134
+ */
135
+ static VALUE
136
+ rb_grn_s_set_lock_timeout (VALUE klass, VALUE timeout)
137
+ {
138
+ grn_set_lock_timeout(NUM2INT(timeout));
139
+ return Qnil;
140
+ }
141
+
142
+ static void
143
+ rb_grn_init_lock_timeout (VALUE mGrn)
144
+ {
145
+ rb_define_singleton_method(mGrn, "lock_timeout",
146
+ rb_grn_s_get_lock_timeout, 0);
147
+ rb_define_singleton_method(mGrn, "lock_timeout=",
148
+ rb_grn_s_set_lock_timeout, 1);
149
+ }
150
+
110
151
  void
111
152
  Init_groonga (void)
112
153
  {
@@ -120,6 +161,7 @@ Init_groonga (void)
120
161
  rb_set_end_proc(finish_groonga, Qnil);
121
162
 
122
163
  rb_grn_init_version(mGrn);
164
+ rb_grn_init_lock_timeout(mGrn);
123
165
 
124
166
  rb_grn_init_utils(mGrn);
125
167
  rb_grn_init_encoding(mGrn);
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2011-2014 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
@@ -55,11 +55,15 @@ module Groonga
55
55
  options[:database] = options[:context].database
56
56
  end
57
57
  options[:dump_schema] = true if options[:dump_schema].nil?
58
+ options[:dump_indexes] = true if options[:dump_indexes].nil?
58
59
  options[:dump_tables] = true if options[:dump_tables].nil?
59
60
 
61
+ if options[:dump_schema] or options[:dump_indexes]
62
+ schema_dumper = SchemaDumper.new(options.merge(:syntax => :command))
63
+ end
64
+
60
65
  if options[:dump_schema]
61
66
  dump_plugins(options)
62
- schema_dumper = SchemaDumper.new(options.merge(:syntax => :command))
63
67
  schema_dumper.dump_tables
64
68
  if schema_dumper.have_reference_columns?
65
69
  options[:output].write("\n")
@@ -67,7 +71,7 @@ module Groonga
67
71
  end
68
72
  end
69
73
  dump_tables(options) if options[:dump_tables]
70
- if options[:dump_schema] and schema_dumper.have_index_columns?
74
+ if options[:dump_indexes] and schema_dumper.have_index_columns?
71
75
  options[:output].write("\n")
72
76
  schema_dumper.dump_index_columns
73
77
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2009-2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2009-2014 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
@@ -117,6 +117,12 @@ module Groonga
117
117
  @table.support_key?
118
118
  end
119
119
 
120
+ # @return @true@ if the table that the record belongs to is
121
+ # created with value type, @false@ otherwise.
122
+ def support_value?
123
+ @table.support_value?
124
+ end
125
+
120
126
  # 名前が _name_ のカラムがレコードの所属するテーブルで定義され
121
127
  # ているなら +true+ を返す。
122
128
  def have_column?(name)
@@ -344,6 +350,11 @@ module Groonga
344
350
  @added = added
345
351
  end
346
352
 
353
+ # @private
354
+ def inspect
355
+ super.gsub(/>\z/, ", attributes: #{attributes.inspect}>")
356
+ end
357
+
347
358
  private
348
359
  def normalize_column_name(name)
349
360
  name.to_s
@@ -429,6 +440,7 @@ module Groonga
429
440
 
430
441
  add_id(attributes, record)
431
442
  add_key(attributes, record)
443
+ add_value(attributes, record)
432
444
  add_score(attributes, record)
433
445
  add_n_sub_records(attributes, record)
434
446
  add_columns(attributes, record)
@@ -482,6 +494,12 @@ module Groonga
482
494
  end
483
495
  end
484
496
 
497
+ def add_value(attributes, record)
498
+ if record.support_value?
499
+ attributes["_value"] = build_value(record.value)
500
+ end
501
+ end
502
+
485
503
  def add_score(attributes, record)
486
504
  if record.support_score?
487
505
  attributes["_score"] = record.score
data/rroonga-build.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Copyright (C) 2009-2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2009-2014 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
@@ -18,16 +18,16 @@
18
18
  module RroongaBuild
19
19
  module RequiredGroongaVersion
20
20
  MAJOR = 3
21
- MINOR = 0
22
- MICRO = 8
21
+ MINOR = 1
22
+ MICRO = 2
23
23
  VERSION = [MAJOR, MINOR, MICRO]
24
- RELEASED_DATE = Time.utc(2013, 9, 29)
24
+ RELEASED_DATE = Time.utc(2014, 1, 29)
25
25
  end
26
26
 
27
27
  module LatestGroongaVersion
28
28
  MAJOR = 3
29
29
  MINOR = 1
30
- MICRO = 1
30
+ MICRO = 2
31
31
  VERSION = [MAJOR, MINOR, MICRO]
32
32
  end
33
33
 
data/test/test-array.rb CHANGED
@@ -22,6 +22,19 @@ class ArrayTest < Test::Unit::TestCase
22
22
  assert_not_predicate(Groonga::Array.create(:name => "Users"), :support_key?)
23
23
  end
24
24
 
25
+ class SupportValueTest < self
26
+ def test_have_value_type
27
+ assert_predicate(Groonga::Array.create(:name => "Users",
28
+ :value_type => "Int32"),
29
+ :support_value?)
30
+ end
31
+
32
+ def test_no_value_type
33
+ assert_not_predicate(Groonga::Array.create(:name => "Users"),
34
+ :support_value?)
35
+ end
36
+ end
37
+
25
38
  def test_inspect_size
26
39
  path = @tables_dir + "named.groonga"
27
40
  contain_table = Groonga::Array.create(:name => "name", :path => path.to_s)
@@ -108,7 +121,7 @@ class ArrayTest < Test::Unit::TestCase
108
121
  users.add(:name => "user #{i}" * 1000,
109
122
  :address => "address #{i}" * 1000)
110
123
  end
111
- assert_equal(7, users.defrag)
124
+ assert_equal(3, users.defrag)
112
125
  end
113
126
 
114
127
  def test_rename
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011-2013 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2011-2014 Kouhei Sutou <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
@@ -69,17 +69,17 @@ class DatabaseDumperTest < Test::Unit::TestCase
69
69
  end
70
70
 
71
71
  def dumped_schema
72
- <<-EOS
72
+ <<-SCHEMA
73
73
  #{dumped_schema_tables}
74
74
 
75
75
  #{dumped_schema_reference_columns}
76
76
 
77
77
  #{dumped_schema_index_columns}
78
- EOS
78
+ SCHEMA
79
79
  end
80
80
 
81
81
  def dumped_schema_tables
82
- <<-EOS.chomp
82
+ <<-SCHEMA.chomp
83
83
  table_create Posts TABLE_NO_KEY
84
84
  column_create Posts created_at COLUMN_SCALAR Time
85
85
  column_create Posts n_goods COLUMN_SCALAR UInt32
@@ -93,22 +93,22 @@ column_create Tags name COLUMN_SCALAR Text
93
93
 
94
94
  table_create Users TABLE_HASH_KEY --key_type ShortText
95
95
  column_create Users name COLUMN_SCALAR Text
96
- EOS
96
+ SCHEMA
97
97
  end
98
98
 
99
99
  def dumped_schema_reference_columns
100
- <<-EOS.chomp
100
+ <<-SCHEMA.chomp
101
101
  column_create Posts author COLUMN_SCALAR Users
102
102
  column_create Posts tags COLUMN_VECTOR Tags
103
- EOS
103
+ SCHEMA
104
104
  end
105
105
 
106
106
  def dumped_schema_index_columns
107
- <<-EOS.chomp
107
+ <<-SCHEMA.chomp
108
108
  column_create Tags Posts_tag_text COLUMN_INDEX Posts tag_text
109
109
 
110
110
  column_create Users Posts_author COLUMN_INDEX Posts author
111
- EOS
111
+ SCHEMA
112
112
  end
113
113
 
114
114
  class EmptyTest < self
@@ -130,117 +130,115 @@ EOS
130
130
  :title => "Why search engine find?")
131
131
  end
132
132
 
133
- def test_default
134
- assert_equal(<<-EOS, dump)
135
- #{dumped_schema_tables}
136
-
137
- #{dumped_schema_reference_columns}
138
-
133
+ def dumped_table_posts
134
+ <<-TABLE.chomp
139
135
  load --table Posts
140
136
  [
141
137
  ["_id","author","created_at","n_goods","published","rank","tag_text","tags","title"],
142
138
  [1,"mori",1268034720.0,4,true,10,"search mori",["search","mori"],"Why search engine find?"]
143
139
  ]
140
+ TABLE
141
+ end
144
142
 
143
+ def dumped_table_tags
144
+ <<-TABLE.chomp
145
145
  load --table Tags
146
146
  [
147
147
  ["_key","name"],
148
148
  ["search",""],
149
149
  ["mori",""]
150
150
  ]
151
+ TABLE
152
+ end
151
153
 
154
+ def dumped_table_users
155
+ <<-TABLE.chomp
152
156
  load --table Users
153
157
  [
154
158
  ["_key","name"],
155
159
  ["mori",""]
156
160
  ]
161
+ TABLE
162
+ end
163
+
164
+ def dumped_tables
165
+ <<-TABLES.chomp
166
+ #{dumped_table_posts}
167
+
168
+ #{dumped_table_tags}
169
+
170
+ #{dumped_table_users}
171
+ TABLES
172
+ end
173
+
174
+ def test_default
175
+ assert_equal(<<-DUMP, dump)
176
+ #{dumped_schema_tables}
177
+
178
+ #{dumped_schema_reference_columns}
179
+
180
+ #{dumped_tables}
157
181
 
158
182
  #{dumped_schema_index_columns}
159
- EOS
183
+ DUMP
160
184
  end
161
185
 
162
186
  def test_limit_tables
163
- assert_equal(<<-EOS, dump(:tables => ["Posts"]))
187
+ assert_equal(<<-DUMP, dump(:tables => ["Posts"]))
164
188
  #{dumped_schema_tables}
165
189
 
166
190
  #{dumped_schema_reference_columns}
167
191
 
168
- load --table Posts
169
- [
170
- ["_id","author","created_at","n_goods","published","rank","tag_text","tags","title"],
171
- [1,"mori",1268034720.0,4,true,10,"search mori",["search","mori"],"Why search engine find?"]
172
- ]
192
+ #{dumped_table_posts}
173
193
 
174
194
  #{dumped_schema_index_columns}
175
- EOS
195
+ DUMP
176
196
  end
177
197
 
178
198
  def test_limit_tables_with_regexp
179
- assert_equal(<<-EOS, dump(:tables => [/Posts?/]))
199
+ assert_equal(<<-DUMP, dump(:tables => [/Posts?/]))
180
200
  #{dumped_schema_tables}
181
201
 
182
202
  #{dumped_schema_reference_columns}
183
203
 
184
- load --table Posts
185
- [
186
- ["_id","author","created_at","n_goods","published","rank","tag_text","tags","title"],
187
- [1,"mori",1268034720.0,4,true,10,"search mori",["search","mori"],"Why search engine find?"]
188
- ]
204
+ #{dumped_table_posts}
189
205
 
190
206
  #{dumped_schema_index_columns}
191
- EOS
207
+ DUMP
192
208
  end
193
209
 
194
210
  def test_exclude_tables
195
211
  dump_options = {
196
212
  :exclude_tables => ["Posts"],
197
213
  }
198
- assert_equal(<<-EOS, dump(dump_options))
214
+ assert_equal(<<-DUMP, dump(dump_options))
199
215
  #{dumped_schema_tables}
200
216
 
201
217
  #{dumped_schema_reference_columns}
202
218
 
203
- load --table Tags
204
- [
205
- ["_key","name"],
206
- ["search",""],
207
- ["mori",""]
208
- ]
219
+ #{dumped_table_tags}
209
220
 
210
- load --table Users
211
- [
212
- ["_key","name"],
213
- ["mori",""]
214
- ]
221
+ #{dumped_table_users}
215
222
 
216
223
  #{dumped_schema_index_columns}
217
- EOS
224
+ DUMP
218
225
  end
219
226
 
220
227
  def test_exclude_tables_with_regexp
221
228
  dump_options = {
222
229
  :exclude_tables => [/Posts?/],
223
230
  }
224
- assert_equal(<<-EOS, dump(dump_options))
231
+ assert_equal(<<-DUMP, dump(dump_options))
225
232
  #{dumped_schema_tables}
226
233
 
227
234
  #{dumped_schema_reference_columns}
228
235
 
229
- load --table Tags
230
- [
231
- ["_key","name"],
232
- ["search",""],
233
- ["mori",""]
234
- ]
236
+ #{dumped_table_tags}
235
237
 
236
- load --table Users
237
- [
238
- ["_key","name"],
239
- ["mori",""]
240
- ]
238
+ #{dumped_table_users}
241
239
 
242
240
  #{dumped_schema_index_columns}
243
- EOS
241
+ DUMP
244
242
  end
245
243
 
246
244
  def test_tables_combination
@@ -248,42 +246,29 @@ EOS
248
246
  :exclude_tables => ["Posts"],
249
247
  :tables => ["Posts", "Users"],
250
248
  }
251
- assert_equal(<<-EOS, dump(dump_options))
249
+ assert_equal(<<-DUMP, dump(dump_options))
252
250
  #{dumped_schema_tables}
253
251
 
254
252
  #{dumped_schema_reference_columns}
255
253
 
256
- load --table Users
257
- [
258
- ["_key","name"],
259
- ["mori",""]
260
- ]
254
+ #{dumped_table_users}
261
255
 
262
256
  #{dumped_schema_index_columns}
263
- EOS
257
+ DUMP
264
258
  end
265
259
 
266
260
  def test_no_schema
267
- assert_equal(<<-EOS, dump(:dump_schema => false))
268
- load --table Posts
269
- [
270
- ["_id","author","created_at","n_goods","published","rank","tag_text","tags","title"],
271
- [1,"mori",1268034720.0,4,true,10,"search mori",["search","mori"],"Why search engine find?"]
272
- ]
261
+ assert_equal(<<-DUMP, dump(:dump_schema => false))
262
+ #{dumped_tables}
273
263
 
274
- load --table Tags
275
- [
276
- ["_key","name"],
277
- ["search",""],
278
- ["mori",""]
279
- ]
264
+ #{dumped_schema_index_columns}
265
+ DUMP
266
+ end
280
267
 
281
- load --table Users
282
- [
283
- ["_key","name"],
284
- ["mori",""]
285
- ]
286
- EOS
268
+ def test_no_schema_no_indexes
269
+ assert_equal(<<-DUMP, dump(:dump_schema => false, :dump_indexes => false))
270
+ #{dumped_tables}
271
+ DUMP
287
272
  end
288
273
 
289
274
  def test_no_tables
@@ -360,7 +345,7 @@ COMMAND
360
345
  end
361
346
 
362
347
  def test_have_records
363
- assert_equal(<<-EOS, dump)
348
+ assert_equal(<<-DUMP, dump)
364
349
  table_create Users TABLE_PAT_KEY --key_type ShortText
365
350
 
366
351
  load --table Users
@@ -369,7 +354,7 @@ load --table Users
369
354
  [\"mori\"],
370
355
  [\"s-yata\"]
371
356
  ]
372
- EOS
357
+ DUMP
373
358
  end
374
359
  end
375
360
  end
@@ -150,7 +150,7 @@ class DatabaseTest < Test::Unit::TestCase
150
150
  users.add(:name => "user #{i}" * 1000,
151
151
  :address => "address #{i}" * 1000)
152
152
  end
153
- assert_equal(7, @database.defrag)
153
+ assert_equal(3, @database.defrag)
154
154
  end
155
155
 
156
156
  def test_tables
@@ -27,6 +27,21 @@ class DoubleArrayTrieTest < Test::Unit::TestCase
27
27
  :support_key?)
28
28
  end
29
29
 
30
+ class SupportValueTest < self
31
+ def test_have_value_type
32
+ assert_predicate(Groonga::DoubleArrayTrie.create(:name => "Users",
33
+ :key_type => "ShortText",
34
+ :value_type => "Int32"),
35
+ :support_value?)
36
+ end
37
+
38
+ def test_no_value_type
39
+ assert_not_predicate(Groonga::DoubleArrayTrie.create(:name => "Users",
40
+ :key_type => "ShortText"),
41
+ :support_value?)
42
+ end
43
+ end
44
+
30
45
  def test_encoding
31
46
  assert_equal(Groonga::Encoding.default,
32
47
  Groonga::DoubleArrayTrie.create.encoding)
@@ -148,7 +163,7 @@ class DoubleArrayTrieTest < Test::Unit::TestCase
148
163
  :name => "user #{i}" * 1000,
149
164
  :address => "address #{i}" * 1000)
150
165
  end
151
- assert_equal(7, users.defrag)
166
+ assert_equal(3, users.defrag)
152
167
  end
153
168
 
154
169
  def test_rename
data/test/test-hash.rb CHANGED
@@ -26,6 +26,21 @@ class HashTest < Test::Unit::TestCase
26
26
  :support_key?)
27
27
  end
28
28
 
29
+ class SupportValueTest < self
30
+ def test_have_value_type
31
+ assert_predicate(Groonga::Hash.create(:name => "Users",
32
+ :key_type => "ShortText",
33
+ :value_type => "Int32"),
34
+ :support_value?)
35
+ end
36
+
37
+ def test_no_value_type
38
+ assert_not_predicate(Groonga::Hash.create(:name => "Users",
39
+ :key_type => "ShortText"),
40
+ :support_value?)
41
+ end
42
+ end
43
+
29
44
  class DeleteTest < self
30
45
  setup
31
46
  def setup_data
@@ -357,7 +372,7 @@ class HashTest < Test::Unit::TestCase
357
372
  :name => "user #{i}" * 1000,
358
373
  :address => "address #{i}" * 1000)
359
374
  end
360
- assert_equal(7, users.defrag)
375
+ assert_equal(3, users.defrag)
361
376
  end
362
377
 
363
378
  def test_rename
@@ -0,0 +1,29 @@
1
+ # Copyright (C) 2014 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 LockTimeoutTest < Test::Unit::TestCase
17
+ def setup
18
+ @original_lock_timeout = Groonga.lock_timeout
19
+ end
20
+
21
+ def teardown
22
+ Groonga.lock_timeout = @original_lock_timeout
23
+ end
24
+
25
+ def test_accessor
26
+ Groonga.lock_timeout = 10
27
+ assert_equal(10, Groonga.lock_timeout)
28
+ end
29
+ end
@@ -27,6 +27,21 @@ class PatriciaTrieTest < Test::Unit::TestCase
27
27
  :support_key?)
28
28
  end
29
29
 
30
+ class SupportValueTest < self
31
+ def test_have_value_type
32
+ assert_predicate(Groonga::PatriciaTrie.create(:name => "Users",
33
+ :key_type => "ShortText",
34
+ :value_type => "Int32"),
35
+ :support_value?)
36
+ end
37
+
38
+ def test_no_value_type
39
+ assert_not_predicate(Groonga::PatriciaTrie.create(:name => "Users",
40
+ :key_type => "ShortText"),
41
+ :support_value?)
42
+ end
43
+ end
44
+
30
45
  def test_encoding
31
46
  assert_equal(Groonga::Encoding.default,
32
47
  Groonga::PatriciaTrie.create.encoding)
@@ -407,7 +422,7 @@ class PatriciaTrieTest < Test::Unit::TestCase
407
422
  :name => "user #{i}" * 1000,
408
423
  :address => "address #{i}" * 1000)
409
424
  end
410
- assert_equal(7, users.defrag)
425
+ assert_equal(3, users.defrag)
411
426
  end
412
427
 
413
428
  def test_rename
data/test/test-record.rb CHANGED
@@ -309,197 +309,231 @@ class RecordTest < Test::Unit::TestCase
309
309
  assert_not_predicate(groonga, :locked?)
310
310
  end
311
311
 
312
- def test_attributes
313
- values = {
314
- "uri" => "http://groonga.org/",
315
- "rate" => 5,
316
- "comment" => "Great!"
317
- }
318
- groonga = @bookmarks.add(values)
319
- assert_equal(values.merge("_id" => groonga.id,
320
- "content" => nil,
321
- "user" => nil),
322
- groonga.attributes)
323
- end
312
+ class AttributesTest < self
313
+ def test_basic
314
+ values = {
315
+ "uri" => "http://groonga.org/",
316
+ "rate" => 5,
317
+ "comment" => "Great!"
318
+ }
319
+ groonga = @bookmarks.add(values)
320
+ assert_equal(values.merge("_id" => groonga.id,
321
+ "_value" => 0,
322
+ "content" => nil,
323
+ "user" => nil),
324
+ groonga.attributes)
325
+ end
324
326
 
325
- def test_recursive_attributes
326
- need_self_recursive_equal
327
+ def test_recursive
328
+ need_self_recursive_equal
327
329
 
328
- @bookmarks.define_column("next", @bookmarks)
330
+ @bookmarks.define_column("next", @bookmarks)
329
331
 
330
- top_page_record = @bookmarks.add(top_page)
331
- doc_page_record = @bookmarks.add(doc_page)
332
+ top_page_record = @bookmarks.add(top_page)
333
+ doc_page_record = @bookmarks.add(doc_page)
332
334
 
333
- top_page_record["next"] = doc_page_record
334
- doc_page_record["next"] = top_page_record
335
+ top_page_record["next"] = doc_page_record
336
+ doc_page_record["next"] = top_page_record
335
337
 
336
- expected = {
337
- "_id" => 1,
338
- "user" => nil,
339
- "uri" => "http://groonga.org/",
340
- "rate" => 5,
341
- "next" => {
342
- "_id" => 2,
338
+ expected = {
339
+ "_id" => 1,
340
+ "_value" => 0,
343
341
  "user" => nil,
344
- "uri" => "http://groonga.org/document.html",
345
- "rate" => 8,
342
+ "uri" => "http://groonga.org/",
343
+ "rate" => 5,
344
+ "next" => {
345
+ "_id" => 2,
346
+ "_value" => 0,
347
+ "user" => nil,
348
+ "uri" => "http://groonga.org/document.html",
349
+ "rate" => 8,
350
+ "content" => nil,
351
+ "comment" => "Informative"
352
+ },
346
353
  "content" => nil,
347
- "comment" => "Informative"
348
- },
349
- "content" => nil,
350
- "comment" => "Great!"
351
- }
352
- expected["next"]["next"] = expected
354
+ "comment" => "Great!"
355
+ }
356
+ expected["next"]["next"] = expected
353
357
 
354
- assert_equal(expected, top_page_record.attributes)
355
- end
358
+ assert_equal(expected, top_page_record.attributes)
359
+ end
356
360
 
357
- def test_duplicate_records_attributes
358
- need_self_recursive_equal
361
+ def test_duplicate_records
362
+ need_self_recursive_equal
359
363
 
360
- @bookmarks.define_column("next1", @bookmarks)
361
- @bookmarks.define_column("next2", @bookmarks)
364
+ @bookmarks.define_column("next1", @bookmarks)
365
+ @bookmarks.define_column("next2", @bookmarks)
362
366
 
363
- top_page_record = @bookmarks.add(top_page)
364
- doc_page_record = @bookmarks.add(doc_page)
367
+ top_page_record = @bookmarks.add(top_page)
368
+ doc_page_record = @bookmarks.add(doc_page)
365
369
 
366
- top_page_record["next1"] = doc_page_record
367
- top_page_record["next2"] = doc_page_record
368
- doc_page_record["next1"] = top_page_record
370
+ top_page_record["next1"] = doc_page_record
371
+ top_page_record["next2"] = doc_page_record
372
+ doc_page_record["next1"] = top_page_record
369
373
 
370
- doc_page_attributes = {
371
- "_id" => 2,
372
- "user" => nil,
373
- "uri" => "http://groonga.org/document.html",
374
- "rate" => 8,
375
- "content" => nil,
376
- "comment" => "Informative",
377
- "next2" => nil
378
- }
379
- top_page_attributes = {
380
- "_id" => 1,
381
- "user" => nil,
382
- "uri" => "http://groonga.org/",
383
- "rate" => 5,
384
- "next1" => doc_page_attributes,
385
- "next2" => doc_page_attributes,
386
- "content" => nil,
387
- "comment" => "Great!"
388
- }
389
- doc_page_attributes["next1"] = top_page_attributes
374
+ doc_page_attributes = {
375
+ "_id" => 2,
376
+ "_value" => 0,
377
+ "user" => nil,
378
+ "uri" => "http://groonga.org/document.html",
379
+ "rate" => 8,
380
+ "content" => nil,
381
+ "comment" => "Informative",
382
+ "next2" => nil
383
+ }
384
+ top_page_attributes = {
385
+ "_id" => 1,
386
+ "_value" => 0,
387
+ "user" => nil,
388
+ "uri" => "http://groonga.org/",
389
+ "rate" => 5,
390
+ "next1" => doc_page_attributes,
391
+ "next2" => doc_page_attributes,
392
+ "content" => nil,
393
+ "comment" => "Great!"
394
+ }
395
+ doc_page_attributes["next1"] = top_page_attributes
390
396
 
391
- actual_records = top_page_record.attributes
392
- assert_equal(top_page_attributes, actual_records)
393
- assert_equal(actual_records["next1"].object_id,
394
- actual_records["next2"].object_id)
395
- end
397
+ actual_records = top_page_record.attributes
398
+ assert_equal(top_page_attributes, actual_records)
399
+ assert_equal(actual_records["next1"].object_id,
400
+ actual_records["next2"].object_id)
401
+ end
396
402
 
397
- def test_select_result_attributes
398
- @bookmarks.add(top_page)
399
- select_result = @bookmarks.select
400
- select_result_result = select_result.first
403
+ def test_select_result
404
+ @bookmarks.add(top_page)
405
+ select_result = @bookmarks.select
406
+ select_result_result = select_result.first
401
407
 
402
- expected_attributes = {
403
- "_id" => 1,
404
- "_key" => {
405
- "comment" => "Great!",
406
- "content" => nil,
408
+ expected_attributes = {
407
409
  "_id" => 1,
408
- "rate" => 5,
409
- "uri" => "http://groonga.org/",
410
- "user" => nil
411
- },
412
- "_score" => 1,
413
- }
410
+ "_key" => {
411
+ "comment" => "Great!",
412
+ "content" => nil,
413
+ "_id" => 1,
414
+ "_value" => 0,
415
+ "rate" => 5,
416
+ "uri" => "http://groonga.org/",
417
+ "user" => nil
418
+ },
419
+ "_score" => 1,
420
+ }
414
421
 
415
- assert_equal(expected_attributes, select_result_result.attributes)
416
- end
422
+ assert_equal(expected_attributes, select_result_result.attributes)
423
+ end
417
424
 
418
- def test_self_referencing_attributes
419
- need_self_recursive_equal
425
+ def test_sort_result
426
+ @bookmarks.add(top_page)
427
+ sort_result = @bookmarks.sort(["_id"])
428
+ sort_result_result = sort_result.first
420
429
 
421
- @bookmarks.define_column("next", @bookmarks)
430
+ expected_attributes = {
431
+ "_id" => 1,
432
+ "_value" => {
433
+ "comment" => "Great!",
434
+ "content" => nil,
435
+ "_id" => 1,
436
+ "_value" => 0,
437
+ "rate" => 5,
438
+ "uri" => "http://groonga.org/",
439
+ "user" => nil
440
+ },
441
+ }
422
442
 
423
- top_page_record = @bookmarks.add(top_page)
424
- top_page_record["next"] = top_page_record
443
+ assert_equal(expected_attributes, sort_result_result.attributes)
444
+ end
425
445
 
426
- expected = {
427
- "_id" => 1,
428
- "user" => nil,
429
- "uri" => "http://groonga.org/",
430
- "rate" => 5,
431
- "content" => nil,
432
- "comment" => "Great!"
433
- }
434
- expected["next"] = expected
446
+ def test_self_referencing
447
+ need_self_recursive_equal
435
448
 
436
- assert_equal(expected, top_page_record.attributes)
437
- end
449
+ @bookmarks.define_column("next", @bookmarks)
438
450
 
439
- def test_vector_attributes
440
- @bookmarks.define_column("related_bookmarks", @bookmarks, :type => :vector)
451
+ top_page_record = @bookmarks.add(top_page)
452
+ top_page_record["next"] = top_page_record
441
453
 
442
- top_page_record = @bookmarks.add(top_page)
443
- doc_page_record = @bookmarks.add(doc_page)
444
- top_page_record["related_bookmarks"] = [doc_page_record]
454
+ expected = {
455
+ "_id" => 1,
456
+ "_value" => 0,
457
+ "user" => nil,
458
+ "uri" => "http://groonga.org/",
459
+ "rate" => 5,
460
+ "content" => nil,
461
+ "comment" => "Great!"
462
+ }
463
+ expected["next"] = expected
445
464
 
446
- expected = {
447
- "_id" => 1,
448
- "user" => nil,
449
- "uri" => "http://groonga.org/",
450
- "rate" => 5,
451
- "related_bookmarks" => [
452
- {
453
- "_id" => 2,
454
- "comment" => "Informative",
455
- "content" => nil,
456
- "rate" => 8,
457
- "related_bookmarks" => [],
458
- "uri" => "http://groonga.org/document.html",
459
- "user" => nil,
460
- }
461
- ],
462
- "content" => nil,
463
- "comment" => "Great!"
464
- }
465
+ assert_equal(expected, top_page_record.attributes)
466
+ end
465
467
 
466
- assert_equal(expected, top_page_record.attributes)
467
- end
468
+ def test_vector
469
+ @bookmarks.define_column("related_bookmarks", @bookmarks, :type => :vector)
468
470
 
469
- def test_self_referencing_vector_attributes
470
- need_self_recursive_equal
471
+ top_page_record = @bookmarks.add(top_page)
472
+ doc_page_record = @bookmarks.add(doc_page)
473
+ top_page_record["related_bookmarks"] = [doc_page_record]
471
474
 
472
- @bookmarks.define_column("related_bookmarks", @bookmarks, :type => :vector)
475
+ expected = {
476
+ "_id" => 1,
477
+ "_value" => 0,
478
+ "user" => nil,
479
+ "uri" => "http://groonga.org/",
480
+ "rate" => 5,
481
+ "related_bookmarks" => [
482
+ {
483
+ "_id" => 2,
484
+ "_value" => 0,
485
+ "comment" => "Informative",
486
+ "content" => nil,
487
+ "rate" => 8,
488
+ "related_bookmarks" => [],
489
+ "uri" => "http://groonga.org/document.html",
490
+ "user" => nil,
491
+ }
492
+ ],
493
+ "content" => nil,
494
+ "comment" => "Great!"
495
+ }
473
496
 
474
- top_page_record = @bookmarks.add(top_page)
475
- doc_page_record = @bookmarks.add(doc_page)
476
- top_page_record["related_bookmarks"] = [
477
- top_page_record,
478
- doc_page_record
479
- ]
497
+ assert_equal(expected, top_page_record.attributes)
498
+ end
480
499
 
481
- top_page_attributes = {
482
- "_id" => 1,
483
- "user" => nil,
484
- "uri" => "http://groonga.org/",
485
- "rate" => 5,
486
- "content" => nil,
487
- "comment" => "Great!"
488
- }
489
- doc_page_attributes = {
490
- "_id" => 2,
491
- "comment" => "Informative",
492
- "content" => nil,
493
- "rate" => 8,
494
- "related_bookmarks" => [],
495
- "uri" => "http://groonga.org/document.html",
496
- "user" => nil,
497
- }
498
- top_page_attributes["related_bookmarks"] = [
499
- top_page_attributes,
500
- doc_page_attributes
501
- ]
502
- assert_equal(top_page_attributes, top_page_record.attributes)
500
+ def test_self_referencing_vector
501
+ need_self_recursive_equal
502
+
503
+ @bookmarks.define_column("related_bookmarks", @bookmarks, :type => :vector)
504
+
505
+ top_page_record = @bookmarks.add(top_page)
506
+ doc_page_record = @bookmarks.add(doc_page)
507
+ top_page_record["related_bookmarks"] = [
508
+ top_page_record,
509
+ doc_page_record
510
+ ]
511
+
512
+ top_page_attributes = {
513
+ "_id" => 1,
514
+ "_value" => 0,
515
+ "user" => nil,
516
+ "uri" => "http://groonga.org/",
517
+ "rate" => 5,
518
+ "content" => nil,
519
+ "comment" => "Great!"
520
+ }
521
+ doc_page_attributes = {
522
+ "_id" => 2,
523
+ "_value" => 0,
524
+ "comment" => "Informative",
525
+ "content" => nil,
526
+ "rate" => 8,
527
+ "related_bookmarks" => [],
528
+ "uri" => "http://groonga.org/document.html",
529
+ "user" => nil,
530
+ }
531
+ top_page_attributes["related_bookmarks"] = [
532
+ top_page_attributes,
533
+ doc_page_attributes
534
+ ]
535
+ assert_equal(top_page_attributes, top_page_record.attributes)
536
+ end
503
537
  end
504
538
 
505
539
  def test_dynamic_accessor
@@ -116,7 +116,7 @@ class VariableSizeColumnTest < Test::Unit::TestCase
116
116
  1000.times do |i|
117
117
  @users.add(:name => "user #{i}" * 1000)
118
118
  end
119
- assert_equal(3, @name.defrag)
119
+ assert_equal(1, @name.defrag)
120
120
  end
121
121
 
122
122
  class VectorTest < self
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: 3.1.1
4
+ version: 3.1.2
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: 2013-12-29 00:00:00.000000000 Z
15
+ date: 2014-01-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pkg-config
@@ -329,6 +329,7 @@ files:
329
329
  - test/test-version.rb
330
330
  - test/test-index-cursor.rb
331
331
  - test/test-double-array-trie.rb
332
+ - test/test-lock-timeout.rb
332
333
  - test/test-exception.rb
333
334
  - test/test-schema-dumper.rb
334
335
  - test/test-schema-type.rb
@@ -412,6 +413,7 @@ test_files:
412
413
  - test/test-version.rb
413
414
  - test/test-index-cursor.rb
414
415
  - test/test-double-array-trie.rb
416
+ - test/test-lock-timeout.rb
415
417
  - test/test-exception.rb
416
418
  - test/test-schema-dumper.rb
417
419
  - test/test-schema-type.rb