Class: LdbEngin
- Inherits:
-
Object
- Object
- LdbEngin
- Defined in:
- lib/ldb_engin.rb
Instance Method Summary collapse
- #dump(rowcount, keybyte, valuebyte) ⇒ Object
-
#initialize(dbdir) ⇒ LdbEngin
constructor
A new instance of LdbEngin.
Constructor Details
#initialize(dbdir) ⇒ LdbEngin
Returns a new instance of LdbEngin.
6 7 8 |
# File 'lib/ldb_engin.rb', line 6 def initialize(dbdir) @db = LevelDB::DB.new dbdir end |
Instance Method Details
#dump(rowcount, keybyte, valuebyte) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ldb_engin.rb', line 10 def dump(rowcount, keybyte, valuebyte) raise "keybyte(#{keybyte}) is too small for #{rowcount} rows." if rowcount.to_s.length > keybyte puts "dump level-db with #{rowcount} rows. key = #{keybyte} bytes, value = #{valuebyte} bytes." tstart = Time.new (0..rowcount).each do |id| key = id.to_s.rjust(keybyte, '0') value = id.to_s.rjust(valuebyte, '-') @db[key] = value end puts "dump finished. #{Time.new - tstart} seconds elapsed." end |