rroonga 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ require 'fileutils'
22
22
  require 'pathname'
23
23
  require 'erb'
24
24
  require 'rubygems'
25
+ require 'rubygems/package_task'
25
26
  require 'yard'
26
27
  require 'jeweler'
27
28
  require 'rake/extensiontask'
@@ -59,12 +60,12 @@ def cleanup_white_space(entry)
59
60
  end
60
61
 
61
62
  ENV["VERSION"] ||= guess_version(groonga_ext_dir)
62
- version = ENV["VERSION"]
63
+ version = ENV["VERSION"].dup
63
64
  spec = nil
64
65
  Jeweler::Tasks.new do |_spec|
65
66
  spec = _spec
66
67
  spec.name = "rroonga"
67
- spec.version = version.dup
68
+ spec.version = version
68
69
  spec.rubyforge_project = "groonga"
69
70
  spec.homepage = "http://groonga.rubyforge.org/"
70
71
  authors = File.join(base_dir, "AUTHORS")
@@ -92,9 +93,14 @@ Jeweler::Tasks.new do |_spec|
92
93
  spec.test_files = FileList["test/**/*.rb"]
93
94
  end
94
95
 
96
+ Rake::Task["release"].prerequisites.clear
95
97
  Jeweler::RubygemsDotOrgTasks.new do
96
98
  end
97
99
 
100
+ Gem::PackageTask.new(spec) do |pkg|
101
+ pkg.need_tar_gz = true
102
+ end
103
+
98
104
  module YARD
99
105
  module CodeObjects
100
106
  class Proxy
@@ -117,10 +123,12 @@ module YARD
117
123
  end
118
124
  end
119
125
 
120
- reference_base_dir = Pathname.new("doc/html")
126
+ reference_base_dir = Pathname.new("doc/reference")
121
127
  doc_en_dir = reference_base_dir + "en"
128
+ html_base_dir = Pathname.new("doc/html")
129
+ html_reference_dir = html_base_dir + spec.name
122
130
  YARD::Rake::YardocTask.new do |task|
123
- task.options += ["--title", "#{spec.name} - #{version}"]
131
+ task.options += ["--title", spec.name]
124
132
  # task.options += ["--charset", "UTF-8"]
125
133
  task.options += ["--readme", "README.textile"]
126
134
  task.options += ["--files", "doc/text/**/*"]
@@ -185,31 +193,28 @@ end
185
193
 
186
194
  include ERB::Util
187
195
 
188
- def apply_template(file, top_path, current_page, head, header, footer, language)
189
- content = File.read(file)
190
- content = content.sub(/lang="en"/, 'lang="#{language}"')
196
+ def apply_template(content, paths, templates, language)
197
+ content = content.sub(/lang="en"/, "lang=\"#{language}\"")
191
198
 
192
199
  title = nil
193
200
  content = content.sub(/<title>(.+?)<\/title>/m) do
194
201
  title = $1
195
- head.result(binding)
202
+ templates[:head].result(binding)
196
203
  end
197
204
 
198
205
  content = content.sub(/<body(?:.*?)>/) do |body_start|
199
- "#{body_start}\n#{header.result(binding)}\n"
206
+ "#{body_start}\n#{templates[:header].result(binding)}\n"
200
207
  end
201
208
 
202
209
  content = content.sub(/<\/body/) do |body_end|
203
- "\n#{footer.result(binding)}\n#{body_end}"
210
+ "\n#{templates[:footer].result(binding)}\n#{body_end}"
204
211
  end
205
212
 
206
- File.open(file, "w") do |file|
207
- file.print(content)
208
- end
213
+ content
209
214
  end
210
215
 
211
216
  def erb_template(name)
212
- file = File.join("html", "#{name}.html.erb")
217
+ file = File.join("doc/templates", "#{name}.html.erb")
213
218
  template = File.read(file)
214
219
  erb = ERB.new(template, nil, "-")
215
220
  erb.filename = file
@@ -233,7 +238,7 @@ end
233
238
  namespace :reference do
234
239
  translate_languages = [:ja]
235
240
  supported_languages = [:en, *translate_languages]
236
- html_files = FileList["doc/html/en/**/*.html"].to_a
241
+ html_files = FileList[doc_en_dir + "**/*.html"].to_a
237
242
 
238
243
  directory reference_base_dir.to_s
239
244
  CLOBBER.include(reference_base_dir.to_s)
@@ -314,50 +319,144 @@ namespace :reference do
314
319
  namespace :publication do
315
320
  task :prepare do
316
321
  supported_languages.each do |language|
317
- doc_dir = Pathname.new("#{reference_base_dir}/#{language}")
322
+ raw_reference_dir = reference_base_dir + language.to_s
323
+ prepared_reference_dir = html_reference_dir + language.to_s
324
+ rm_rf(prepared_reference_dir.to_s)
318
325
  head = erb_template("head.#{language}")
319
326
  header = erb_template("header.#{language}")
320
327
  footer = erb_template("footer.#{language}")
321
- doc_dir.find do |file|
322
- case file.basename.to_s
323
- when "_index.html", /\A(?:class|method|file)_list.html\z/
324
- next
325
- when /\.html\z/
326
- relative_dir_path = file.relative_path_from(doc_dir).dirname
327
- current_page = relative_dir_path + file.basename
328
- top_path = doc_dir.relative_path_from(file.dirname).to_s
329
- apply_template(file, top_path, current_page,
330
- head, header, footer, language)
328
+ raw_reference_dir.find do |path|
329
+ relative_path = path.relative_path_from(raw_reference_dir)
330
+ prepared_path = prepared_reference_dir + relative_path
331
+ if path.directory?
332
+ mkdir_p(prepared_path.to_s)
333
+ else
334
+ case path.basename.to_s
335
+ when /(?:file|method|class)_list\.html\z/
336
+ cp(path.to_s, prepared_path.to_s)
337
+ when /\.html\z/
338
+ relative_dir_path = relative_path.dirname
339
+ current_path = relative_dir_path + path.basename
340
+ if current_path.basename.to_s == "index.html"
341
+ current_path = current_path.dirname
342
+ end
343
+ top_path = html_base_dir.relative_path_from(prepared_path.dirname)
344
+ paths = {
345
+ :top => top_path,
346
+ :current => current_path,
347
+ }
348
+ templates = {
349
+ :head => head,
350
+ :header => header,
351
+ :footer => footer
352
+ }
353
+ content = apply_template(File.read(path.to_s),
354
+ paths,
355
+ templates,
356
+ language)
357
+ File.open(prepared_path.to_s, "w") do |file|
358
+ file.print(content)
359
+ end
360
+ else
361
+ cp(path.to_s, prepared_path.to_s)
362
+ end
331
363
  end
332
364
  end
333
365
  end
334
- File.open("#{reference_base_dir}/.htaccess", "w") do |file|
335
- file.puts("Redirect permanent /rroonga/text/TUTORIAL_ja_rdoc.html " +
336
- "http://groonga.rubyforge.org/rroonga/ja/file.tutorial.html")
337
- file.puts("RedirectMatch permanent ^/rroonga/$ " +
338
- "http://groonga.rubyforge.org/rroonga/en/")
366
+ File.open("#{html_reference_dir}/.htaccess", "w") do |file|
367
+ file.puts("Redirect permanent /#{spec.name}/text/TUTORIAL_ja_rdoc.html " +
368
+ "#{spec.homepage}#{spec.name}/ja/file.tutorial.html")
369
+ file.puts("RedirectMatch permanent ^/#{spec.name}/$ " +
370
+ "#{spec.homepage}#{spec.name}/en/")
339
371
  end
340
372
  end
341
373
  end
342
374
 
343
375
  desc "Upload document to rubyforge."
344
376
  task :publish => [:generate, "reference:publication:prepare"] do
345
- rsync_to_rubyforge(spec, "#{reference_base_dir}/", spec.name,
346
- :delete => true)
377
+ rsync_to_rubyforge(spec, "#{html_reference_dir}/", spec.name)
347
378
  end
348
379
  end
349
380
 
350
381
  namespace :html do
351
382
  desc "Publish HTML to Web site."
352
383
  task :publish do
353
- rsync_to_rubyforge(spec, "html/", "")
384
+ rsync_to_rubyforge(spec, "#{html_base_dir}/", "")
354
385
  end
355
386
  end
356
387
 
357
388
  desc "Upload document and HTML to rubyforge."
358
- task :publish => ["reference:publish", "html:publish"]
389
+ task :publish => ["html:publish", "reference:publish"]
359
390
 
360
391
  desc "Tag the current revision."
361
392
  task :tag do
362
393
  sh("git tag -a #{version} -m 'release #{version}!!!'")
363
394
  end
395
+
396
+ namespace :release do
397
+ namespace :info do
398
+ desc "update version in index HTML."
399
+ task :update do
400
+ old_version = ENV["OLD_VERSION"]
401
+ old_release_date = ENV["OLD_RELEASE_DATE"]
402
+ new_release_date = ENV["RELEASE_DATE"] || Time.now.strftime("%Y-%m-%d")
403
+ new_version = ENV["VERSION"]
404
+
405
+ empty_options = []
406
+ empty_options << "OLD_VERSION" if old_version.nil?
407
+ empty_options << "OLD_RELEASE_DATE" if old_release_date.nil?
408
+
409
+ unless empty_options.empty?
410
+ raise ArgumentError, "Specify option(s) of #{empty_options.join(",")}."
411
+ end
412
+
413
+ indexes = ["doc/html/index.html", "doc/html/index.html.ja"]
414
+ indexes.each do |index|
415
+ content = replaced_content = File.read(index)
416
+ [[old_version, new_version],
417
+ [old_release_date, new_release_date]].each do |old, new|
418
+ replaced_content = replaced_content.gsub(/#{Regexp.escape(old)}/, new)
419
+ if /\./ =~ old
420
+ old_undnerscore = old.gsub(/\./, '-')
421
+ new_underscore = new.gsub(/\./, '-')
422
+ replaced_content =
423
+ replaced_content.gsub(/#{Regexp.escape(old_underscore)}/,
424
+ new_underscore)
425
+ end
426
+ end
427
+
428
+ next if replaced_content == content
429
+ File.open(index, "w") do |output|
430
+ output.print(replaced_content)
431
+ end
432
+ end
433
+ end
434
+ end
435
+
436
+ namespace :rubyforge do
437
+ desc "Upload tar.gz to RubyForge."
438
+ task :upload => "package" do
439
+ ruby("-S", "rubyforge",
440
+ "add_release",
441
+ spec.rubyforge_project,
442
+ spec.name,
443
+ spec.version.to_s,
444
+ "pkg/#{spec.name}-#{spec.version}.tar.gz")
445
+ end
446
+ end
447
+
448
+ desc "Release to RubyForge."
449
+ task :rubyforge => "release:rubyforge:upload"
450
+ end
451
+
452
+ namespace :test do
453
+ task :install do
454
+ gemspec_helper = Rake.application.jeweler.gemspec_helper
455
+ ruby("-S gem install --user-install #{gemspec_helper.gem_path}")
456
+
457
+ gem_spec = Gem.source_index.find_name("rroonga").last
458
+ installed_path = gem_spec.full_gem_path
459
+ ENV["NO_MAKE"] = "yes"
460
+ ruby("-rubygems", "#{installed_path}/test/run-test.rb")
461
+ end
462
+ end
data/bin/grndump CHANGED
@@ -24,6 +24,7 @@ require 'groonga'
24
24
 
25
25
  options = OpenStruct.new
26
26
  options.tables = []
27
+ options.exclude_tables = []
27
28
  options.dump_schema = true
28
29
  options.dump_tables = true
29
30
  option_parser = OptionParser.new do |parser|
@@ -50,6 +51,18 @@ option_parser = OptionParser.new do |parser|
50
51
  options.tables << table
51
52
  end
52
53
  end
54
+
55
+ parser.on("--exclude-table=TABLE",
56
+ "don't dump TABLE.",
57
+ "use this option multiple to not dump multiple tables.",
58
+ "use /.../ as TABLE to match table name with regexp.") do |table|
59
+ case table
60
+ when /\A\/(.*)\/(i)?\z/
61
+ options.exclude_tables << Regexp.new($1, $2 == "i")
62
+ when
63
+ options.exclude_tables << table
64
+ end
65
+ end
53
66
  end
54
67
  args = option_parser.parse!(ARGV)
55
68
 
@@ -66,6 +79,7 @@ dumper_options = {
66
79
  :dump_schema => options.dump_schema,
67
80
  :dump_tables => options.dump_tables,
68
81
  :tables => options.tables,
82
+ :exclude_tables => options.exclude_tables,
69
83
  }
70
84
  database_dumper = Groonga::DatabaseDumper.new(dumper_options)
71
85
  database_dumper.dump
data/ext/groonga/Makefile CHANGED
@@ -57,12 +57,12 @@ cflags = $(optflags) $(debugflags) $(warnflags)
57
57
  optflags = -O3
58
58
  debugflags = -ggdb
59
59
  warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long
60
- CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/home/kou/work/ruby/rroonga/vendor/local/include/groonga
60
+ CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/tmp/local/include/groonga
61
61
  INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
62
62
  DEFS =
63
- CPPFLAGS = -DRB_GRN_COMPILATION -DGRN_MAJOR_VERSION=1 -DGRN_MINOR_VERSION=2 -DGRN_MICRO_VERSION=3 -DHAVE_RB_ERRINFO -DHAVE_TYPE_ENUM_RUBY_VALUE_TYPE $(DEFS) $(cppflags)
63
+ CPPFLAGS = -DRB_GRN_COMPILATION -DGRN_MAJOR_VERSION=1 -DGRN_MINOR_VERSION=2 -DGRN_MICRO_VERSION=1 -DHAVE_RB_ERRINFO -DHAVE_TYPE_ENUM_RUBY_VALUE_TYPE $(DEFS) $(cppflags)
64
64
  CXXFLAGS = $(CFLAGS) -fno-strict-aliasing -g
65
- ldflags = -L. -rdynamic -Wl,-export-dynamic -L/home/kou/work/ruby/rroonga/vendor/local/lib
65
+ ldflags = -L. -rdynamic -Wl,-export-dynamic -L/tmp/local/lib
66
66
  dldflags =
67
67
  ARCH_FLAG =
68
68
  DLDFLAGS = $(ldflags) $(dldflags)
@@ -105,8 +105,8 @@ extout_prefix =
105
105
  target_prefix =
106
106
  LOCAL_LIBS =
107
107
  LIBS = $(LIBRUBYARG_SHARED) -lgroonga -lpthread -lrt -ldl -lcrypt -lm -lc
108
- SRCS = rb-grn-procedure.c rb-grn-column.c rb-grn-index-column.c rb-grn-encoding-support.c rb-grn-variable.c rb-grn-table.c rb-grn-hash-cursor.c rb-grn-table-cursor-key-support.c rb-grn-object.c rb-grn-view-accessor.c rb-grn-table-key-support.c rb-grn-array.c rb-grn-patricia-trie.c rb-grn-utils.c rb-grn-record.c rb-grn-query.c rb-groonga.c rb-grn-exception.c rb-grn-variable-size-column.c rb-grn-encoding.c rb-grn-expression-builder.c rb-grn-operator.c rb-grn-snippet.c rb-grn-array-cursor.c rb-grn-type.c rb-grn-table-cursor.c rb-grn-fix-size-column.c rb-grn-view-cursor.c rb-grn-logger.c rb-grn-plugin.c rb-grn-database.c rb-grn-view-record.c rb-grn-patricia-trie-cursor.c rb-grn-index-cursor.c rb-grn-view.c rb-grn-accessor.c rb-grn-context.c rb-grn-posting.c rb-grn-expression.c rb-grn-hash.c
109
- OBJS = rb-grn-procedure.o rb-grn-column.o rb-grn-index-column.o rb-grn-encoding-support.o rb-grn-variable.o rb-grn-table.o rb-grn-hash-cursor.o rb-grn-table-cursor-key-support.o rb-grn-object.o rb-grn-view-accessor.o rb-grn-table-key-support.o rb-grn-array.o rb-grn-patricia-trie.o rb-grn-utils.o rb-grn-record.o rb-grn-query.o rb-groonga.o rb-grn-exception.o rb-grn-variable-size-column.o rb-grn-encoding.o rb-grn-expression-builder.o rb-grn-operator.o rb-grn-snippet.o rb-grn-array-cursor.o rb-grn-type.o rb-grn-table-cursor.o rb-grn-fix-size-column.o rb-grn-view-cursor.o rb-grn-logger.o rb-grn-plugin.o rb-grn-database.o rb-grn-view-record.o rb-grn-patricia-trie-cursor.o rb-grn-index-cursor.o rb-grn-view.o rb-grn-accessor.o rb-grn-context.o rb-grn-posting.o rb-grn-expression.o rb-grn-hash.o
108
+ SRCS = rb-grn-exception.c rb-grn-view-accessor.c rb-grn-hash-cursor.c rb-grn-query.c rb-grn-record.c rb-grn-variable.c rb-grn-view.c rb-grn-table-cursor-key-support.c rb-grn-fix-size-column.c rb-grn-context.c rb-grn-plugin.c rb-grn-hash.c rb-grn-variable-size-column.c rb-grn-index-column.c rb-grn-operator.c rb-grn-table-key-support.c rb-grn-patricia-trie.c rb-grn-table-cursor.c rb-grn-object.c rb-grn-table.c rb-grn-procedure.c rb-grn-snippet.c rb-grn-encoding-support.c rb-grn-view-record.c rb-grn-patricia-trie-cursor.c rb-grn-array.c rb-grn-database.c rb-grn-view-cursor.c rb-grn-column.c rb-grn-index-cursor.c rb-grn-type.c rb-grn-accessor.c rb-grn-posting.c rb-groonga.c rb-grn-array-cursor.c rb-grn-utils.c rb-grn-logger.c rb-grn-expression.c rb-grn-encoding.c rb-grn-expression-builder.c
109
+ OBJS = rb-grn-exception.o rb-grn-view-accessor.o rb-grn-hash-cursor.o rb-grn-query.o rb-grn-record.o rb-grn-variable.o rb-grn-view.o rb-grn-table-cursor-key-support.o rb-grn-fix-size-column.o rb-grn-context.o rb-grn-plugin.o rb-grn-hash.o rb-grn-variable-size-column.o rb-grn-index-column.o rb-grn-operator.o rb-grn-table-key-support.o rb-grn-patricia-trie.o rb-grn-table-cursor.o rb-grn-object.o rb-grn-table.o rb-grn-procedure.o rb-grn-snippet.o rb-grn-encoding-support.o rb-grn-view-record.o rb-grn-patricia-trie-cursor.o rb-grn-array.o rb-grn-database.o rb-grn-view-cursor.o rb-grn-column.o rb-grn-index-cursor.o rb-grn-type.o rb-grn-accessor.o rb-grn-posting.o rb-groonga.o rb-grn-array-cursor.o rb-grn-utils.o rb-grn-logger.o rb-grn-expression.o rb-grn-encoding.o rb-grn-expression-builder.o
110
110
  TARGET = groonga
111
111
  DLLIB = $(TARGET).so
112
112
  EXTSTATIC =
@@ -154,54 +154,54 @@ install-rb: pre-install-rb install-rb-default
154
154
  install-rb-default: pre-install-rb-default
155
155
  pre-install-rb: Makefile
156
156
  pre-install-rb-default: Makefile
157
- pre-install-rb: $(RUBYLIBDIR)/groonga
158
- install-rb: $(RUBYLIBDIR)/groonga/schema.rb
159
- $(RUBYLIBDIR)/groonga/schema.rb: $(srcdir)/../../lib/groonga/schema.rb
157
+ pre-install-rb: $(RUBYLIBDIR)
158
+ install-rb: $(RUBYLIBDIR)/groonga.rb
159
+ $(RUBYLIBDIR)/groonga.rb: $(srcdir)/../../lib/groonga.rb
160
160
  @-$(MAKEDIRS) $(@D)
161
- $(INSTALL_DATA) $(srcdir)/../../lib/groonga/schema.rb $(@D)
162
- install-rb: $(RUBYLIBDIR)/groonga/pagination.rb
163
- $(RUBYLIBDIR)/groonga/pagination.rb: $(srcdir)/../../lib/groonga/pagination.rb
161
+ $(INSTALL_DATA) $(srcdir)/../../lib/groonga.rb $(@D)
162
+ pre-install-rb: $(RUBYLIBDIR)/groonga
163
+ install-rb: $(RUBYLIBDIR)/groonga/record.rb
164
+ $(RUBYLIBDIR)/groonga/record.rb: $(srcdir)/../../lib/groonga/record.rb
164
165
  @-$(MAKEDIRS) $(@D)
165
- $(INSTALL_DATA) $(srcdir)/../../lib/groonga/pagination.rb $(@D)
166
+ $(INSTALL_DATA) $(srcdir)/../../lib/groonga/record.rb $(@D)
166
167
  install-rb: $(RUBYLIBDIR)/groonga/view-record.rb
167
168
  $(RUBYLIBDIR)/groonga/view-record.rb: $(srcdir)/../../lib/groonga/view-record.rb
168
169
  @-$(MAKEDIRS) $(@D)
169
170
  $(INSTALL_DATA) $(srcdir)/../../lib/groonga/view-record.rb $(@D)
170
- install-rb: $(RUBYLIBDIR)/groonga/patricia-trie.rb
171
- $(RUBYLIBDIR)/groonga/patricia-trie.rb: $(srcdir)/../../lib/groonga/patricia-trie.rb
171
+ install-rb: $(RUBYLIBDIR)/groonga/context.rb
172
+ $(RUBYLIBDIR)/groonga/context.rb: $(srcdir)/../../lib/groonga/context.rb
172
173
  @-$(MAKEDIRS) $(@D)
173
- $(INSTALL_DATA) $(srcdir)/../../lib/groonga/patricia-trie.rb $(@D)
174
- install-rb: $(RUBYLIBDIR)/groonga/dumper.rb
175
- $(RUBYLIBDIR)/groonga/dumper.rb: $(srcdir)/../../lib/groonga/dumper.rb
174
+ $(INSTALL_DATA) $(srcdir)/../../lib/groonga/context.rb $(@D)
175
+ install-rb: $(RUBYLIBDIR)/groonga/pagination.rb
176
+ $(RUBYLIBDIR)/groonga/pagination.rb: $(srcdir)/../../lib/groonga/pagination.rb
176
177
  @-$(MAKEDIRS) $(@D)
177
- $(INSTALL_DATA) $(srcdir)/../../lib/groonga/dumper.rb $(@D)
178
+ $(INSTALL_DATA) $(srcdir)/../../lib/groonga/pagination.rb $(@D)
179
+ install-rb: $(RUBYLIBDIR)/groonga/schema.rb
180
+ $(RUBYLIBDIR)/groonga/schema.rb: $(srcdir)/../../lib/groonga/schema.rb
181
+ @-$(MAKEDIRS) $(@D)
182
+ $(INSTALL_DATA) $(srcdir)/../../lib/groonga/schema.rb $(@D)
178
183
  install-rb: $(RUBYLIBDIR)/groonga/posting.rb
179
184
  $(RUBYLIBDIR)/groonga/posting.rb: $(srcdir)/../../lib/groonga/posting.rb
180
185
  @-$(MAKEDIRS) $(@D)
181
186
  $(INSTALL_DATA) $(srcdir)/../../lib/groonga/posting.rb $(@D)
182
- install-rb: $(RUBYLIBDIR)/groonga/context.rb
183
- $(RUBYLIBDIR)/groonga/context.rb: $(srcdir)/../../lib/groonga/context.rb
184
- @-$(MAKEDIRS) $(@D)
185
- $(INSTALL_DATA) $(srcdir)/../../lib/groonga/context.rb $(@D)
186
- install-rb: $(RUBYLIBDIR)/groonga/record.rb
187
- $(RUBYLIBDIR)/groonga/record.rb: $(srcdir)/../../lib/groonga/record.rb
187
+ install-rb: $(RUBYLIBDIR)/groonga/patricia-trie.rb
188
+ $(RUBYLIBDIR)/groonga/patricia-trie.rb: $(srcdir)/../../lib/groonga/patricia-trie.rb
188
189
  @-$(MAKEDIRS) $(@D)
189
- $(INSTALL_DATA) $(srcdir)/../../lib/groonga/record.rb $(@D)
190
+ $(INSTALL_DATA) $(srcdir)/../../lib/groonga/patricia-trie.rb $(@D)
190
191
  install-rb: $(RUBYLIBDIR)/groonga/expression-builder.rb
191
192
  $(RUBYLIBDIR)/groonga/expression-builder.rb: $(srcdir)/../../lib/groonga/expression-builder.rb
192
193
  @-$(MAKEDIRS) $(@D)
193
194
  $(INSTALL_DATA) $(srcdir)/../../lib/groonga/expression-builder.rb $(@D)
194
- pre-install-rb: $(RUBYLIBDIR)
195
- install-rb: $(RUBYLIBDIR)/groonga.rb
196
- $(RUBYLIBDIR)/groonga.rb: $(srcdir)/../../lib/groonga.rb
195
+ install-rb: $(RUBYLIBDIR)/groonga/dumper.rb
196
+ $(RUBYLIBDIR)/groonga/dumper.rb: $(srcdir)/../../lib/groonga/dumper.rb
197
197
  @-$(MAKEDIRS) $(@D)
198
- $(INSTALL_DATA) $(srcdir)/../../lib/groonga.rb $(@D)
198
+ $(INSTALL_DATA) $(srcdir)/../../lib/groonga/dumper.rb $(@D)
199
199
  $(RUBYARCHDIR):
200
200
  $(MAKEDIRS) $@
201
- $(RUBYLIBDIR)/groonga:
202
- $(MAKEDIRS) $@
203
201
  $(RUBYLIBDIR):
204
202
  $(MAKEDIRS) $@
203
+ $(RUBYLIBDIR)/groonga:
204
+ $(MAKEDIRS) $@
205
205
 
206
206
  site-install: site-install-so site-install-rb
207
207
  site-install-so: install-so
@@ -130,10 +130,9 @@ unless PKGConfig.have_package(package_name, major, minor, micro)
130
130
  unless have_local_groonga?(package_name, major, minor, micro)
131
131
  install_groonga_locally(major, minor, micro)
132
132
  end
133
- end
134
-
135
- unless PKGConfig.have_package(package_name, major, minor, micro)
136
- have_local_groonga?(package_name, major, minor, micro) or exit 1
133
+ unless PKGConfig.have_package(package_name, major, minor, micro)
134
+ exit(false)
135
+ end
137
136
  add_rpath_for_local_groonga
138
137
  end
139
138
 
@@ -53,6 +53,9 @@ rb_grn_context_from_ruby_object (VALUE object)
53
53
  Data_Get_Struct(object, RbGrnContext, rb_grn_context);
54
54
  if (!rb_grn_context)
55
55
  rb_raise(rb_eGrnError, "groonga context is NULL");
56
+ if (!rb_grn_context->context)
57
+ rb_raise(rb_eGrnClosed,
58
+ "can't access already closed groonga context");
56
59
  return rb_grn_context->context;
57
60
  }
58
61
 
@@ -88,7 +91,7 @@ rb_grn_context_free (void *pointer)
88
91
 
89
92
  context = rb_grn_context->context;
90
93
  debug("context-free: %p\n", context);
91
- if (!rb_grn_exited)
94
+ if (context && !rb_grn_exited)
92
95
  rb_grn_context_fin(context);
93
96
  debug("context-free: %p: done\n", context);
94
97
  xfree(rb_grn_context);
@@ -332,7 +335,8 @@ rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
332
335
  rb_grn_context = ALLOC(RbGrnContext);
333
336
  DATA_PTR(self) = rb_grn_context;
334
337
  rb_grn_context->self = self;
335
- context = rb_grn_context->context = grn_ctx_open(flags);
338
+ grn_ctx_init(&(rb_grn_context->context_entity), flags);
339
+ context = rb_grn_context->context = &(rb_grn_context->context_entity);
336
340
  rb_grn_context_check(context, self);
337
341
 
338
342
  GRN_CTX_USER_DATA(context)->ptr = rb_grn_context;
@@ -350,6 +354,45 @@ rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
350
354
  return Qnil;
351
355
  }
352
356
 
357
+ /*
358
+ * call-seq:
359
+ * context.close
360
+ *
361
+ * Closes the _context_. Closed _context_ can't be used
362
+ * anymore.
363
+ */
364
+ static VALUE
365
+ rb_grn_context_close (VALUE self)
366
+ {
367
+ int rc;
368
+ grn_ctx *context;
369
+ RbGrnContext *rb_grn_context;
370
+
371
+ context = SELF(self);
372
+ rc = grn_ctx_fin(context);
373
+ Data_Get_Struct(self, RbGrnContext, rb_grn_context);
374
+ rb_grn_context->context = NULL;
375
+ rb_grn_rc_check(rc, self);
376
+
377
+ return Qnil;
378
+ }
379
+
380
+ /*
381
+ * call-seq:
382
+ * context.closed?
383
+ *
384
+ * Returns whether the _context_ is closed by #close or not.
385
+ */
386
+ static VALUE
387
+ rb_grn_context_closed_p (VALUE self)
388
+ {
389
+ RbGrnContext *rb_grn_context;
390
+
391
+ Data_Get_Struct(self, RbGrnContext, rb_grn_context);
392
+
393
+ return CBOOL2RVAL(rb_grn_context->context == NULL);
394
+ }
395
+
353
396
  /*
354
397
  * call-seq:
355
398
  * context.inspect -> String
@@ -763,6 +806,9 @@ rb_grn_init_context (VALUE mGrn)
763
806
 
764
807
  rb_define_method(cGrnContext, "initialize", rb_grn_context_initialize, -1);
765
808
 
809
+ rb_define_method(cGrnContext, "close", rb_grn_context_close, 0);
810
+ rb_define_method(cGrnContext, "closed?", rb_grn_context_closed_p, 0);
811
+
766
812
  rb_define_method(cGrnContext, "inspect", rb_grn_context_inspect, 0);
767
813
 
768
814
  rb_define_method(cGrnContext, "encoding", rb_grn_context_get_encoding, 0);
@@ -19,7 +19,7 @@
19
19
  #include "rb-grn.h"
20
20
 
21
21
  VALUE rb_eGrnError;
22
- VALUE rb_eGrnObjectClosed;
22
+ VALUE rb_eGrnClosed;
23
23
  VALUE rb_eGrnNoSuchColumn;
24
24
 
25
25
  static VALUE eGrnEndOfData;
@@ -589,14 +589,25 @@ rb_grn_init_exception (VALUE mGrn)
589
589
  rb_eGrnError =
590
590
  rb_define_class_under(mGrn, "Error", rb_eStandardError);
591
591
 
592
+ /*
593
+ * Document-class: Groonga::Closed
594
+ *
595
+ * groongaレベルでは破棄されているが、Rubyレベルでは生き
596
+ * ているオブジェクトにアクセスすると発生する。
597
+ *
598
+ * @since 1.2.3
599
+ */
600
+ rb_eGrnClosed = rb_define_class_under(mGrn, "Closed", rb_eGrnError);
601
+
592
602
  /*
593
603
  * Document-class: Groonga::ObjectClosed
594
604
  *
595
605
  * groongaレベルでは破棄されているが、Rubyレベルでは生き
596
606
  * ているオブジェクトにアクセスすると発生する。
607
+ *
608
+ * @deprecated since 1.2.3. Use Groonga::Closed instead.
597
609
  */
598
- rb_eGrnObjectClosed =
599
- rb_define_class_under(mGrn, "ObjectClosed", rb_eGrnError);
610
+ rb_define_const(mGrn, "ObjectClosed", rb_eGrnClosed);
600
611
 
601
612
  /*
602
613
  * Document-class: Groonga::NoSuchColumn
@@ -464,7 +464,7 @@ rb_grn_object_deconstruct (RbGrnObject *rb_grn_object,
464
464
  return;
465
465
 
466
466
  if (!rb_grn_object->object) {
467
- rb_raise(rb_eGrnObjectClosed,
467
+ rb_raise(rb_eGrnClosed,
468
468
  "can't access already closed groonga object: %s",
469
469
  rb_grn_inspect(CLASS_OF(rb_grn_object->self)));
470
470
  }
data/ext/groonga/rb-grn.h CHANGED
@@ -69,7 +69,7 @@ RB_GRN_BEGIN_DECLS
69
69
 
70
70
  #define RB_GRN_MAJOR_VERSION 1
71
71
  #define RB_GRN_MINOR_VERSION 2
72
- #define RB_GRN_MICRO_VERSION 4
72
+ #define RB_GRN_MICRO_VERSION 5
73
73
 
74
74
  #define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
75
75
 
@@ -93,6 +93,7 @@ typedef struct _RbGrnContext RbGrnContext;
93
93
  struct _RbGrnContext
94
94
  {
95
95
  grn_ctx *context;
96
+ grn_ctx context_entity;
96
97
  VALUE self;
97
98
  };
98
99
 
@@ -192,7 +193,7 @@ struct _RbGrnPlugin
192
193
  RB_GRN_VAR grn_bool rb_grn_exited;
193
194
 
194
195
  RB_GRN_VAR VALUE rb_eGrnError;
195
- RB_GRN_VAR VALUE rb_eGrnObjectClosed;
196
+ RB_GRN_VAR VALUE rb_eGrnClosed;
196
197
  RB_GRN_VAR VALUE rb_eGrnNoSuchColumn;
197
198
  RB_GRN_VAR VALUE rb_eGrnInvalidArgument;
198
199
  RB_GRN_VAR VALUE rb_cGrnObject;
@@ -72,7 +72,8 @@ module Groonga
72
72
  options[:database].each(:order_by => :key) do |object|
73
73
  next unless object.is_a?(Groonga::Table)
74
74
  next if object.size.zero?
75
- next unless target_table?(options[:tables], object)
75
+ next if target_table?(options[:exclude_tables], object, false)
76
+ next unless target_table?(options[:tables], object, true)
76
77
  options[:output].write("\n") if !first_table or options[:dump_schema]
77
78
  first_table = false
78
79
  dump_records(object, options)
@@ -93,8 +94,8 @@ module Groonga
93
94
  output.write("register #{plugin_name}\n")
94
95
  end
95
96
 
96
- def target_table?(target_tables, table)
97
- return true if target_tables.nil? or target_tables.empty?
97
+ def target_table?(target_tables, table, default_value)
98
+ return default_value if target_tables.nil? or target_tables.empty?
98
99
  target_tables.any? do |name|
99
100
  name === table.name
100
101
  end
@@ -278,7 +279,7 @@ module Groonga
278
279
  target_table_name = column.range.name
279
280
  sources = column.sources
280
281
  source_names = sources.collect do |source|
281
- if source.is_a?(table.class)
282
+ if source.is_a?(Groonga::Table)
282
283
  "_key".dump
283
284
  else
284
285
  source.local_name.dump
@@ -393,7 +394,7 @@ module Groonga
393
394
  parameters << "#{flags.join('|')}"
394
395
  parameters << "#{column.range.name}"
395
396
  source_names = column.sources.collect do |source|
396
- if source.is_a?(table.class)
397
+ if source.is_a?(Groonga::Table)
397
398
  "_key"
398
399
  else
399
400
  source.local_name
@@ -1217,10 +1217,6 @@ module Groonga
1217
1217
  sub_records = options[:sub_records]
1218
1218
  sub_records = false if sub_records.nil?
1219
1219
  return false unless table.support_sub_records? == sub_records
1220
- path = options[:path]
1221
- if path and File.expand_path(table.path) != File.expand_path(path)
1222
- return false
1223
- end
1224
1220
 
1225
1221
  case table
1226
1222
  when Groonga::Array
data/test/test-context.rb CHANGED
@@ -120,4 +120,11 @@ class ContextTest < Test::Unit::TestCase
120
120
  context.match_escalation_threshold = -1
121
121
  assert_equal(-1, context.match_escalation_threshold)
122
122
  end
123
+
124
+ def test_close
125
+ context = Groonga::Context.new
126
+ assert_false(context.closed?)
127
+ context.close
128
+ assert_true(context.closed?)
129
+ end
123
130
  end
@@ -157,6 +157,66 @@ load --table Posts
157
157
  EOS
158
158
  end
159
159
 
160
+ def test_exclude_tables
161
+ dump_options = {
162
+ :exclude_tables => ["Posts"],
163
+ }
164
+ assert_equal(<<-EOS, dump(dump_options))
165
+ #{dumped_schema.chomp}
166
+
167
+ load --table Tags
168
+ [
169
+ ["_key","name"],
170
+ ["search",""],
171
+ ["mori",""]
172
+ ]
173
+
174
+ load --table Users
175
+ [
176
+ ["_key","name"],
177
+ ["mori",""]
178
+ ]
179
+ EOS
180
+ end
181
+
182
+ def test_exclude_tables_with_regexp
183
+ dump_options = {
184
+ :exclude_tables => [/Posts?/],
185
+ }
186
+ assert_equal(<<-EOS, dump(dump_options))
187
+ #{dumped_schema.chomp}
188
+
189
+ load --table Tags
190
+ [
191
+ ["_key","name"],
192
+ ["search",""],
193
+ ["mori",""]
194
+ ]
195
+
196
+ load --table Users
197
+ [
198
+ ["_key","name"],
199
+ ["mori",""]
200
+ ]
201
+ EOS
202
+ end
203
+
204
+ def test_tables_combination
205
+ dump_options = {
206
+ :exclude_tables => ["Posts"],
207
+ :tables => ["Posts", "Users"],
208
+ }
209
+ assert_equal(<<-EOS, dump(dump_options))
210
+ #{dumped_schema.chomp}
211
+
212
+ load --table Users
213
+ [
214
+ ["_key","name"],
215
+ ["mori",""]
216
+ ]
217
+ EOS
218
+ end
219
+
160
220
  def test_no_schema
161
221
  assert_equal(<<-EOS, dump(:dump_schema => false))
162
222
  load --table Posts
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2011 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
@@ -99,28 +99,6 @@ module SchemaCreateTableTests
99
99
  end
100
100
  end
101
101
 
102
- def test_same_path
103
- path = (@tmp_dir + "posts.groonga").to_s
104
- Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
105
- end
106
-
107
- Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
108
- end
109
- assert_equal(path, context["Posts"].path)
110
- end
111
-
112
- def test_different_path
113
- path = (@tmp_dir + "posts.groonga").to_s
114
- Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
115
- end
116
-
117
- assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
118
- path = (@tmp_dir + "posts.grn").to_s
119
- Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
120
- end
121
- end
122
- end
123
-
124
102
  def test_default_path
125
103
  Groonga::Schema.create_table("Posts", options) do |table|
126
104
  end
@@ -49,7 +49,7 @@ class SchemaDumperTest < Test::Unit::TestCase
49
49
  def define_index_schema
50
50
  Groonga::Schema.define do |schema|
51
51
  schema.create_table("Items",
52
- :type => :patricia_trie,
52
+ :type => :hash,
53
53
  :key_type => "ShortText") do |table|
54
54
  table.short_text("title")
55
55
  end
@@ -106,7 +106,7 @@ EOS
106
106
  define_index_schema
107
107
  assert_equal(<<-EOS, dump)
108
108
  create_table("Items",
109
- :type => :patricia_trie,
109
+ :type => :hash,
110
110
  :key_type => "ShortText",
111
111
  :force => true) do |table|
112
112
  table.short_text("title")
@@ -163,7 +163,7 @@ EOS
163
163
  def test_index
164
164
  define_index_schema
165
165
  assert_equal(<<-EOS, dump)
166
- table_create Items TABLE_PAT_KEY --key_type ShortText
166
+ table_create Items TABLE_HASH_KEY --key_type ShortText
167
167
  column_create Items title COLUMN_SCALAR ShortText
168
168
 
169
169
  table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rroonga
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 4
10
- version: 1.2.4
9
+ - 5
10
+ version: 1.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kouhei Sutou
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2011-06-29 00:00:00 Z
22
+ date: 2011-08-05 00:00:00 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -143,8 +143,6 @@ files:
143
143
  - benchmark/select.rb
144
144
  - benchmark/write-many-small-items.rb
145
145
  - bin/grndump
146
- - bug.rb
147
- - crash.rb
148
146
  - example/bookmark.rb
149
147
  - example/index-html.rb
150
148
  - ext/groonga/Makefile
@@ -206,52 +204,52 @@ files:
206
204
  - rroonga-build.rb
207
205
  - README.textile
208
206
  - TODO
209
- - test/groonga-test-utils.rb
210
- - test/run-test.rb
207
+ - test/test-remote.rb
208
+ - test/test-table-cursor.rb
211
209
  - test/test-accessor.rb
212
- - test/test-array.rb
213
- - test/test-column.rb
214
- - test/test-context-select.rb
215
- - test/test-context.rb
216
210
  - test/test-database-dumper.rb
217
- - test/test-database.rb
218
- - test/test-encoding.rb
219
- - test/test-exception.rb
220
- - test/test-expression-builder.rb
221
- - test/test-expression.rb
222
- - test/test-fix-size-column.rb
223
- - test/test-gqtp.rb
224
- - test/test-hash.rb
225
211
  - test/test-index-column.rb
226
- - test/test-index-cursor.rb
227
- - test/test-logger.rb
212
+ - test/test-context-select.rb
213
+ - test/groonga-test-utils.rb
228
214
  - test/test-pagination.rb
229
- - test/test-patricia-trie.rb
215
+ - test/test-table.rb
216
+ - test/test-variable-size-column.rb
230
217
  - test/test-plugin.rb
231
- - test/test-procedure.rb
232
- - test/test-query.rb
233
- - test/test-record.rb
234
- - test/test-remote.rb
218
+ - test/test-hash.rb
219
+ - test/test-encoding.rb
235
220
  - test/test-schema-create-table.rb
236
- - test/test-schema-dumper.rb
237
- - test/test-schema-type.rb
238
- - test/test-schema-view.rb
239
- - test/test-schema.rb
240
- - test/test-snippet.rb
241
- - test/test-table-cursor.rb
221
+ - test/test-type.rb
222
+ - test/test-database.rb
223
+ - test/test-variable.rb
224
+ - test/test-table-select.rb
225
+ - test/test-patricia-trie.rb
226
+ - test/test-expression-builder.rb
227
+ - test/test-logger.rb
228
+ - test/test-array.rb
229
+ - test/test-record.rb
230
+ - test/test-column.rb
231
+ - test/test-fix-size-column.rb
232
+ - test/run-test.rb
233
+ - test/test-procedure.rb
242
234
  - test/test-table-dumper.rb
243
- - test/test-table-offset-and-limit.rb
235
+ - test/test-schema.rb
236
+ - test/test-view.rb
244
237
  - test/test-table-select-mecab.rb
245
238
  - test/test-table-select-normalize.rb
246
- - test/test-table-select-weight.rb
247
- - test/test-table-select.rb
248
- - test/test-table.rb
249
- - test/test-type.rb
250
- - test/test-variable-size-column.rb
251
- - test/test-variable.rb
239
+ - test/test-expression.rb
252
240
  - test/test-vector-column.rb
253
241
  - test/test-version.rb
254
- - test/test-view.rb
242
+ - test/test-schema-view.rb
243
+ - test/test-index-cursor.rb
244
+ - test/test-exception.rb
245
+ - test/test-schema-dumper.rb
246
+ - test/test-query.rb
247
+ - test/test-schema-type.rb
248
+ - test/test-table-select-weight.rb
249
+ - test/test-gqtp.rb
250
+ - test/test-context.rb
251
+ - test/test-snippet.rb
252
+ - test/test-table-offset-and-limit.rb
255
253
  homepage: http://groonga.rubyforge.org/
256
254
  licenses:
257
255
  - LGPLv2
@@ -286,49 +284,49 @@ signing_key:
286
284
  specification_version: 3
287
285
  summary: Ruby bindings for groonga that provide full text search and column store features.
288
286
  test_files:
289
- - test/groonga-test-utils.rb
290
- - test/run-test.rb
287
+ - test/test-remote.rb
288
+ - test/test-table-cursor.rb
291
289
  - test/test-accessor.rb
292
- - test/test-array.rb
293
- - test/test-column.rb
294
- - test/test-context-select.rb
295
- - test/test-context.rb
296
290
  - test/test-database-dumper.rb
297
- - test/test-database.rb
298
- - test/test-encoding.rb
299
- - test/test-exception.rb
300
- - test/test-expression-builder.rb
301
- - test/test-expression.rb
302
- - test/test-fix-size-column.rb
303
- - test/test-gqtp.rb
304
- - test/test-hash.rb
305
291
  - test/test-index-column.rb
306
- - test/test-index-cursor.rb
307
- - test/test-logger.rb
292
+ - test/test-context-select.rb
293
+ - test/groonga-test-utils.rb
308
294
  - test/test-pagination.rb
309
- - test/test-patricia-trie.rb
295
+ - test/test-table.rb
296
+ - test/test-variable-size-column.rb
310
297
  - test/test-plugin.rb
311
- - test/test-procedure.rb
312
- - test/test-query.rb
313
- - test/test-record.rb
314
- - test/test-remote.rb
298
+ - test/test-hash.rb
299
+ - test/test-encoding.rb
315
300
  - test/test-schema-create-table.rb
316
- - test/test-schema-dumper.rb
317
- - test/test-schema-type.rb
318
- - test/test-schema-view.rb
319
- - test/test-schema.rb
320
- - test/test-snippet.rb
321
- - test/test-table-cursor.rb
301
+ - test/test-type.rb
302
+ - test/test-database.rb
303
+ - test/test-variable.rb
304
+ - test/test-table-select.rb
305
+ - test/test-patricia-trie.rb
306
+ - test/test-expression-builder.rb
307
+ - test/test-logger.rb
308
+ - test/test-array.rb
309
+ - test/test-record.rb
310
+ - test/test-column.rb
311
+ - test/test-fix-size-column.rb
312
+ - test/run-test.rb
313
+ - test/test-procedure.rb
322
314
  - test/test-table-dumper.rb
323
- - test/test-table-offset-and-limit.rb
315
+ - test/test-schema.rb
316
+ - test/test-view.rb
324
317
  - test/test-table-select-mecab.rb
325
318
  - test/test-table-select-normalize.rb
326
- - test/test-table-select-weight.rb
327
- - test/test-table-select.rb
328
- - test/test-table.rb
329
- - test/test-type.rb
330
- - test/test-variable-size-column.rb
331
- - test/test-variable.rb
319
+ - test/test-expression.rb
332
320
  - test/test-vector-column.rb
333
321
  - test/test-version.rb
334
- - test/test-view.rb
322
+ - test/test-schema-view.rb
323
+ - test/test-index-cursor.rb
324
+ - test/test-exception.rb
325
+ - test/test-schema-dumper.rb
326
+ - test/test-query.rb
327
+ - test/test-schema-type.rb
328
+ - test/test-table-select-weight.rb
329
+ - test/test-gqtp.rb
330
+ - test/test-context.rb
331
+ - test/test-snippet.rb
332
+ - test/test-table-offset-and-limit.rb
data/bug.rb DELETED
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'fileutils'
4
- require 'groonga'
5
-
6
- Groonga::Logger.log_path = "/tmp/groonga.log"
7
- Groonga::Logger.query_log_path = "/tmp/groonga-query.log"
8
-
9
- i = 0
10
- loop do
11
- path = "/tmp/db/db"
12
- FileUtils.rm_rf(File.dirname(path))
13
- FileUtils.mkdir_p(File.dirname(path))
14
- Groonga::Context.default = nil
15
- database = Groonga::Database.create(:path => path)
16
- Groonga::Schema.define do |schema|
17
- schema.create_table("Users",
18
- :type => :hash,
19
- :key_type => "ShortText") do |table|
20
- table.uint32("name_length")
21
- end
22
- end
23
-
24
- users = Groonga["Users"]
25
- 10.times do
26
- i += 1
27
- exit if i > 100
28
- name = i.to_s
29
- users.add(name, :name_length => name.length)
30
- end
31
- builder = Groonga::RecordExpressionBuilder.new(users, nil)
32
- builder.query = "name_length:3"
33
- builder.build
34
- database.close
35
- GC.start
36
- end
data/crash.rb DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'groonga'
4
-
5
- context = Groonga::Context.default
6
- context.connect(:port => 10042)
7
-
8
- 10000.times do |i|
9
- p i
10
- GC.stress = true
11
- result = context.select("Program")
12
- result.records.each do |record|
13
- record["_key"]
14
- record["unknown"]
15
- end
16
- GC.stress = false
17
- end