rroonga 3.0.5 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/AUTHORS +5 -0
  2. data/Gemfile +20 -0
  3. data/Rakefile +187 -0
  4. data/doc/text/news.textile +10 -2
  5. data/doc/text/tutorial.textile +0 -2
  6. data/ext/groonga/extconf.rb +7 -1
  7. data/ext/groonga/rb-grn-accessor.c +11 -11
  8. data/ext/groonga/rb-grn-array.c +25 -25
  9. data/ext/groonga/rb-grn-column.c +106 -106
  10. data/ext/groonga/rb-grn-context.c +121 -121
  11. data/ext/groonga/rb-grn-database.c +78 -78
  12. data/ext/groonga/rb-grn-double-array-trie.c +92 -92
  13. data/ext/groonga/rb-grn-encoding-support.c +1 -1
  14. data/ext/groonga/rb-grn-encoding.c +28 -28
  15. data/ext/groonga/rb-grn-exception.c +9 -9
  16. data/ext/groonga/rb-grn-expression-builder.c +6 -6
  17. data/ext/groonga/rb-grn-expression.c +87 -87
  18. data/ext/groonga/rb-grn-fix-size-column.c +12 -12
  19. data/ext/groonga/rb-grn-geo-point.c +2 -2
  20. data/ext/groonga/rb-grn-hash.c +38 -38
  21. data/ext/groonga/rb-grn-index-column.c +191 -191
  22. data/ext/groonga/rb-grn-index-cursor.c +29 -29
  23. data/ext/groonga/rb-grn-logger.c +36 -36
  24. data/ext/groonga/rb-grn-normalizer.c +10 -10
  25. data/ext/groonga/rb-grn-patricia-trie.c +196 -196
  26. data/ext/groonga/rb-grn-plugin.c +5 -5
  27. data/ext/groonga/rb-grn-posting.c +2 -2
  28. data/ext/groonga/rb-grn-procedure.c +2 -2
  29. data/ext/groonga/rb-grn-query-logger.c +1 -1
  30. data/ext/groonga/rb-grn-record.c +1 -1
  31. data/ext/groonga/rb-grn-snippet.c +14 -14
  32. data/ext/groonga/rb-grn-table-cursor-key-support.c +4 -4
  33. data/ext/groonga/rb-grn-table-cursor.c +52 -52
  34. data/ext/groonga/rb-grn-table-key-support.c +209 -209
  35. data/ext/groonga/rb-grn-type.c +18 -18
  36. data/ext/groonga/rb-grn-utils.c +332 -314
  37. data/ext/groonga/rb-grn-variable-size-column.c +34 -34
  38. data/ext/groonga/rb-grn-variable.c +2 -2
  39. data/ext/groonga/rb-grn.h +240 -232
  40. data/ext/groonga/rb-groonga.c +10 -10
  41. data/rroonga-build.rb +7 -0
  42. data/rroonga.gemspec +1 -1
  43. data/test/test-hash.rb +4 -4
  44. data/test/test-index-column.rb +271 -257
  45. data/test/test-table-key-support.rb +78 -0
  46. data/test/test-table.rb +78 -51
  47. metadata +195 -164
  48. checksums.yaml +0 -7
data/AUTHORS ADDED
@@ -0,0 +1,5 @@
1
+ Kouhei Sutou <kou@clear-code.com>
2
+ Tasuku SUENAGA <a@razil.jp>
3
+ daijiro <morita@razil.jp>
4
+ Yuto HAYAMIZU <y.hayamizu@gmail.com>
5
+ SHIDARA Yoji <dara@shidara.net>
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2011-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
+ source "https://rubygems.org/"
19
+
20
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,187 @@
1
+ # -*- coding: utf-8; mode: ruby -*-
2
+ #
3
+ # Copyright (C) 2009-2012 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
+ require "find"
19
+ require "fileutils"
20
+ require "pathname"
21
+ require "erb"
22
+ require "rubygems"
23
+ require "rubygems/package_task"
24
+ require "yard"
25
+ require "bundler/gem_helper"
26
+ require "rake/extensiontask"
27
+ require "packnga"
28
+
29
+ if YAML.const_defined?(:ENGINE)
30
+ begin
31
+ YAML::ENGINE.yamler = "psych"
32
+ rescue LoadError
33
+ end
34
+ end
35
+
36
+ base_dir = File.join(File.dirname(__FILE__))
37
+
38
+ groonga_ext_dir = File.join(base_dir, "ext", "groonga")
39
+ groonga_lib_dir = File.join(base_dir, "lib")
40
+ $LOAD_PATH.unshift(groonga_ext_dir)
41
+ $LOAD_PATH.unshift(groonga_lib_dir)
42
+ ENV["RUBYLIB"] = "#{groonga_lib_dir}:#{groonga_ext_dir}:#{ENV['RUBYLIB']}"
43
+
44
+ helper = Bundler::GemHelper.new(base_dir)
45
+ def helper.version_tag
46
+ version
47
+ end
48
+
49
+ helper.install
50
+ spec = helper.gemspec
51
+
52
+ Gem::PackageTask.new(spec) do |pkg|
53
+ pkg.need_tar_gz = true
54
+ end
55
+
56
+ Packnga::DocumentTask.new(spec) do |task|
57
+ task.original_language = "en"
58
+ task.translate_language = "ja"
59
+ end
60
+
61
+ ranguba_org_dir = Dir.glob("{..,../../www}/ranguba.org").first
62
+ Packnga::ReleaseTask.new(spec) do |task|
63
+ task.index_html_dir = ranguba_org_dir
64
+ end
65
+
66
+ module YARD
67
+ module CodeObjects
68
+ class Proxy
69
+ alias_method :initialize_original, :initialize
70
+ def initialize(namespace, name, type=nil)
71
+ name = name.to_s.gsub(/\AGrn(.*)\z/) do
72
+ suffix = $1
73
+ case suffix
74
+ when ""
75
+ "Groonga"
76
+ when "TableKeySupport"
77
+ "Groonga::Table::KeySupport"
78
+ else
79
+ "Groonga::#{suffix}"
80
+ end
81
+ end
82
+ initialize_original(namespace, name, type)
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ def windows?(platform=nil)
89
+ platform ||= RUBY_PLATFORM
90
+ platform =~ /mswin(?!ce)|mingw|cygwin|bccwin/
91
+ end
92
+
93
+ def collect_binary_files(binary_dir)
94
+ binary_files = []
95
+ Find.find(binary_dir) do |name|
96
+ next unless File.file?(name)
97
+ next if /\.zip\z/i =~ name
98
+ binary_files << name
99
+ end
100
+ binary_files
101
+ end
102
+
103
+ relative_vendor_dir = "vendor"
104
+ relative_binary_dir = File.join("vendor", "local")
105
+ vendor_dir = File.join(base_dir, relative_vendor_dir)
106
+ binary_dir = File.join(base_dir, relative_binary_dir)
107
+
108
+ groonga_win32_i386_p = ENV["GROONGA64"] != "yes"
109
+
110
+ namespace :win32 do
111
+ namespace :groonga do
112
+ task :download do
113
+ require "open-uri"
114
+ require "rroonga-build"
115
+ groonga_version = RroongaBuild::RequiredGroongaVersion::VERSION.join(".")
116
+ base_name = "groonga-#{groonga_version}-"
117
+ if groonga_win32_i386_p
118
+ base_name << "x86"
119
+ else
120
+ base_name << "x64"
121
+ end
122
+ base_name << ".zip"
123
+ base_url = "http://packages.groonga.org/windows/groonga/"
124
+ Dir.chdir(base_dir) do
125
+ unless File.exist?(base_name)
126
+ open("#{base_url}#{base_name}", "rb") do |zip|
127
+ File.open(base_name, "wb") do |output|
128
+ output.print(zip.read)
129
+ end
130
+ end
131
+ end
132
+ sh("unzip", base_name)
133
+ rm_rf(relative_binary_dir)
134
+ mkdir_p(File.dirname(relative_binary_dir))
135
+ mv(File.basename(base_name, ".*"), relative_binary_dir)
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ Rake::ExtensionTask.new("groonga", spec) do |ext|
142
+ if groonga_win32_i386_p
143
+ ext.cross_platform = ["x86-mingw32"]
144
+ else
145
+ ext.cross_platform = ["x64-mingw32"]
146
+ end
147
+ if windows?
148
+ ext.gem_spec.files += collect_binary_files(relative_binary_dir)
149
+ else
150
+ ext.cross_compile = true
151
+ ext.cross_compiling do |_spec|
152
+ if windows?(_spec.platform.to_s)
153
+ _spec.files += collect_binary_files(relative_binary_dir)
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+ file "Makefile" => ["extconf.rb", "ext/groonga/extconf.rb"] do
160
+ extconf_args = []
161
+ if ENV["TRAVIS"]
162
+ extconf_args << "--enable-debug-build"
163
+ end
164
+ ruby("extconf.rb", *extconf_args)
165
+ end
166
+
167
+ desc "Configure"
168
+ task :configure => "Makefile"
169
+
170
+ desc "Run test"
171
+ task :test => :configure do
172
+ ruby("-rubygems", "test/run-test.rb")
173
+ end
174
+
175
+ namespace :test do
176
+ task :install do
177
+ gemspec_helper = Rake.application.jeweler.gemspec_helper
178
+ ruby("-S gem install --user-install #{gemspec_helper.gem_path}")
179
+
180
+ gem_spec = Gem.source_index.find_name("rroonga").last
181
+ installed_path = gem_spec.full_gem_path
182
+ ENV["NO_MAKE"] = "yes"
183
+ ruby("-rubygems", "#{installed_path}/test/run-test.rb")
184
+ end
185
+ end
186
+
187
+ task :default => :test
@@ -1,14 +1,22 @@
1
1
  h1. NEWS
2
2
 
3
+ h2(#3-0-6). 3.0.6: 2013-09-13
4
+
5
+ h3. Improvements
6
+
7
+ * Supported accessing reference column that referes a table that uses
8
+ Int8/UInt8/Int16/UInt16 key.
9
+
3
10
  h2(#3-0-5). 3.0.5: 2013-07-29
4
11
 
5
12
  h3. Improvements
6
13
 
7
- * [dumper] supported dumping of DoubleArrayTrie
14
+ * [dumper] supported dumping of DoubleArrayTrie.
8
15
  * Supported Int8/UInt8/Int16/UInt16 to Ruby conversion.
9
16
  [groonga-dev,01524][Reported by Masaharu YOSHIOKA]
10
17
  * Added memory pool mechanism to reduce GC easily.
11
- Context#push_memory_pool and Context#pop_memory_pool are added.
18
+ {Groonga::Context#push_memory_pool} and {Groonga::Context#pop_memory_pool}
19
+ are added.
12
20
  You can close temporary table objects automatically:
13
21
  <pre>
14
22
  context.push_memory_pool do
@@ -26,8 +26,6 @@ Now you use UTF-8 as the encoding of database.
26
26
 
27
27
  <pre>
28
28
  !!!irb
29
- >> $KCODE = "UTF-8"
30
- => "UTF-8"
31
29
  >> Groonga::Context.default_options = {:encoding => :utf8}
32
30
  => {:encoding=>:utf8}
33
31
  </pre>
@@ -231,7 +231,13 @@ end
231
231
 
232
232
  unless PKGConfig.have_package(package_name, major, minor, micro)
233
233
  unless have_local_groonga?(package_name, major, minor, micro)
234
- install_groonga_locally(major, minor, micro)
234
+ required_version = [major, minor, micro]
235
+ if (required_version <=> LatestGroongaVersion::VERSISON) > 0
236
+ target_version = LatestGroongaVersion::VERSISON
237
+ else
238
+ target_version = required_version
239
+ end
240
+ install_groonga_locally(*target_version)
235
241
  end
236
242
  unless PKGConfig.have_package(package_name, major, minor, micro)
237
243
  exit(false)
@@ -26,7 +26,7 @@ grn_obj *
26
26
  rb_grn_accessor_from_ruby_object (VALUE object)
27
27
  {
28
28
  if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnAccessor))) {
29
- rb_raise(rb_eTypeError, "not a groonga accessor");
29
+ rb_raise(rb_eTypeError, "not a groonga accessor");
30
30
  }
31
31
 
32
32
  return RVAL2GRNOBJECT(object, NULL);
@@ -34,14 +34,14 @@ rb_grn_accessor_from_ruby_object (VALUE object)
34
34
 
35
35
  VALUE
36
36
  rb_grn_accessor_to_ruby_object (grn_ctx *context, grn_obj *table,
37
- grn_bool owner)
37
+ grn_bool owner)
38
38
  {
39
39
  return GRNOBJECT2RVAL(rb_cGrnAccessor, context, table, owner);
40
40
  }
41
41
 
42
42
  void
43
43
  rb_grn_accessor_bind (RbGrnAccessor *rb_accessor,
44
- grn_ctx *context, grn_obj *accessor)
44
+ grn_ctx *context, grn_obj *accessor)
45
45
  {
46
46
  RbGrnObject *rb_grn_object;
47
47
  RbGrnNamedObject *rb_grn_named_object;
@@ -54,22 +54,22 @@ rb_grn_accessor_bind (RbGrnAccessor *rb_accessor,
54
54
 
55
55
  name_size = grn_column_name(context, accessor, name, sizeof(name));
56
56
  if (name_size > 0) {
57
- rb_grn_named_object_set_name(rb_grn_named_object, name, name_size);
57
+ rb_grn_named_object_set_name(rb_grn_named_object, name, name_size);
58
58
  }
59
59
 
60
60
  rb_accessor->value = grn_obj_open(context, GRN_BULK, 0,
61
- rb_grn_object->range_id);
61
+ rb_grn_object->range_id);
62
62
  }
63
63
 
64
64
 
65
65
  void
66
66
  rb_grn_accessor_finalizer (grn_ctx *context, grn_obj *grn_object,
67
- RbGrnAccessor *rb_accessor)
67
+ RbGrnAccessor *rb_accessor)
68
68
  {
69
69
  rb_grn_named_object_finalizer(context, grn_object,
70
- RB_GRN_NAMED_OBJECT(rb_accessor));
70
+ RB_GRN_NAMED_OBJECT(rb_accessor));
71
71
  if (context && rb_accessor->value)
72
- grn_obj_unlink(context, rb_accessor->value);
72
+ grn_obj_unlink(context, rb_accessor->value);
73
73
  rb_accessor->value = NULL;
74
74
  }
75
75
 
@@ -93,10 +93,10 @@ rb_grn_accessor_get_local_name (VALUE self)
93
93
  rb_grn_accessor = SELF(self);
94
94
  rb_grn_named_object = RB_GRN_NAMED_OBJECT(rb_grn_accessor);
95
95
  if (rb_grn_named_object->name_size == 0)
96
- return Qnil;
96
+ return Qnil;
97
97
 
98
98
  return rb_str_new(rb_grn_named_object->name,
99
- rb_grn_named_object->name_size);
99
+ rb_grn_named_object->name_size);
100
100
  }
101
101
 
102
102
  /*
@@ -111,5 +111,5 @@ rb_grn_init_accessor (VALUE mGrn)
111
111
  rb_cGrnAccessor = rb_define_class_under(mGrn, "Accessor", rb_cGrnObject);
112
112
 
113
113
  rb_define_method(rb_cGrnAccessor, "local_name",
114
- rb_grn_accessor_get_local_name, 0);
114
+ rb_grn_accessor_get_local_name, 0);
115
115
  }
@@ -98,40 +98,40 @@ rb_grn_array_s_create (int argc, VALUE *argv, VALUE klass)
98
98
  rb_scan_args(argc, argv, "01", &options);
99
99
 
100
100
  rb_grn_scan_options(options,
101
- "context", &rb_context,
102
- "name", &rb_name,
101
+ "context", &rb_context,
102
+ "name", &rb_name,
103
103
  "path", &rb_path,
104
- "persistent", &rb_persistent,
105
- "value_type", &rb_value_type,
106
- "sub_records", &rb_sub_records,
107
- NULL);
104
+ "persistent", &rb_persistent,
105
+ "value_type", &rb_value_type,
106
+ "sub_records", &rb_sub_records,
107
+ NULL);
108
108
 
109
109
  context = rb_grn_context_ensure(&rb_context);
110
110
 
111
111
  if (!NIL_P(rb_name)) {
112
112
  name = StringValuePtr(rb_name);
113
- name_size = RSTRING_LEN(rb_name);
114
- flags |= GRN_OBJ_PERSISTENT;
113
+ name_size = RSTRING_LEN(rb_name);
114
+ flags |= GRN_OBJ_PERSISTENT;
115
115
  }
116
116
 
117
117
  if (!NIL_P(rb_path)) {
118
118
  path = StringValueCStr(rb_path);
119
- flags |= GRN_OBJ_PERSISTENT;
119
+ flags |= GRN_OBJ_PERSISTENT;
120
120
  }
121
121
 
122
122
  if (RVAL2CBOOL(rb_persistent))
123
- flags |= GRN_OBJ_PERSISTENT;
123
+ flags |= GRN_OBJ_PERSISTENT;
124
124
 
125
125
  if (!NIL_P(rb_value_type))
126
- value_type = RVAL2GRNOBJECT(rb_value_type, &context);
126
+ value_type = RVAL2GRNOBJECT(rb_value_type, &context);
127
127
 
128
128
  if (RVAL2CBOOL(rb_sub_records))
129
- flags |= GRN_OBJ_WITH_SUBREC;
129
+ flags |= GRN_OBJ_WITH_SUBREC;
130
130
 
131
131
  table = grn_table_create(context, name, name_size, path,
132
- flags, NULL, value_type);
132
+ flags, NULL, value_type);
133
133
  if (!table)
134
- rb_grn_context_check(context, rb_ary_new4(argc, argv));
134
+ rb_grn_context_check(context, rb_ary_new4(argc, argv));
135
135
  rb_table = GRNOBJECT2RVAL(klass, context, table, GRN_TRUE);
136
136
  rb_grn_context_check(context, rb_table);
137
137
  rb_iv_set(rb_table, "@context", rb_context);
@@ -186,9 +186,9 @@ rb_grn_array_add (int argc, VALUE *argv, VALUE self)
186
186
  rb_grn_context_check(context, self);
187
187
 
188
188
  if (GRN_ID_NIL == id) {
189
- return Qnil;
189
+ return Qnil;
190
190
  } else {
191
- return rb_grn_record_new_added(self, id, values);
191
+ return rb_grn_record_new_added(self, id, values);
192
192
  }
193
193
  }
194
194
 
@@ -207,9 +207,9 @@ yield_record (VALUE user_data)
207
207
  volatile VALUE record;
208
208
 
209
209
  if (data->id == GRN_ID_NIL) {
210
- record = Qnil;
210
+ record = Qnil;
211
211
  } else {
212
- record = rb_grn_record_new(data->self, data->id, Qnil);
212
+ record = rb_grn_record_new(data->self, data->id, Qnil);
213
213
  }
214
214
  data->record = record;
215
215
 
@@ -307,7 +307,7 @@ rb_grn_array_push (VALUE self)
307
307
  YieldRecordCallbackData data;
308
308
 
309
309
  if (!rb_block_given_p()) {
310
- rb_raise(rb_eArgError,
310
+ rb_raise(rb_eArgError,
311
311
  "tried to call Groonga::Array#push without a block");
312
312
  }
313
313
 
@@ -318,7 +318,7 @@ rb_grn_array_push (VALUE self)
318
318
  data.status = 0;
319
319
  grn_array_push(context, (grn_array *)table, yield_record_callback, &data);
320
320
  if (data.status != 0) {
321
- rb_jump_tag(data.status);
321
+ rb_jump_tag(data.status);
322
322
  }
323
323
  rb_grn_context_check(context, self);
324
324
 
@@ -394,11 +394,11 @@ rb_grn_array_pull (int argc, VALUE *argv, VALUE self)
394
394
  rb_scan_args(argc, argv, "01", &options);
395
395
 
396
396
  rb_grn_scan_options(options,
397
- "block?", &rb_block_p,
398
- NULL);
397
+ "block?", &rb_block_p,
398
+ NULL);
399
399
 
400
400
  if (!rb_block_given_p()) {
401
- rb_raise(rb_eArgError,
401
+ rb_raise(rb_eArgError,
402
402
  "tried to call Groonga::Array#pull without a block");
403
403
  }
404
404
 
@@ -414,7 +414,7 @@ rb_grn_array_pull (int argc, VALUE *argv, VALUE self)
414
414
  grn_array_pull(context, (grn_array *)table, RVAL2CBOOL(rb_block_p),
415
415
  yield_record_callback, &data);
416
416
  if (data.status != 0) {
417
- rb_jump_tag(data.status);
417
+ rb_jump_tag(data.status);
418
418
  }
419
419
  rb_grn_context_check(context, self);
420
420
 
@@ -466,7 +466,7 @@ rb_grn_init_array (VALUE mGrn)
466
466
  rb_cGrnArray = rb_define_class_under(mGrn, "Array", rb_cGrnTable);
467
467
 
468
468
  rb_define_singleton_method(rb_cGrnArray, "create",
469
- rb_grn_array_s_create, -1);
469
+ rb_grn_array_s_create, -1);
470
470
 
471
471
  rb_define_method(rb_cGrnArray, "add", rb_grn_array_add, -1);
472
472
  rb_define_method(rb_cGrnArray, "push", rb_grn_array_push, 0);