projects
/
chise
/
ruby.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update.
[chise/ruby.git]
/
chise
/
chisedb.rb
diff --git
a/chise/chisedb.rb
b/chise/chisedb.rb
index
a858e8e
..
7d7715e
100755
(executable)
--- a/
chise/chisedb.rb
+++ b/
chise/chisedb.rb
@@
-18,18
+18,26
@@
module CHISE
def initialize
@location = CHISE::DataSource::DB_DIR.path
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
@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
def close
# @ds.close if @ds # do not close for now
+ # @ds = nil
end
def each_feature_name()
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/
@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
end
def each_ccs
+# setup_ds
each_entry("character/by_feature") {|f| yield(f) }
end
def get_feature(name)
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)
@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)
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)
@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)
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
@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
module TableManagementModule
def to_hash
+ sync # add.
h = {}
each_char {|k, v| h[k] = v }
h
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
}
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)
alias close sync
def set_value(cid, value)