Class FDBRecordContext
- java.lang.Object
-
- com.apple.foundationdb.record.provider.foundationdb.FDBTransactionContext
-
- com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext
-
- All Implemented Interfaces:
AutoCloseable
@API(STABLE) public class FDBRecordContext extends FDBTransactionContext implements AutoCloseable
An open transaction against FDB.All reads and writes to the database are transactional: an open
FDBRecordContext
is needed. AnFDBDatabase
is needed to open anFDBRecordContext
.final FDBDatabase fdb = FDBDatabaseFactory.instance().getDatabase(); try (FDBRecordContext ctx = fdb.openContext()) { ... }
- See Also:
FDBRecordStore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FDBRecordContext.AfterCommit
A hook to run after commit has completed successfully.static interface
FDBRecordContext.CommitCheck
A synchronousFDBRecordContext.CommitCheckAsync
.static interface
FDBRecordContext.CommitCheckAsync
A consistency check, such as uniqueness, that can execute asynchronously and is finally checked at or before commit time.static interface
FDBRecordContext.PostCommit
A supplier of a future to be executed after the transaction has been successfully committed.
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_TR_ID_SIZE
The maximum size for a transaction ID in bytes when serialized as UTF-8.-
Fields inherited from class com.apple.foundationdb.record.provider.foundationdb.FDBTransactionContext
database, timer, transaction
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FDBRecordContext(FDBDatabase fdb, Transaction transaction, FDBRecordContextConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAfterCommit(FDBRecordContext.AfterCommit afterCommit)
Adds code to be executed immediately following a successful commit.void
addCommitCheck(FDBRecordContext.CommitCheckAsync check)
Add aFDBRecordContext.CommitCheckAsync
to be performed beforecommit()
finishes.void
addCommitCheck(CompletableFuture<Void> check)
Add a check to be completed beforecommit()
finishes.void
addPostCommit(FDBRecordContext.PostCommit postCommit)
Install an anonymous post-commit hook.void
addPostCommit(String name, FDBRecordContext.PostCommit postCommit)
Adds a new post-commit hook.byte[]
addVersionMutation(byte[] key, byte[] value)
Deprecated.use #addVersionMutation(MutationType, byte[], byte[]) insteadbyte[]
addVersionMutation(MutationType mutationType, byte[] key, byte[] value)
Add aSET_VERSIONSTAMPED_KEY
orSET_VERSIONTSTAMPED_VALUE
mutation to be run at commit time.<T> T
asyncToSync(StoreTimer.Wait event, CompletableFuture<T> async)
int
claimLocalVersion()
Claims a local version that is unique within a single transaction.void
close()
void
commit()
Commit an open transaction.CompletableFuture<Void>
commitAsync()
Async version ofcommit()
.Transaction
ensureActive()
<T> T
get(CompletableFuture<T> future)
Get a future following the same logic thatasyncToSync()
uses to validate that the operation isn't blocking in an asynchronous context.long
getCommittedVersion()
Return the eight byte version assigned to this context at commit time.Map<String,String>
getMdcContext()
byte[]
getMetaDataVersionStamp(IsolationLevel isolationLevel)
A blocking version ofgetMetaDataVersionStampAsync(IsolationLevel)
.CompletableFuture<byte[]>
getMetaDataVersionStampAsync(IsolationLevel isolationLevel)
Get the database's meta-data version-stamp.FDBRecordContext.PostCommit
getOrCreatePostCommit(String name, Function<String,FDBRecordContext.PostCommit> ifNotExists)
Fetches a post-commit hook, creating a new one if it does not already exist.FDBRecordContext.PostCommit
getPostCommit(String name)
Fetches a previously installed post-commit hook.FDBTransactionPriority
getPriority()
Get the priority of this transaction.long
getReadVersion()
Get the read version used by this transaction.CompletableFuture<Long>
getReadVersionAsync()
Get the read version used by this transaction.long
getTimeoutMillis()
Get the timeout time for the underlying transaction.long
getTrackOpenTimeNanos()
Get the nanosecond time at which this context was opened.long
getTransactionAge()
Get the number of milliseconds since context was created.long
getTransactionCreateTime()
String
getTransactionId()
Get the ID used by FoundationDB to track this transaction.byte[]
getVersionStamp()
Return the ten byte version-stamp assigned to this context at commit time.FDBDatabase.WeakReadSemantics
getWeakReadSemantics()
boolean
hasDirtyStoreState()
Return whether any record store opened with this context has had its cache-able store state modified.boolean
hasHookForAsyncToSync()
boolean
hasReadVersion()
Get whether this transaction's read version has already been set.boolean
isClosed()
boolean
isLogged()
Get whether the current transaction details are logged to the client trace logs.<T> T
join(CompletableFuture<T> future)
Join a future following the same logic thatasyncToSync()
uses to validate that the operation isn't blocking in an asynchronous context.<T> T
joinNow(CompletableFuture<T> future)
Join a future but validate that the future is already completed.void
logTransaction()
Write the details of this transaction to the FoundationDB client logs.FDBDatabaseRunner
newRunner()
Get a newFDBDatabaseRunner
that will run contexts similar to this one.ReadTransaction
readTransaction(boolean snapshot)
FDBRecordContext.PostCommit
removePostCommit(String name)
Remove a previously installed post-commit hook.byte[]
removeVersionMutation(byte[] key)
Remove aSET_VERSIONSTAMPED_KEY
mutation that would have been run at commit time.void
runAfterCommits()
Deprecated.this method probably should never have been publicCompletableFuture<Void>
runCommitChecks()
Run anyFDBRecordContext.CommitCheckAsync
s that are still outstanding.void
setDirtyStoreState(boolean dirtyStoreState)
void
setHookForAsyncToSync(Consumer<StoreTimer.Wait> hook)
void
setMetaDataVersionStamp()
Update the meta-data version-stamp.long
setReadVersion(long readVersion)
Set the read version used by this transaction.void
timeReadSampleKey(byte[] key)
byte[]
updateVersionMutation(MutationType mutationType, byte[] key, byte[] value, BiFunction<byte[],byte[],byte[]> remappingFunction)
-
Methods inherited from class com.apple.foundationdb.record.provider.foundationdb.FDBTransactionContext
getApproximateTransactionSize, getDatabase, getExecutor, getTimer, increment, increment, instrument, instrument, instrument, instrument, record, record, setTimer
-
-
-
-
Field Detail
-
MAX_TR_ID_SIZE
public static final int MAX_TR_ID_SIZE
The maximum size for a transaction ID in bytes when serialized as UTF-8. This value is used to determine whether the transaction ID provided inFDBDatabase.openContext(Map, FDBStoreTimer, FDBDatabase.WeakReadSemantics, FDBTransactionPriority, String)
should be truncated or dropped. Note that JavaString
s are encoded using UTF-16, so usingString.length()
is insufficient to know if the transaction ID will be too large if it contains any non-ASCII characters (though it is recommended that all transaction IDs be printable ASCII characters as those are the ones that render well in the logs). To get the size in UTF-8, one can serialize the string to UTF-8 usingString.getBytes(Charset)
or check its encoded size usingUtf8.encodedLength(CharSequence)
or an equivalent function.Note that this limit is inherited by the Record Layer from the FoundationDB client. In particular, the
TransactionOptions.setDebugTransactionIdentifier(String)
method will not accept IDs longer than 100 bytes in length.
-
-
Constructor Detail
-
FDBRecordContext
protected FDBRecordContext(@Nonnull FDBDatabase fdb, @Nonnull Transaction transaction, @Nonnull FDBRecordContextConfig config)
-
-
Method Detail
-
getTransactionId
@Nullable public String getTransactionId()
Get the ID used by FoundationDB to track this transaction. This can be used as a correlation key to correlate requests with their transactions. If this returnsnull
, then no ID has been set. This means that it is unsafe to calllogTransaction()
on this context if this method returnsnull
.This ID is used by FoundationDB internally in a few different places, including the transaction sample, large transaction monitoring, and client trace logs if transaction logging is enabled for that transaction. If the caller already has a notion of "request ID", then one strategy might be to set the transaction's ID to the initiating request's ID so that one can correlate requests and transactions.
The transaction ID is limited in size to 100 bytes when encoded as UTF-8. In general, most callers should limit IDs to printable ASCII characters (as those are the only characters that are easily readable in the client trace logs). If the provided ID exceeds 100 bytes, it will be truncated or possibly ignored if truncating the ID cannot be done safely.
To set this ID, the user can call either
FDBDatabase.openContext(Map, FDBStoreTimer, FDBDatabase.WeakReadSemantics, FDBTransactionPriority, String)
and provided a non-null
transaction ID as a parameter, or the user can callFDBDatabase.openContext(Map, FDBStoreTimer)
orFDBDatabase.openContext(Map, FDBStoreTimer, FDBDatabase.WeakReadSemantics)
and set the "uuid" key to the desired transaction ID in the MDC context. In either case, note that the transaction ID is limited in size to 100 bytes when encoded in UTF-8. In general, most callers should limit IDs to printable ASCII characters (as those are the only characters that are easily readable in the client trace logs). If the provided ID exceeds 100 bytes, it will be truncated or possibly ignored if truncating the ID cannot be done safely.- Returns:
- the ID used by FoundationDB to track this transaction or
null
if not set - See Also:
logTransaction()
-
getTimeoutMillis
public long getTimeoutMillis()
Get the timeout time for the underlying transaction. The value returned here is whatever timeout is actually set for this transaction, if one is set through the context's constructor. This can be from either anFDBDatabaseFactory
, anFDBDatabaseRunner
, or anFDBRecordContextConfig
. If this returnsFDBDatabaseFactory.DEFAULT_TR_TIMEOUT_MILLIS
, then this indicates that the transaction was set using the default system timeout, which is configured withDatabaseOptions.setTransactionTimeout(long)
. As those options can not be inspected through FoundationDB Java bindings, this method cannot return an accurate result. Likewise, if a user explicitly sets the underlying option usingTransactionOptions.setTimeout(long)
, then this method will not return an accurate result.- Returns:
- the timeout configured for this transaction at its initialization
- See Also:
FDBDatabaseFactory.setTransactionTimeoutMillis(long)
,FDBDatabaseRunner.setTransactionTimeoutMillis(long)
,FDBRecordContextConfig.Builder.setTransactionTimeoutMillis(long)
,FDBExceptions.FDBStoreTransactionTimeoutException
-
logTransaction
public final void logTransaction()
Write the details of this transaction to the FoundationDB client logs. Note that this operation does not do anything if the client has not been configured to emit logs. This should only really be used for debugging purposes, as the messages that are logged here can be rather verbose, and they include all read and written keys and values.All of the transaction's entries will be tagged with this transaction's ID. If an ID has not been set, this method will throw a
NOTE: It is generally better to enable logging at open time via theRecordCoreException
. As a result, the user is encouraged to callgetTransactionId()
before calling this method.FDBRecordContextConfig
.
-
isLogged
public boolean isLogged()
Get whether the current transaction details are logged to the client trace logs. Essentially, this returns if the transaction has been traced or if the user has (successfully) calledlogTransaction()
. SeelogTransaction()
for more details.- Returns:
- whether this transaction is logged to the client trace logs
- See Also:
logTransaction()
-
getTrackOpenTimeNanos
@API(INTERNAL) public long getTrackOpenTimeNanos()
Get the nanosecond time at which this context was opened.- Returns:
- time opened
-
isClosed
public boolean isClosed()
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
commit
public void commit()
Commit an open transaction.
-
commitAsync
public CompletableFuture<Void> commitAsync()
Async version ofcommit()
.- Returns:
- a future that is complete when commit is done
-
ensureActive
@Nonnull public Transaction ensureActive()
- Overrides:
ensureActive
in classFDBTransactionContext
-
setReadVersion
public long setReadVersion(long readVersion)
Set the read version used by this transaction. All reads to the database will include only changes that were committed at this version or smaller. A transaction's read version can only be set once, so if this function is called multiple times, it will return the previously set read version. If this method is called and another caller has already calledgetReadVersionAsync()
orgetReadVersion()
, this method may throw aRecordCoreException
indicating that there is already an outstanding read version request if that request has not yet completed.- Parameters:
readVersion
- the read version this transaction should use if is not already set- Returns:
- this transaction's read version
- See Also:
ReadTransaction.setReadVersion(long)
-
getReadVersionAsync
@Nonnull public CompletableFuture<Long> getReadVersionAsync()
Get the read version used by this transaction. All reads to the database will include only changes that were committed at this version or smaller. If the read version has not already been set or gotten, this may require talking to the database. If the read version has already been set or gotten, then this will return with an already completed future.Note that this method is
synchronized
, but only creating the future (not waiting on the future) will block other threads. Thus, while it is advised that this method only be called once and by only one caller at a time, if it safe to use this method in asynchronous contexts. If this method is called multiple times, then the same future will be returned each time.- Returns:
- a future that will contain the read version of this transaction
- See Also:
ReadTransaction.getReadVersion()
-
getReadVersion
public long getReadVersion()
Get the read version used by this transaction. This is a synchronous version ofgetReadVersionAsync()
. Note that if the read version has already been set or gotten (either by callingsetReadVersion(long)
orgetReadVersionAsync()
or this method), then the previously set read version is returned immediately, and this method will not block. One can check if the read version has already been set by callinghasReadVersion()
.- Returns:
- the read version of this transaction
- See Also:
getReadVersionAsync()
,ReadTransaction.getReadVersion()
-
hasReadVersion
public boolean hasReadVersion()
Get whether this transaction's read version has already been set. In particular, this will returntrue
if someone has explicitly calledsetReadVersion(long)
orgetReadVersion()
on this context or if agetReadVersionAsync()
call has completed, and it will returnfalse
otherwise. If this returnstrue
, thengetReadVersionAsync()
will return an immediately ready future andgetReadVersion()
is non-blocking.- Returns:
- whether this transaction's read version has already been set
- See Also:
getReadVersionAsync()
,setReadVersion(long)
,ReadTransaction.getReadVersion()
-
readTransaction
@Nonnull public ReadTransaction readTransaction(boolean snapshot)
-
getTransactionAge
public long getTransactionAge()
Get the number of milliseconds since context was created.- Returns:
- the number of milliseconds since context was created
-
getTransactionCreateTime
public long getTransactionCreateTime()
-
hasDirtyStoreState
@API(INTERNAL) public boolean hasDirtyStoreState()
Return whether any record store opened with this context has had its cache-able store state modified. This is then used to avoid using the cached state when there have been modifications to the cached state within this transaction. Note that if multiple record stores are opened within a single transaction and one (but not all of them) updates its state, then the other record stores will also eschew the cache.This method is internal to the Record Layer and should not be used by external consumers.
- Returns:
- whether the record store's state has been modified in the course of this transaction
-
addCommitCheck
public void addCommitCheck(@Nonnull FDBRecordContext.CommitCheckAsync check)
Add aFDBRecordContext.CommitCheckAsync
to be performed beforecommit()
finishes. This method is suitable for checks that cannot be started until just before commit. For checks that can be started beforeaddCommitCheck
time,addCommitCheck(CompletableFuture)
may be more convenient.It is possible for this method to throw an exception caused by an earlier unsuccessful check that has become ready in the meantime.
- Parameters:
check
- the check to be performed
-
addCommitCheck
public void addCommitCheck(@Nonnull CompletableFuture<Void> check)
Add a check to be completed beforecommit()
finishes.commit()
will wait for the future to be completed (exceptionally if the check fails) before committing the underlying transaction.It is possible for this method to throw an exception caused by an earlier unsuccessful check that has become ready in the meantime.
- Parameters:
check
- the check to be performed
-
runCommitChecks
@Nonnull public CompletableFuture<Void> runCommitChecks()
Run anyFDBRecordContext.CommitCheckAsync
s that are still outstanding.- Returns:
- a future that is complete when all checks have been performed
-
getOrCreatePostCommit
@Nonnull public FDBRecordContext.PostCommit getOrCreatePostCommit(@Nonnull String name, @Nonnull Function<String,FDBRecordContext.PostCommit> ifNotExists)
Fetches a post-commit hook, creating a new one if it does not already exist.- Parameters:
name
- name of the post-commit hookifNotExists
- if the post-commit hook has not been previously installed, a function that will be called to install a new hook by the provided name- Returns:
- post commit hook
-
getPostCommit
@Nullable public FDBRecordContext.PostCommit getPostCommit(@Nonnull String name)
Fetches a previously installed post-commit hook.- Parameters:
name
- the name of the post-commit hook- Returns:
- the post-commit hook, if it was previously installed or
null
if there is no hook by the providedname
-
addPostCommit
public void addPostCommit(@Nonnull String name, @Nonnull FDBRecordContext.PostCommit postCommit)
Adds a new post-commit hook. This method should only be used in cases in which you will be installing the post-commit hook exactly once. That is, due to race conditions, you should not be doing:if (context.getPostCommit("myPostCommit")) { context.addPostCommit("myPostCommit", () -> ..); }
if you need this behavior usegetOrCreatePostCommit(String, Function)
instead.- Parameters:
name
- name of the post-commitpostCommit
- the post commit to install
-
addPostCommit
public void addPostCommit(@Nonnull FDBRecordContext.PostCommit postCommit)
Install an anonymous post-commit hook. A post-commit hook installed in this fashion cannot be retrieved viagetPostCommit(String)
.- Parameters:
postCommit
- post-commit hook to install
-
removePostCommit
@Nullable public FDBRecordContext.PostCommit removePostCommit(@Nonnull String name)
Remove a previously installed post-commit hook.- Parameters:
name
- the name of the hook to remove- Returns:
null
if the hook does not exist, otherwise the handle to the previously installed hook
-
addAfterCommit
public void addAfterCommit(@Nonnull FDBRecordContext.AfterCommit afterCommit)
Adds code to be executed immediately following a successful commit. All after-commit hooks are run serially within a single future immediately following the completion of the commit future.- Parameters:
afterCommit
- code to be executed following successful commit
-
runAfterCommits
@Deprecated @API(DEPRECATED) public void runAfterCommits()
Deprecated.this method probably should never have been publicRun all of the after commit hooks.
-
getCommittedVersion
public long getCommittedVersion()
Return the eight byte version assigned to this context at commit time. This version is used internally by the database to determine which transactions should be visible by which reads. (In other words, only transactions assigned a read version greater than or equal to this version will see the effects of this transaction). If this transaction is read only, then no version will ever be assigned to this commit, so this function will return -1.- Returns:
- the eight byte version associated with this transaction or
null
- Throws:
IllegalStateException
- if this is called prior to the transaction being committed
-
getVersionStamp
@Nullable public byte[] getVersionStamp()
Return the ten byte version-stamp assigned to this context at commit time. The first eight bytes will be the big-Endian byte representation of the result ofgetCommittedVersion()
. This version is compatible with the "global version" that is required by theFDBRecordVersion
class and can be used to construct a complete record version from an incomplete one. If this transaction is read only, then no version will ever be assigned to this commit, so this function will returnnull
.- Returns:
- the ten byte global version-stamp associated with this transaction or
null
- Throws:
IllegalStateException
- if this is called prior to the transaction being committed
-
getMetaDataVersionStampAsync
@Nonnull public CompletableFuture<byte[]> getMetaDataVersionStampAsync(@Nonnull IsolationLevel isolationLevel)
Get the database's meta-data version-stamp. This key is somewhat different from other keys in the database in that its value is returned to the client at the same time that the client receives its read version. This means that reading this key does not require querying any storage server, so the client can use this key as a kind of "cache invalidation" key without needing to worry about the extra reads to this key overloading the backing storage servers (which would be the case for other keys).This key can only be updated by calling
setMetaDataVersionStamp()
, which will set the key to the transaction's version-stamp when the transaction is committed. If the key is set within the context of this transaction, this method will returnnull
.- Parameters:
isolationLevel
- the isolation level at which to read the key- Returns:
- a future that will complete with the current value of the meta-data version stamp or
null
if it is unset or has been updated during the course of this transaction
-
getMetaDataVersionStamp
@Nullable public byte[] getMetaDataVersionStamp(@Nonnull IsolationLevel isolationLevel)
A blocking version ofgetMetaDataVersionStampAsync(IsolationLevel)
.- Parameters:
isolationLevel
- the isolation level at which to read the key- Returns:
- the current value of the meta-data version stamp or
null
if it is unset or has been updated during the course of this transaction - See Also:
getMetaDataVersionStampAsync(IsolationLevel)
-
setMetaDataVersionStamp
public void setMetaDataVersionStamp()
Update the meta-data version-stamp. At commit time, the database will write to this key the commit version-stamp of this transaction. After this has been committed, any subsequent transaction will see an updated value when callinggetMetaDataVersionStamp(IsolationLevel)
, and those transactions may use that value to invalidate any stale cache entries using the meta-data version-stamp key. After this method has been called, any calls togetMetaDataVersionStamp()
will returnnull
. After this context has been committed, one may callgetVersionStamp()
to get the value that this transaction wrote to the database.
-
asyncToSync
@Nullable public <T> T asyncToSync(StoreTimer.Wait event, @Nonnull CompletableFuture<T> async)
-
join
public <T> T join(CompletableFuture<T> future)
Join a future following the same logic thatasyncToSync()
uses to validate that the operation isn't blocking in an asynchronous context.- Type Parameters:
T
- the type of the value produced by the future- Parameters:
future
- the future to be completed- Returns:
- the result value
- See Also:
FDBDatabase.join(CompletableFuture)
-
joinNow
public <T> T joinNow(CompletableFuture<T> future)
Join a future but validate that the future is already completed. This can be used to unwrap a completed future while allowing for bugs caused by inadvertently waiting on incomplete futures to be caught. In particular, this will throw an exception if theBlockingInAsyncDetection
behavior is set to throw an exception on incomplete futures and otherwise just log that future was waited on.- Type Parameters:
T
- the type of the value produced by the future- Parameters:
future
- the future that should already be completed- Returns:
- the result value
- See Also:
FDBDatabase.joinNow(CompletableFuture)
-
get
public <T> T get(CompletableFuture<T> future) throws InterruptedException, ExecutionException
Get a future following the same logic thatasyncToSync()
uses to validate that the operation isn't blocking in an asynchronous context.- Type Parameters:
T
- the type of the value produced by the future- Parameters:
future
- the future to be completed- Returns:
- the result value
- Throws:
CancellationException
- if the future was cancelledExecutionException
- if the future completed exceptionallyInterruptedException
- if the current thread was interrupted- See Also:
FDBDatabase.get(CompletableFuture)
-
timeReadSampleKey
public void timeReadSampleKey(byte[] key)
-
newRunner
@Nonnull public FDBDatabaseRunner newRunner()
Get a newFDBDatabaseRunner
that will run contexts similar to this one.- Same database
- Same timer
- Same MDC context
- Same weak read semantics
- Same priority
- Same transaction timeout
- Returns:
- a new database runner based on this context
-
claimLocalVersion
public int claimLocalVersion()
Claims a local version that is unique within a single transaction. This means that any two calls to this method will return a different value. If the ordering of these calls is deterministic, then it is also guaranteed that the earlier calls will receive a smaller version than the newer calls.- Returns:
- an integer to version different records added to the database
-
addVersionMutation
@Deprecated @Nullable public byte[] addVersionMutation(@Nonnull byte[] key, @Nonnull byte[] value)
Deprecated.use #addVersionMutation(MutationType, byte[], byte[]) insteadAdd aSET_VERSIONSTAMPED_KEY
mutation to be run at commit time. This method is deprecated in favor ofaddVersionMutation(MutationType, byte[], byte[])
which behaves like this method except that the choice ofSET_VERSIONSTAMPED_KEY
as the mutation type must be made explicitly.- Parameters:
key
- key bytes for the mutationvalue
- parameter bytes for the mutation- Returns:
- the previous value set for the given key or
null
if unset
-
addVersionMutation
@Nullable public byte[] addVersionMutation(@Nonnull MutationType mutationType, @Nonnull byte[] key, @Nonnull byte[] value)
Add aSET_VERSIONSTAMPED_KEY
orSET_VERSIONTSTAMPED_VALUE
mutation to be run at commit time. When called, this updates a local cache of these mutations. ThecommitAsync
method will then be sure to flush these mutations to the transaction prior to calling commit.- Parameters:
mutationType
- the type of versionstamp mutationkey
- key bytes for the mutationvalue
- parameter bytes for the mutation- Returns:
- the previous value set for the given key or
null
if unset
-
removeVersionMutation
@Nullable public byte[] removeVersionMutation(@Nonnull byte[] key)
Remove aSET_VERSIONSTAMPED_KEY
mutation that would have been run at commit time. When called, this updates a local cache of these mutations. This will only work as expected if the dummy bytes included that stand in for the versionstamp within the key bytes are equal to the dummy bytes for whatever key is included in the cache already. (For example, one might use entirely0xff
bytes for those dummy bytes for all incomplete versions. This is what theFDBRecordVersion
class does.)- Parameters:
key
- key bytes appropriate for mutation to set- Returns:
- the previous value set for the given key or
null
if unset
-
updateVersionMutation
@Nullable public byte[] updateVersionMutation(@Nonnull MutationType mutationType, @Nonnull byte[] key, @Nonnull byte[] value, @Nonnull BiFunction<byte[],byte[],byte[]> remappingFunction)
-
getWeakReadSemantics
@Nullable public FDBDatabase.WeakReadSemantics getWeakReadSemantics()
-
getPriority
@Nonnull public FDBTransactionPriority getPriority()
Get the priority of this transaction. This is used to determine what rate-limiting rules should be applied to this transaction by the database. In general,DEFAULT
priority transactions are favored overBATCH
priority transactions.- Returns:
- this transaction's priority
- See Also:
FDBTransactionPriority
-
setHookForAsyncToSync
public void setHookForAsyncToSync(@Nonnull Consumer<StoreTimer.Wait> hook)
-
hasHookForAsyncToSync
public boolean hasHookForAsyncToSync()
-
-