Class: FDB::Transaction
Instance Attribute Summary collapse
#db, #tpointer
Instance Method Summary
collapse
finalize, #get, #get_key, #get_range, #get_range_start_with, #get_read_version, #transact
Constructor Details
#initialize(tpointer, db) ⇒ Transaction
Returns a new instance of Transaction.
863
864
865
866
867
868
869
870
871
872
|
# File 'lib/fdbimpl.rb', line 863
def initialize(tpointer, db)
super(tpointer, db, 0)
@snapshot = TransactionRead.new(tpointer, db, 1)
@options = TransactionOptions.new lambda { |code, param|
FDBC.check_error FDBC.fdb_transaction_set_option(@tpointer, code, param, param.nil? ? 0 : param.bytesize)
}
ObjectSpace.undefine_finalizer self
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
861
862
863
|
# File 'lib/fdbimpl.rb', line 861
def options
@options
end
|
#snapshot ⇒ Object
Returns the value of attribute snapshot.
861
862
863
|
# File 'lib/fdbimpl.rb', line 861
def snapshot
@snapshot
end
|
Instance Method Details
#add_read_conflict_key(key) ⇒ Object
887
888
889
890
|
# File 'lib/fdbimpl.rb', line 887
def add_read_conflict_key(key)
key = FDB.key_to_bytes(key)
add_read_conflict_range(key, key + "\x00")
end
|
#add_read_conflict_range(bkey, ekey) ⇒ Object
881
882
883
884
885
|
# File 'lib/fdbimpl.rb', line 881
def add_read_conflict_range(bkey, ekey)
bkey = FDB.key_to_bytes(bkey)
ekey = FDB.key_to_bytes(ekey)
FDBC.check_error FDBC.fdb_transaction_add_conflict_range(@tpointer, bkey, bkey.bytesize, ekey, ekey.bytesize, @@ConflictRangeType["READ"][0])
end
|
#add_write_conflict_key(key) ⇒ Object
898
899
900
901
|
# File 'lib/fdbimpl.rb', line 898
def add_write_conflict_key(key)
key = FDB.key_to_bytes(key)
add_write_conflict_range(key, key + "\x00")
end
|
#add_write_conflict_range(bkey, ekey) ⇒ Object
892
893
894
895
896
|
# File 'lib/fdbimpl.rb', line 892
def add_write_conflict_range(bkey, ekey)
bkey = FDB.key_to_bytes(bkey)
ekey = FDB.key_to_bytes(ekey)
FDBC.check_error FDBC.fdb_transaction_add_conflict_range(@tpointer, bkey, bkey.bytesize, ekey, ekey.bytesize, @@ConflictRangeType["WRITE"][0])
end
|
#cancel ⇒ Object
952
953
954
|
# File 'lib/fdbimpl.rb', line 952
def cancel
FDBC.fdb_transaction_cancel @tpointer
end
|
#clear(key) ⇒ Object
917
918
919
920
|
# File 'lib/fdbimpl.rb', line 917
def clear(key)
key = FDB.key_to_bytes(key)
FDBC.fdb_transaction_clear(@tpointer, key, key.bytesize)
end
|
#clear_range(bkey, ekey) ⇒ Object
922
923
924
925
926
|
# File 'lib/fdbimpl.rb', line 922
def clear_range(bkey, ekey)
bkey = FDB.key_to_bytes(bkey)
ekey = FDB.key_to_bytes(ekey)
FDBC.fdb_transaction_clear_range(@tpointer, bkey || "", bkey && bkey.bytesize || 0, ekey || "", ekey && ekey.bytesize || 0)
end
|
#clear_range_start_with(prefix) ⇒ Object
928
929
930
931
932
|
# File 'lib/fdbimpl.rb', line 928
def clear_range_start_with(prefix)
prefix = FDB.key_to_bytes(prefix)
prefix = prefix.dup.force_encoding "BINARY"
clear_range(prefix, FDB.strinc(prefix))
end
|
#commit ⇒ Object
903
904
905
|
# File 'lib/fdbimpl.rb', line 903
def commit
FutureNil.new(FDBC.fdb_transaction_commit(@tpointer))
end
|
#get_committed_version ⇒ Object
938
939
940
941
942
|
# File 'lib/fdbimpl.rb', line 938
def get_committed_version
version = FFI::MemoryPointer.new :int64
FDBC.check_error FDBC.fdb_transaction_get_committed_version(@tpointer, version)
version.read_long_long
end
|
#get_versionstamp ⇒ Object
944
945
946
|
# File 'lib/fdbimpl.rb', line 944
def get_versionstamp
Key.new(FDBC.fdb_transaction_get_versionstamp(@tpointer))
end
|
#on_error(e) ⇒ Object
912
913
914
915
|
# File 'lib/fdbimpl.rb', line 912
def on_error(e)
raise e if !e.kind_of? Error
FutureNil.new(FDBC.fdb_transaction_on_error(@tpointer, e.code))
end
|
#reset ⇒ Object
948
949
950
|
# File 'lib/fdbimpl.rb', line 948
def reset
FDBC.fdb_transaction_reset @tpointer
end
|
#set(key, value) ⇒ Object
Also known as:
[]=
874
875
876
877
878
|
# File 'lib/fdbimpl.rb', line 874
def set(key, value)
key = FDB.key_to_bytes(key)
value = FDB.value_to_bytes(value)
FDBC.fdb_transaction_set(@tpointer, key, key.bytesize, value, value.bytesize)
end
|
#set_read_version(version) ⇒ Object
934
935
936
|
# File 'lib/fdbimpl.rb', line 934
def set_read_version(version)
FDBC.fdb_transaction_set_read_version(@tpointer, version)
end
|
#watch(key) ⇒ Object
907
908
909
910
|
# File 'lib/fdbimpl.rb', line 907
def watch(key)
key = FDB.key_to_bytes(key)
FutureNil.new(FDBC.fdb_transaction_watch(@tpointer, key, key.bytesize))
end
|