rroonga 3.0.4-x86-mingw32 → 3.0.5-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/text/news.textile +29 -0
- data/ext/groonga/rb-grn-context.c +10 -0
- data/ext/groonga/rb-grn-object.c +10 -0
- data/ext/groonga/rb-grn-utils.c +12 -3
- data/ext/groonga/rb-grn.h +3 -1
- data/lib/1.9/groonga.so +0 -0
- data/lib/2.0/groonga.so +0 -0
- data/lib/groonga/context.rb +122 -0
- data/lib/groonga/dumper.rb +5 -0
- data/lib/groonga/memory-pool.rb +38 -0
- data/test/test-convert.rb +52 -0
- data/test/test-database-dumper.rb +35 -1
- data/test/test-memory-pool.rb +88 -0
- data/test/test-schema-dumper.rb +48 -18
- metadata +7 -2
data/doc/text/news.textile
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
h1. NEWS
|
2
2
|
|
3
|
+
h2(#3-0-5). 3.0.5: 2013-07-29
|
4
|
+
|
5
|
+
h3. Improvements
|
6
|
+
|
7
|
+
* [dumper] supported dumping of DoubleArrayTrie.
|
8
|
+
* Supported Int8/UInt8/Int16/UInt16 to Ruby conversion.
|
9
|
+
[groonga-dev,01524][Reported by Masaharu YOSHIOKA]
|
10
|
+
* Added memory pool mechanism to reduce GC easily.
|
11
|
+
{Groonga::Context#push_memory_pool} and {Groonga::Context#pop_memory_pool}
|
12
|
+
are added.
|
13
|
+
You can close temporary table objects automatically:
|
14
|
+
<pre>
|
15
|
+
context.push_memory_pool do
|
16
|
+
# create tempoeray table objects by select, group, sort and so on...
|
17
|
+
end
|
18
|
+
# createed tempoeray table objects are closed automatically
|
19
|
+
</pre>
|
20
|
+
* Supported max int32 over Fixnum
|
21
|
+
[Reported by xtuaok]
|
22
|
+
|
23
|
+
h3. Fixes
|
24
|
+
|
25
|
+
* [dumper] fixed a bug that no column table isn't dumped.
|
26
|
+
|
27
|
+
h3. Thanks
|
28
|
+
|
29
|
+
* Masaharu YOSHIOKA
|
30
|
+
* xtuaok
|
31
|
+
|
3
32
|
h2(#3-0-4). 3.0.4: 2013-07-04
|
4
33
|
|
5
34
|
h3. Fixes
|
@@ -470,6 +470,8 @@ rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
|
|
470
470
|
GRN_CTX_SET_ENCODING(context, encoding);
|
471
471
|
}
|
472
472
|
|
473
|
+
rb_iv_set(self, "@memory_pools", rb_ary_new());
|
474
|
+
|
473
475
|
debug("context new: %p\n", context);
|
474
476
|
|
475
477
|
return Qnil;
|
@@ -924,6 +926,14 @@ rb_grn_context_array_reference (VALUE self, VALUE name_or_id)
|
|
924
926
|
return GRNOBJECT2RVAL(Qnil, context, object, GRN_FALSE);
|
925
927
|
}
|
926
928
|
|
929
|
+
void
|
930
|
+
rb_grn_context_object_created (VALUE rb_context, VALUE rb_object)
|
931
|
+
{
|
932
|
+
ID id_object_created;
|
933
|
+
CONST_ID(id_object_created, "object_created");
|
934
|
+
rb_funcall(rb_context, id_object_created, 1, rb_object);
|
935
|
+
}
|
936
|
+
|
927
937
|
void
|
928
938
|
rb_grn_init_context (VALUE mGrn)
|
929
939
|
{
|
data/ext/groonga/rb-grn-object.c
CHANGED
@@ -313,6 +313,16 @@ rb_grn_object_to_ruby_object (VALUE klass, grn_ctx *context, grn_obj *object,
|
|
313
313
|
rb_object = rb_obj_alloc(klass);
|
314
314
|
rb_grn_object_assign(klass, rb_object, rb_context, context, object);
|
315
315
|
|
316
|
+
switch (object->header.type) {
|
317
|
+
case GRN_TABLE_NO_KEY:
|
318
|
+
case GRN_TABLE_HASH_KEY:
|
319
|
+
case GRN_TABLE_PAT_KEY:
|
320
|
+
case GRN_TABLE_DAT_KEY:
|
321
|
+
rb_grn_context_object_created(rb_context, rb_object);
|
322
|
+
default:
|
323
|
+
break;
|
324
|
+
}
|
325
|
+
|
316
326
|
return rb_object;
|
317
327
|
}
|
318
328
|
|
data/ext/groonga/rb-grn-utils.c
CHANGED
@@ -205,6 +205,18 @@ rb_grn_bulk_to_ruby_object_by_range_id (grn_ctx *context, grn_obj *bulk,
|
|
205
205
|
case GRN_DB_BOOL:
|
206
206
|
*rb_value = GRN_BOOL_VALUE(bulk) ? Qtrue : Qfalse;
|
207
207
|
break;
|
208
|
+
case GRN_DB_INT8:
|
209
|
+
*rb_value = INT2NUM(GRN_INT8_VALUE(bulk));
|
210
|
+
break;
|
211
|
+
case GRN_DB_UINT8:
|
212
|
+
*rb_value = UINT2NUM(GRN_UINT8_VALUE(bulk));
|
213
|
+
break;
|
214
|
+
case GRN_DB_INT16:
|
215
|
+
*rb_value = INT2NUM(GRN_INT16_VALUE(bulk));
|
216
|
+
break;
|
217
|
+
case GRN_DB_UINT16:
|
218
|
+
*rb_value = UINT2NUM(GRN_UINT16_VALUE(bulk));
|
219
|
+
break;
|
208
220
|
case GRN_DB_INT32:
|
209
221
|
*rb_value = INT2NUM(GRN_INT32_VALUE(bulk));
|
210
222
|
break;
|
@@ -373,9 +385,6 @@ rb_grn_bulk_from_ruby_object (VALUE object, grn_ctx *context, grn_obj *bulk)
|
|
373
385
|
rb_grn_context_text_set(context, bulk, object);
|
374
386
|
break;
|
375
387
|
case T_FIXNUM:
|
376
|
-
grn_obj_reinit(context, bulk, GRN_DB_INT32, 0);
|
377
|
-
GRN_INT32_SET(context, bulk, NUM2INT(object));
|
378
|
-
break;
|
379
388
|
case T_BIGNUM:
|
380
389
|
{
|
381
390
|
int64_t int64_value;
|
data/ext/groonga/rb-grn.h
CHANGED
@@ -76,7 +76,7 @@ RB_GRN_BEGIN_DECLS
|
|
76
76
|
|
77
77
|
#define RB_GRN_MAJOR_VERSION 3
|
78
78
|
#define RB_GRN_MINOR_VERSION 0
|
79
|
-
#define RB_GRN_MICRO_VERSION
|
79
|
+
#define RB_GRN_MICRO_VERSION 5
|
80
80
|
|
81
81
|
#define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
|
82
82
|
|
@@ -313,6 +313,8 @@ grn_obj *rb_grn_context_get_backward_compatibility
|
|
313
313
|
(grn_ctx *context,
|
314
314
|
const char *name,
|
315
315
|
unsigned int name_size);
|
316
|
+
void rb_grn_context_object_created (VALUE rb_context,
|
317
|
+
VALUE rb_object);
|
316
318
|
|
317
319
|
const char *rb_grn_inspect (VALUE object);
|
318
320
|
const char *rb_grn_inspect_type (unsigned char type);
|
data/lib/1.9/groonga.so
CHANGED
Binary file
|
data/lib/2.0/groonga.so
CHANGED
Binary file
|
data/lib/groonga/context.rb
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
|
18
18
|
require "groonga/command"
|
19
19
|
|
20
|
+
require "groonga/memory-pool"
|
21
|
+
|
20
22
|
module Groonga
|
21
23
|
class Context
|
22
24
|
# _path_ にある既存のデータベースを開く。ブロックを指定した場
|
@@ -190,5 +192,125 @@ module Groonga
|
|
190
192
|
yield(buffer.dup, response) if block_given?
|
191
193
|
end
|
192
194
|
end
|
195
|
+
|
196
|
+
# Pushes a new memory pool to the context. Temporary objects that
|
197
|
+
# are created between pushing a new memory pool and popping the
|
198
|
+
# new memory pool are closed automatically when popping the new
|
199
|
+
# memory pool.
|
200
|
+
#
|
201
|
+
# It is useful for request and response style applications. These
|
202
|
+
# style applications can close temporary objects between a request
|
203
|
+
# and resopnse pair. There are some merits for closing temporary
|
204
|
+
# objects explicilty rather than closing implicitly by GC:
|
205
|
+
#
|
206
|
+
# * Less memory consumption
|
207
|
+
# * Faster
|
208
|
+
#
|
209
|
+
# The "less memory consumption" merit is caused by temporary
|
210
|
+
# objects are closed each request and response pair. The max
|
211
|
+
# memory consumption in these applications is the same as the max
|
212
|
+
# memory consumption in a request and response pair. If temporary
|
213
|
+
# objects are closed by GC, the max memory consumption in these
|
214
|
+
# applications is the same as the max memory consumption between
|
215
|
+
# the current GC and the next GC. These applications process many
|
216
|
+
# request and response pairs during two GCs.
|
217
|
+
#
|
218
|
+
# The "faster" merit is caused by reducing GC. You can reduce GC,
|
219
|
+
# your application run faster because GC is a heavy process. You
|
220
|
+
# can reduce GC because memory consumption is reduced.
|
221
|
+
#
|
222
|
+
# You can nest {#push_memory_pool} and {#pop_memory_pool} pair.
|
223
|
+
#
|
224
|
+
# @example Pushes a new memory pool with block
|
225
|
+
# adults = nil
|
226
|
+
# context.push_memory_pool do
|
227
|
+
# users = context["Users"]
|
228
|
+
# adults = users.select do |user|
|
229
|
+
# user.age >= 20
|
230
|
+
# end
|
231
|
+
# p adults.temporary? # => true
|
232
|
+
# p adults.closed? # => false
|
233
|
+
# end
|
234
|
+
# p adults.closed? # => true
|
235
|
+
#
|
236
|
+
# @example Pushes a new memory pool without block
|
237
|
+
# adults = nil
|
238
|
+
# context.push_memory_pool
|
239
|
+
# users = context["Users"]
|
240
|
+
# adults = users.select do |user|
|
241
|
+
# user.age >= 20
|
242
|
+
# end
|
243
|
+
# p adults.temporary? # => true
|
244
|
+
# p adults.closed? # => false
|
245
|
+
# context.pop_memory_pool
|
246
|
+
# p adults.closed? # => true
|
247
|
+
#
|
248
|
+
# @example Nesting push and pop pair
|
249
|
+
# adults = nil
|
250
|
+
# context.push_memory_pool do
|
251
|
+
# users = context["Users"]
|
252
|
+
# adults = users.select do |user|
|
253
|
+
# user.age >= 20
|
254
|
+
# end
|
255
|
+
# grouped_adults = nil
|
256
|
+
# context.push_memory_pool do
|
257
|
+
# grouped_adults = adults.group(["hobby"])
|
258
|
+
# p grouped_adults.temporary? # => true
|
259
|
+
# p grouped_adults.closed? # => false
|
260
|
+
# end
|
261
|
+
# p grouped_adults.closed? # => true
|
262
|
+
# p adults.temporary? # => true
|
263
|
+
# p adults.closed? # => false
|
264
|
+
# end
|
265
|
+
# p adults.closed? # => true
|
266
|
+
#
|
267
|
+
# @overload push_memory_pool
|
268
|
+
# Pushes a new memory pool to the context. You need to pop the
|
269
|
+
# memory pool explicitly by yourself.
|
270
|
+
#
|
271
|
+
# @return [void]
|
272
|
+
#
|
273
|
+
# @overload push_memory_pool {}
|
274
|
+
# Closes temporary objects created in the given block
|
275
|
+
# automatically.
|
276
|
+
#
|
277
|
+
# @yield []
|
278
|
+
# Yields the block. Temporary objects created in the block
|
279
|
+
# are closed automatically when the block is exited.
|
280
|
+
# @yieldreturn [Object] It is the return value of this
|
281
|
+
# method call.
|
282
|
+
# @return [Object] The value returned by the block.
|
283
|
+
#
|
284
|
+
# @since 3.0.5
|
285
|
+
def push_memory_pool
|
286
|
+
memory_pool = MemoryPool.new
|
287
|
+
@memory_pools.push(memory_pool)
|
288
|
+
return unless block_given?
|
289
|
+
|
290
|
+
begin
|
291
|
+
yield
|
292
|
+
ensure
|
293
|
+
pop_memory_pool
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# Pops the pushed memory pool.
|
298
|
+
#
|
299
|
+
# @return [void]
|
300
|
+
#
|
301
|
+
# @see push_memory_pool
|
302
|
+
#
|
303
|
+
# @since 3.0.5
|
304
|
+
def pop_memory_pool
|
305
|
+
memory_pool = @memory_pools.pop
|
306
|
+
memory_pool.close
|
307
|
+
end
|
308
|
+
|
309
|
+
# @api private
|
310
|
+
def object_created(object)
|
311
|
+
return if @memory_pools.empty?
|
312
|
+
memory_pool = @memory_pools.last
|
313
|
+
memory_pool.register(object)
|
314
|
+
end
|
193
315
|
end
|
194
316
|
end
|
data/lib/groonga/dumper.rb
CHANGED
@@ -123,6 +123,7 @@ module Groonga
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def index_only_table?(table)
|
126
|
+
return false if table.columns.empty?
|
126
127
|
table.columns.all? do |column|
|
127
128
|
column.index?
|
128
129
|
end
|
@@ -414,6 +415,8 @@ module Groonga
|
|
414
415
|
parameters << ":type => :hash"
|
415
416
|
when Groonga::PatriciaTrie
|
416
417
|
parameters << ":type => :patricia_trie"
|
418
|
+
when Groonga::DoubleArrayTrie
|
419
|
+
parameters << ":type => :double_array_trie"
|
417
420
|
end
|
418
421
|
if table.domain
|
419
422
|
parameters << ":key_type => #{table.domain.name.dump}"
|
@@ -547,6 +550,8 @@ module Groonga
|
|
547
550
|
flags << "TABLE_HASH_KEY"
|
548
551
|
when Groonga::PatriciaTrie
|
549
552
|
flags << "TABLE_PAT_KEY"
|
553
|
+
when Groonga::DoubleArrayTrie
|
554
|
+
flags << "TABLE_DAT_KEY"
|
550
555
|
end
|
551
556
|
if table.domain
|
552
557
|
flags << "KEY_NORMALIZE" if default_normalizer?(_normalizer_name)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License version 2.1 as published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this library; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
module Groonga
|
19
|
+
# @api private
|
20
|
+
class MemoryPool
|
21
|
+
def initialize
|
22
|
+
@temporary_objects = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def register(object)
|
26
|
+
return unless object.temporary?
|
27
|
+
return unless object.is_a?(Groonga::Table)
|
28
|
+
@temporary_objects[object] = true
|
29
|
+
end
|
30
|
+
|
31
|
+
def close
|
32
|
+
@temporary_objects.each do |(object, _)|
|
33
|
+
object.close unless object.closed?
|
34
|
+
end
|
35
|
+
@temporary_objects.clear
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License version 2.1 as published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this library; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
class ConvertTest < Test::Unit::TestCase
|
19
|
+
include GroongaTestUtils
|
20
|
+
|
21
|
+
setup :setup_database
|
22
|
+
|
23
|
+
setup
|
24
|
+
def setup_schema
|
25
|
+
end
|
26
|
+
|
27
|
+
setup
|
28
|
+
def setup_data
|
29
|
+
end
|
30
|
+
|
31
|
+
class Int64Test < self
|
32
|
+
def setup_schema
|
33
|
+
Groonga::Schema.define do |schema|
|
34
|
+
schema.create_table("Values") do |table|
|
35
|
+
table.int64("content")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
@values = Groonga["Values"]
|
39
|
+
end
|
40
|
+
|
41
|
+
data("Fixnum" => -1,
|
42
|
+
"Max Fixnum" => 2 ** 62 - 1,
|
43
|
+
"Bignum" => 2 ** 62)
|
44
|
+
def test_select(value)
|
45
|
+
@values.add(:content => value)
|
46
|
+
result = @values.select do |record|
|
47
|
+
record.content == value
|
48
|
+
end
|
49
|
+
assert_equal([value], result.collect(&:content))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2011-
|
1
|
+
# Copyright (C) 2011-2013 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
|
@@ -64,6 +64,10 @@ class DatabaseDumperTest < Test::Unit::TestCase
|
|
64
64
|
context["Posts"]
|
65
65
|
end
|
66
66
|
|
67
|
+
def users
|
68
|
+
context["Users"]
|
69
|
+
end
|
70
|
+
|
67
71
|
def dumped_schema
|
68
72
|
<<-EOS
|
69
73
|
#{dumped_schema_tables}
|
@@ -338,4 +342,34 @@ column_create Tags Posts_tag_text COLUMN_INDEX Posts tag_text
|
|
338
342
|
COMMAND
|
339
343
|
end
|
340
344
|
end
|
345
|
+
|
346
|
+
class NoColumnTest < self
|
347
|
+
def setup_tables
|
348
|
+
Groonga::Schema.define do |schema|
|
349
|
+
schema.create_table("Users",
|
350
|
+
:type => :patricia_trie,
|
351
|
+
:key_type => "ShortText") do |table|
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
setup
|
357
|
+
def setup_data
|
358
|
+
users.add("s-yata")
|
359
|
+
users.add("mori")
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_have_records
|
363
|
+
assert_equal(<<-EOS, dump)
|
364
|
+
table_create Users TABLE_PAT_KEY --key_type ShortText
|
365
|
+
|
366
|
+
load --table Users
|
367
|
+
[
|
368
|
+
[\"_key\"],
|
369
|
+
[\"mori\"],
|
370
|
+
[\"s-yata\"]
|
371
|
+
]
|
372
|
+
EOS
|
373
|
+
end
|
374
|
+
end
|
341
375
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Copyright (C) 2013 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 MemoryPoolTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
def setup
|
20
|
+
setup_sandbox
|
21
|
+
setup_database
|
22
|
+
setup_schema
|
23
|
+
setup_data
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup_schema
|
27
|
+
Groonga::Schema.define do |schema|
|
28
|
+
schema.create_table("Users",
|
29
|
+
:type => :hash,
|
30
|
+
:key_type => :short_text) do |table|
|
31
|
+
table.uint8(:age)
|
32
|
+
table.short_text(:hobby)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
@users = context["Users"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup_data
|
39
|
+
@users.add("mori", :age => 46, :hobby => "violin")
|
40
|
+
@users.add("s-yata", :age => 28, :hobby => "programming")
|
41
|
+
@users.add("kou", :age => 31, :hobby => "programming")
|
42
|
+
end
|
43
|
+
|
44
|
+
def teardown
|
45
|
+
teardown_sandbox
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_block
|
49
|
+
adults = nil
|
50
|
+
context.push_memory_pool do
|
51
|
+
adults = @users.select do |user|
|
52
|
+
user.age >= 20
|
53
|
+
end
|
54
|
+
assert_true(adults.temporary?)
|
55
|
+
assert_false(adults.closed?)
|
56
|
+
end
|
57
|
+
assert_true(adults.closed?)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_not_block
|
61
|
+
context.push_memory_pool
|
62
|
+
adults = @users.select do |user|
|
63
|
+
user.age >= 20
|
64
|
+
end
|
65
|
+
assert_true(adults.temporary?)
|
66
|
+
assert_false(adults.closed?)
|
67
|
+
context.pop_memory_pool
|
68
|
+
assert_true(adults.closed?)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_nested
|
72
|
+
adults = nil
|
73
|
+
context.push_memory_pool do
|
74
|
+
adults = @users.select do |user|
|
75
|
+
user.age >= 20
|
76
|
+
end
|
77
|
+
grouped_adults = nil
|
78
|
+
context.push_memory_pool do
|
79
|
+
grouped_adults = adults.group(["hobby"])
|
80
|
+
assert_true(grouped_adults.temporary?)
|
81
|
+
assert_false(grouped_adults.closed?)
|
82
|
+
end
|
83
|
+
assert_true(grouped_adults.closed?)
|
84
|
+
assert_false(adults.closed?)
|
85
|
+
end
|
86
|
+
assert_true(adults.closed?)
|
87
|
+
end
|
88
|
+
end
|
data/test/test-schema-dumper.rb
CHANGED
@@ -104,21 +104,31 @@ class SchemaDumperTest < Test::Unit::TestCase
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
+
def define_double_array_trie_schema
|
108
|
+
Groonga::Schema.define do |schema|
|
109
|
+
schema.create_table("Accounts",
|
110
|
+
:type => :double_array_trie,
|
111
|
+
:key_type => "ShortText") do |table|
|
112
|
+
table.short_text("name")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
107
117
|
class RubySyntaxSchemaDumperTest < SchemaDumperTest
|
108
118
|
def test_simple
|
109
119
|
define_simple_schema
|
110
|
-
assert_equal(<<-
|
120
|
+
assert_equal(<<-SCHEMA, dump)
|
111
121
|
create_table("Posts",
|
112
122
|
:force => true) do |table|
|
113
123
|
table.short_text("comments", :type => :vector)
|
114
124
|
table.short_text("title")
|
115
125
|
end
|
116
|
-
|
126
|
+
SCHEMA
|
117
127
|
end
|
118
128
|
|
119
129
|
def test_built_in_types
|
120
130
|
define_built_in_types_schema
|
121
|
-
assert_equal(<<-
|
131
|
+
assert_equal(<<-SCHEMA, dump)
|
122
132
|
create_table("Posts",
|
123
133
|
:force => true) do |table|
|
124
134
|
table.long_text("attachment")
|
@@ -138,12 +148,12 @@ create_table("Posts",
|
|
138
148
|
table.unsigned_integer8("uint8")
|
139
149
|
table.float("vote_average")
|
140
150
|
end
|
141
|
-
|
151
|
+
SCHEMA
|
142
152
|
end
|
143
153
|
|
144
154
|
def test_reference_table
|
145
155
|
define_reference_table_schema
|
146
|
-
assert_equal(<<-
|
156
|
+
assert_equal(<<-SCHEMA, dump)
|
147
157
|
create_table("Terms",
|
148
158
|
:type => :hash,
|
149
159
|
:key_type => "ShortText",
|
@@ -155,12 +165,12 @@ create_table("IndexTerms",
|
|
155
165
|
:key_type => "Terms",
|
156
166
|
:force => true) do |table|
|
157
167
|
end
|
158
|
-
|
168
|
+
SCHEMA
|
159
169
|
end
|
160
170
|
|
161
171
|
def test_reference_column
|
162
172
|
define_reference_column_schema
|
163
|
-
assert_equal(<<-
|
173
|
+
assert_equal(<<-SCHEMA, dump)
|
164
174
|
create_table("Comments",
|
165
175
|
:force => true) do |table|
|
166
176
|
table.text("content")
|
@@ -182,12 +192,12 @@ change_table("Comments") do |table|
|
|
182
192
|
table.reference("children", "Items", :type => :vector)
|
183
193
|
table.reference("item", "Items")
|
184
194
|
end
|
185
|
-
|
195
|
+
SCHEMA
|
186
196
|
end
|
187
197
|
|
188
198
|
def test_index
|
189
199
|
define_index_schema
|
190
|
-
assert_equal(<<-
|
200
|
+
assert_equal(<<-SCHEMA, dump)
|
191
201
|
create_table("Items",
|
192
202
|
:type => :hash,
|
193
203
|
:key_type => "ShortText",
|
@@ -207,7 +217,19 @@ change_table("Terms") do |table|
|
|
207
217
|
table.index("Items", "_key", :name => "Items__key")
|
208
218
|
table.index("Items", "title", :name => "Items_title")
|
209
219
|
end
|
210
|
-
|
220
|
+
SCHEMA
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_double_array_trie
|
224
|
+
define_double_array_trie_schema
|
225
|
+
assert_equal(<<-SCHEMA, dump)
|
226
|
+
create_table("Accounts",
|
227
|
+
:type => :double_array_trie,
|
228
|
+
:key_type => "ShortText",
|
229
|
+
:force => true) do |table|
|
230
|
+
table.short_text("name")
|
231
|
+
end
|
232
|
+
SCHEMA
|
211
233
|
end
|
212
234
|
|
213
235
|
private
|
@@ -219,25 +241,25 @@ EOS
|
|
219
241
|
class CommandSyntaxSchemaDumperTest < SchemaDumperTest
|
220
242
|
def test_simple
|
221
243
|
define_simple_schema
|
222
|
-
assert_equal(<<-
|
244
|
+
assert_equal(<<-SCHEMA, dump)
|
223
245
|
table_create Posts TABLE_NO_KEY
|
224
246
|
column_create Posts comments COLUMN_VECTOR ShortText
|
225
247
|
column_create Posts title COLUMN_SCALAR ShortText
|
226
|
-
|
248
|
+
SCHEMA
|
227
249
|
end
|
228
250
|
|
229
251
|
def test_reference_table
|
230
252
|
define_reference_table_schema
|
231
|
-
assert_equal(<<-
|
253
|
+
assert_equal(<<-SCHEMA, dump)
|
232
254
|
table_create Terms TABLE_HASH_KEY --key_type ShortText
|
233
255
|
|
234
256
|
table_create IndexTerms TABLE_HASH_KEY --key_type Terms
|
235
|
-
|
257
|
+
SCHEMA
|
236
258
|
end
|
237
259
|
|
238
260
|
def test_reference_column
|
239
261
|
define_reference_column_schema
|
240
|
-
assert_equal(<<-
|
262
|
+
assert_equal(<<-SCHEMA, dump)
|
241
263
|
table_create Comments TABLE_NO_KEY
|
242
264
|
column_create Comments content COLUMN_SCALAR Text
|
243
265
|
column_create Comments issued COLUMN_SCALAR Time
|
@@ -251,12 +273,12 @@ column_create Users name COLUMN_SCALAR ShortText
|
|
251
273
|
column_create Comments author COLUMN_SCALAR Users
|
252
274
|
column_create Comments children COLUMN_VECTOR Items
|
253
275
|
column_create Comments item COLUMN_SCALAR Items
|
254
|
-
|
276
|
+
SCHEMA
|
255
277
|
end
|
256
278
|
|
257
279
|
def test_index
|
258
280
|
define_index_schema
|
259
|
-
assert_equal(<<-
|
281
|
+
assert_equal(<<-SCHEMA, dump)
|
260
282
|
table_create Items TABLE_HASH_KEY --key_type ShortText
|
261
283
|
column_create Items title COLUMN_SCALAR ShortText
|
262
284
|
|
@@ -264,7 +286,15 @@ table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_to
|
|
264
286
|
|
265
287
|
column_create Terms Items__key COLUMN_INDEX|WITH_POSITION Items _key
|
266
288
|
column_create Terms Items_title COLUMN_INDEX|WITH_POSITION Items title
|
267
|
-
|
289
|
+
SCHEMA
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_double_array_trie
|
293
|
+
define_double_array_trie_schema
|
294
|
+
assert_equal(<<-SCHEMA, dump)
|
295
|
+
table_create Accounts TABLE_DAT_KEY --key_type ShortText
|
296
|
+
column_create Accounts name COLUMN_SCALAR ShortText
|
297
|
+
SCHEMA
|
268
298
|
end
|
269
299
|
|
270
300
|
private
|
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.0.
|
4
|
+
version: 3.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: x86-mingw32
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-07-
|
16
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: pkg-config
|
@@ -224,6 +224,7 @@ files:
|
|
224
224
|
- lib/groonga/index-column.rb
|
225
225
|
- lib/groonga/sub-records.rb
|
226
226
|
- lib/groonga/view-record.rb
|
227
|
+
- lib/groonga/memory-pool.rb
|
227
228
|
- lib/groonga/context.rb
|
228
229
|
- lib/groonga/grntest-log.rb
|
229
230
|
- lib/groonga/pagination.rb
|
@@ -295,6 +296,7 @@ files:
|
|
295
296
|
- test/groonga-test-utils.rb
|
296
297
|
- test/test-pagination.rb
|
297
298
|
- test/test-table.rb
|
299
|
+
- test/test-memory-pool.rb
|
298
300
|
- test/test-variable-size-column.rb
|
299
301
|
- test/test-plugin.rb
|
300
302
|
- test/test-hash.rb
|
@@ -330,6 +332,7 @@ files:
|
|
330
332
|
- test/test-schema-dumper.rb
|
331
333
|
- test/test-schema-type.rb
|
332
334
|
- test/test-table-select-weight.rb
|
335
|
+
- test/test-convert.rb
|
333
336
|
- test/test-gqtp.rb
|
334
337
|
- test/test-context.rb
|
335
338
|
- test/test-snippet.rb
|
@@ -1206,6 +1209,7 @@ test_files:
|
|
1206
1209
|
- test/groonga-test-utils.rb
|
1207
1210
|
- test/test-pagination.rb
|
1208
1211
|
- test/test-table.rb
|
1212
|
+
- test/test-memory-pool.rb
|
1209
1213
|
- test/test-variable-size-column.rb
|
1210
1214
|
- test/test-plugin.rb
|
1211
1215
|
- test/test-hash.rb
|
@@ -1241,6 +1245,7 @@ test_files:
|
|
1241
1245
|
- test/test-schema-dumper.rb
|
1242
1246
|
- test/test-schema-type.rb
|
1243
1247
|
- test/test-table-select-weight.rb
|
1248
|
+
- test/test-convert.rb
|
1244
1249
|
- test/test-gqtp.rb
|
1245
1250
|
- test/test-context.rb
|
1246
1251
|
- test/test-snippet.rb
|