Class: LevelDB::Batch
- Inherits:
-
Object
- Object
- LevelDB::Batch
- Defined in:
- lib/leveldb/batch.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #[]=(key, val) ⇒ Object (also: #put)
- #delete(key) ⇒ Object
- #error_message ⇒ Object (also: #clear_errors!)
- #errors? ⇒ Boolean
-
#initialize(db, write_opts) ⇒ Batch
constructor
A new instance of Batch.
- #inspect ⇒ Object (also: #to_s)
-
#write! ⇒ Object
true end alias clear! clear.
Constructor Details
Instance Method Details
#[]=(key, val) ⇒ Object Also known as: put
14 15 16 17 18 19 |
# File 'lib/leveldb/batch.rb', line 14 def []=(key, val) key, val = key.to_s, val.to_s C.writebatch_put(@_batch, key, key.size, val, val.size) val end |
#delete(key) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/leveldb/batch.rb', line 22 def delete(key) key = key.to_s C.writebatch_delete(@_batch, key, key.size) key end |
#error_message ⇒ Object Also known as: clear_errors!
49 50 51 52 53 54 55 56 57 |
# File 'lib/leveldb/batch.rb', line 49 def return unless errors? @_err.ptr.to_s ensure if errors? @_err = C::Pointer.malloc(C::SIZEOF_VOIDP) @_err.free = C[:free] end end |
#errors? ⇒ Boolean
44 45 46 47 |
# File 'lib/leveldb/batch.rb', line 44 def errors? return unless @_err !@_err.ptr.null? end |
#inspect ⇒ Object Also known as: to_s
60 61 62 |
# File 'lib/leveldb/batch.rb', line 60 def inspect "#<LevelDB::Batch:#{'0x%x' % object_id}>" end |