X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fruby.git;a=blobdiff_plain;f=chise%2Fchisedb.rb;fp=chise%2Fchisedb.rb;h=7d7715e7d2b9d93ba531081b74cae0251030bc20;hp=a858e8ee59fcff5ed1b9c0c7759167644b9ad2a1;hb=fc94a49ca7fffa51475bcccf26b328a3b92f3758;hpb=5f691f77eafbb6df3012966d053e9d8b39c6a3ff diff --git a/chise/chisedb.rb b/chise/chisedb.rb index a858e8e..7d7715e 100755 --- a/chise/chisedb.rb +++ b/chise/chisedb.rb @@ -18,18 +18,26 @@ module CHISE def initialize @location = CHISE::DataSource::DB_DIR.path - @ds = DataSource.new(CHISE::DataSource::Berkeley_DB, @location.to_s, 0, 0755) + @ds = nil + setup_ds @feature_db = {} @ccs_db = {} @byids_db = {} end attr_reader :ds, :location + def setup_ds + return if @ds + @ds = DataSource.new(CHISE::DataSource::Berkeley_DB, @location.to_s, 0, 0755) + end + def close # @ds.close if @ds # do not close for now + # @ds = nil end def each_feature_name() +# setup_ds @ds.each_feature_name {|f| next if f.to_s == "." || f.to_s == ".." next if f.to_s =~ /\.txt\Z/ @@ -38,30 +46,36 @@ module CHISE end def each_ccs +# setup_ds each_entry("character/by_feature") {|f| yield(f) } end def get_feature(name) +# setup_ds @feature_db[name] = FeatureDB.new(self, name) if @feature_db[name].nil? @feature_db[name] end def load_feature(cid, name) +# setup_ds feature = get_feature(name) feature.get_value(cid) end def get_ccs(name) +# setup_ds @ccs_db[name] = CCS_DB.new(self, name) if @ccs_db[name].nil? @ccs_db[name] end def decode_char(ccs, code_point) +# setup_ds ccsdb = get_ccs(ccs) ccsdb.decode(code_point) end def get_by_ids_db(n) +# setup_ds @byids_db[n] = ByIDS_DB.new(self, n) if @byids_db[n].nil? @byids_db[n] end @@ -72,6 +86,7 @@ module CHISE module TableManagementModule def to_hash + sync # add. h = {} each_char {|k, v| h[k] = v } h @@ -102,7 +117,10 @@ module CHISE } end def setup_db(w) @feature.setup_db(w); end - def sync() @feature.sync(); end + def sync + #qp "sync" + @feature.sync + end alias close sync def set_value(cid, value)