Class: FDB::Transaction
Instance Attribute Summary collapse
#db, #tpointer
Instance Method Summary
collapse
finalize, #get, #get_estimated_range_size_bytes, #get_key, #get_range, #get_range_split_points, #get_range_start_with, #get_read_version, #transact
Constructor Details
#initialize(tpointer, db) ⇒ Transaction
Returns a new instance of Transaction.
867
868
869
870
871
872
873
874
875
876
|
# File 'lib/fdbimpl.rb', line 867
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.
865
866
867
|
# File 'lib/fdbimpl.rb', line 865
def options
@options
end
|
#snapshot ⇒ Object
Returns the value of attribute snapshot.
865
866
867
|
# File 'lib/fdbimpl.rb', line 865
def snapshot
@snapshot
end
|
Instance Method Details
#add_read_conflict_key(key) ⇒ Object
891
892
893
894
|
# File 'lib/fdbimpl.rb', line 891
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
885
886
887
888
889
|
# File 'lib/fdbimpl.rb', line 885
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
902
903
904
905
|
# File 'lib/fdbimpl.rb', line 902
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
896
897
898
899
900
|
# File 'lib/fdbimpl.rb', line 896
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
960
961
962
|
# File 'lib/fdbimpl.rb', line 960
def cancel
FDBC.fdb_transaction_cancel @tpointer
end
|
#clear(key) ⇒ Object
921
922
923
924
|
# File 'lib/fdbimpl.rb', line 921
def clear(key)
key = FDB.key_to_bytes(key)
FDBC.fdb_transaction_clear(@tpointer, key, key.bytesize)
end
|
#clear_range(bkey, ekey) ⇒ Object
926
927
928
929
930
|
# File 'lib/fdbimpl.rb', line 926
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
932
933
934
935
936
|
# File 'lib/fdbimpl.rb', line 932
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
907
908
909
|
# File 'lib/fdbimpl.rb', line 907
def commit
FutureNil.new(FDBC.fdb_transaction_commit(@tpointer))
end
|
#get_approximate_size ⇒ Object
948
949
950
|
# File 'lib/fdbimpl.rb', line 948
def get_approximate_size
Int64Future.new(FDBC.fdb_transaction_get_approximate_size @tpointer)
end
|
#get_committed_version ⇒ Object
942
943
944
945
946
|
# File 'lib/fdbimpl.rb', line 942
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
952
953
954
|
# File 'lib/fdbimpl.rb', line 952
def get_versionstamp
Key.new(FDBC.fdb_transaction_get_versionstamp(@tpointer))
end
|
#on_error(e) ⇒ Object
916
917
918
919
|
# File 'lib/fdbimpl.rb', line 916
def on_error(e)
raise e if !e.kind_of? Error
FutureNil.new(FDBC.fdb_transaction_on_error(@tpointer, e.code))
end
|
#reset ⇒ Object
956
957
958
|
# File 'lib/fdbimpl.rb', line 956
def reset
FDBC.fdb_transaction_reset @tpointer
end
|
#set(key, value) ⇒ Object
Also known as:
[]=
878
879
880
881
882
|
# File 'lib/fdbimpl.rb', line 878
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
938
939
940
|
# File 'lib/fdbimpl.rb', line 938
def set_read_version(version)
FDBC.fdb_transaction_set_read_version(@tpointer, version)
end
|
#watch(key) ⇒ Object
911
912
913
914
|
# File 'lib/fdbimpl.rb', line 911
def watch(key)
key = FDB.key_to_bytes(key)
FutureNil.new(FDBC.fdb_transaction_watch(@tpointer, key, key.bytesize))
end
|