<< | Index | >>
suspend
Change log
Experiment
def migrate_to_utf8 ODBA.cache.retire_age = 5 ODBA.cache.cleaner_step = 100000child = @system.instance_variable_get('@doctors')
p child.class
exit
Run
ruby193 -I ../oddb/lib bin/oddbd
ch.oddb> migrate_to_utf8
Result
failsafe rescued RuntimeError < StandardError can't add a new key into hash during iteration /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1474:in `instance_eval' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:325:in `block (3 levels) in fetch_or_restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `call' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `fetch_or_do' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:320:in `block (2 levels) in fetch_or_restore' <internal:prelude>:10:in `synchronize' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:319:in `block in fetch_or_restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `call' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `fetch_or_do' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:317:in `fetch_or_restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:64:in `block in bulk_restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:61:in `each' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:61:in `bulk_restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:55:in `bulk_fetch' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:260:in `fetch_collection' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:597:in `restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:318:in `block in fetch_or_restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `call' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `fetch_or_do' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:317:in `fetch_or_restore' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:605:in `restore_object' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:570:in `load_object' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:226:in `block in fetch' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `call' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:313:in `fetch_or_do' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/cache.rb:225:in `fetch' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/stub.rb:49:in `odba_receiver' /home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/stub.rb:17:in `class' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1788:in `migrate_to_utf8' (eval):1:in `block (2 levels) in _admin' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1474:in `instance_eval' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1474:in `block (2 levels) in _admin' /home/masa/ywesee/oddb.org.ruby193/src/util/failsafe.rb:9:in `call' /home/masa/ywesee/oddb.org.ruby193/src/util/failsafe.rb:9:in `failsafe' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1473:in `block in _admin'
Experiment
def migrate_to_utf8 ODBA.cache.retire_age = 5child = @system.instance_variable_get('@doctors')
p child.class
exit
ODBA.cache.cleaner_step = 100000
Result
Hash
Note
ODBA.cache.cleaner_step
does something
Experiment
def migrate_to_utf8 ...#ODBA.cache.cleaner_step = 100000
def _migrate_child_to_utf8 child, queue, table, iconv, opts={} #child = iconv.iconv(child)child.force_encoding('utf-8')
Run
ruby193 -I ../oddb/lib bin/oddbd
ch.oddb> migrate_to_utf8
Note
Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) when updating index 'fachinfo_index_de' with a ODDB::Fachinfo ["/home/masa/ywesee/oddb.org.ruby193/src/util/searchterms.rb:79:in `gsub'", "/home/masa/ywesee/oddb.org.ruby193/src/util/searchterms.rb:79:in `search_term'", "/home/masa/ywesee/oddb.org.ruby193/src/model/fachinfo.rb:69:in `search_text'", "(eval):3:in `block in proc_resolve_search_term'"] [...] Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) when updating index 'fachinfo_index_fr' with a ODDB::Fachinfo ["/home/masa/ywesee/oddb.org.ruby193/src/util/searchterms.rb:79:in `gsub'", "/home/masa/ywesee/oddb.org.ruby193/src/util/searchterms.rb:79:in `search_term'", "/home/masa/ywesee/oddb.org.ruby193/src/model/fachinfo.rb:69:in `search_text'", "(eval):3:in `block in proc_resolve_search_term'"] [...]
ODBA::Stub was unable to replace ODDB::SimpleLanguage::Descriptions#27473952 from ODDB::AtcClass:#13744 ODBA::Stub was unable to replace Hash#27501234 from ODDB::CommercialForm:#1067691 ODBA::Stub was unable to replace ODDB::SimpleLanguage::Descriptions#27501236 from ODDB::CommercialForm:#1067691 ODBA::Stub was unable to replace Array#27501235 from ODDB::CommercialForm:#1067691
saved: 295664 failsafe rescued NoMethodError < StandardError undefined method `odba_store' for nil:NilClass /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1474:in `instance_eval' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1821:in `_migrate_to_utf8' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1802:in `migrate_to_utf8' (eval):1:in `block (2 levels) in _admin' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1474:in `instance_eval' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1474:in `block (2 levels) in _admin' /home/masa/ywesee/oddb.org.ruby193/src/util/failsafe.rb:9:in `call' /home/masa/ywesee/oddb.org.ruby193/src/util/failsafe.rb:9:in `failsafe' /home/masa/ywesee/oddb.org.ruby193/src/util/oddbapp.rb:1473:in `block in _admin'
if obj @count ||= 0 obj.odba_store unless obj.odba_unsaved? print "saved: ", @count+=1, "\n" end
class NilClass def odba_store end end
def migrate_to_utf8@migrate_mutex = Mutex.new
... def _migrate_to_utf8 queue, table, iconv, opts={} ...@migrate_mutex.synchronize {
if obj @count ||= 0 obj.odba_store unless obj.odba_unsaved? print "saved: ", @count+=1, "\n" end}
Result
.... saved: 2484074
Note
def ODDB.search_term(term)term.force_encoding('UTF-8')
def ODDB.search_terms(words, opts={}) terms = [] words.flatten.compact.uniq.inject(terms) { |terms, term| if(opts[:downcase]) term = term.downcase endterm.force_encoding('UTF-8')
parts = term.split(/[\/-]/u)
#!/usr/bin/env ruby# utf-8
... def city@location.force_encoding('utf-8')
Question
Refer to testcases
Experiment (Check directly the instance that causes Stub error)
ch.oddb> ODBA.cache.fetch('13744').description.encoding -> US-ASCII ch.oddb> ODBA.cache.fetch('13744').description.force_encoding('utf-8') -> ch.oddb> ODBA.cache.fetch('13744').description.encoding -> US-ASCII ch.oddb> ODBA.cache.fetch('13744').description.length -> 0
# encoding: utf-8
Reboot oddbd
bin/admin
ch.oddb> ODBA.cache.fetch('13744').description.encoding -> UTF-8
Note
class Descriptions < Hash def first if empty? '' else sort.first.last end end end def description(key=nil) descriptions[key.to_s] || descriptions.first end def descriptions @descriptions ||= Descriptions.new end
Next