Class: XRBP::NodeStore::Backends::RocksDB
- Defined in:
- lib/xrbp/nodestore/backends/rocksdb.rb
Overview
RocksDB nodestore backend, faciliates accessing XRP Ledger data in a RocksDB database.
Constant Summary collapse
- MAX_OPEN_FILES =
cap max open files for performance
2000
Instance Method Summary collapse
-
#[](key) ⇒ String
Retrieve database value for the specified key.
-
#each ⇒ Object
Iterate over each database key/value pair, invoking callback.
-
#initialize(path) ⇒ RocksDB
constructor
A new instance of RocksDB.
Methods inherited from DB
#account, #inner_node, #ledger, #ledger_entry, #tx
Constructor Details
#initialize(path) ⇒ RocksDB
Returns a new instance of RocksDB.
18 19 20 21 22 |
# File 'lib/xrbp/nodestore/backends/rocksdb.rb', line 18 def initialize(path) @db = ::RocksDB::DB.new path, {:readonly => true, :max_open_files => MAX_OPEN_FILES} end |
Instance Method Details
#[](key) ⇒ String
Retrieve database value for the specified key
28 29 30 |
# File 'lib/xrbp/nodestore/backends/rocksdb.rb', line 28 def [](key) @db[key] end |
#each ⇒ Object
Iterate over each database key/value pair, invoking callback. During iteration will emit signals specific to the DB types being parsed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/xrbp/nodestore/backends/rocksdb.rb', line 51 def each iterator = @db.new_iterator iterator.seek_to_first while(iterator.valid) type, obj = infer_type(iterator.value) if type emit type, iterator.key, obj else emit :unknown, iterator.key, iterator.value end yield iterator iterator.next end iterator.close return self end |