public class Transaction extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Transaction.VisibilityLevel
Defines the possible visibility levels for read operations.
|
Modifier and Type | Field and Description |
---|---|
static Transaction |
ALL_VISIBLE_LATEST |
static long |
NO_TX_IN_PROGRESS |
Constructor and Description |
---|
Transaction(long readPointer,
long txId,
long[] invalids,
long[] inProgress,
long firstShortInProgress)
Creates a new short transaction.
|
Transaction(long readPointer,
long txId,
long[] invalids,
long[] inProgress,
long firstShortInProgress,
TransactionType type)
Creates a new transaction.
|
Transaction(long readPointer,
long txId,
long writePointer,
long[] invalids,
long[] inProgress,
long firstShortInProgress,
TransactionType type,
long[] checkpointPointers,
Transaction.VisibilityLevel visibilityLevel)
Creates a new transaction.
|
Transaction(Transaction toCopy,
long writePointer,
long[] checkpointPointers)
Creates a new transaction for a checkpoint operation, copying all members from the original transaction,
with the updated checkpoint write pointers.
|
Modifier and Type | Method and Description |
---|---|
int |
excludesSize() |
long[] |
getCheckpointWritePointers()
Returns any prior write pointers used in the current transaction.
|
long |
getFirstInProgress() |
long |
getFirstShortInProgress() |
long[] |
getInProgress() |
long[] |
getInvalids() |
long |
getReadPointer() |
long |
getTransactionId()
Returns the initial write pointer assigned to the transaction.
|
TransactionType |
getType() |
Transaction.VisibilityLevel |
getVisibilityLevel()
Returns the currently set visibility level.
|
long |
getVisibilityUpperBound() |
long |
getWritePointer()
Returns the write pointer to be used in persisting any changes.
|
boolean |
hasExcludes() |
boolean |
isCheckpoint(long version)
Returns true if the the given version corresponds to one of the checkpoint versions in the current
transaction.
|
boolean |
isCurrentWrite(long version)
Returns whether the given version was written by the current transaction.
|
boolean |
isExcluded(long version)
Returns true if the given version is present in one of the arrays of excluded versions (in-progress and
invalid transactions).
|
boolean |
isInProgress(long version)
Returns true if the given version corresponds to a transaction that was in-progress at the time this transaction
started.
|
boolean |
isVisible(long version)
Returns whether or not the given version should be visible to the current transaction.
|
void |
setVisibility(Transaction.VisibilityLevel level)
Sets the visibility level for read operations.
|
String |
toString() |
public static final long NO_TX_IN_PROGRESS
public static final Transaction ALL_VISIBLE_LATEST
public Transaction(long readPointer, long txId, long[] invalids, long[] inProgress, long firstShortInProgress)
readPointer
- read pointer for transactiontxId
- unique identifier for the transactioninvalids
- list of invalid transactions to exclude while readinginProgress
- list of in-progress transactions to exclude while readingfirstShortInProgress
- earliest in-progress short transactionpublic Transaction(long readPointer, long txId, long[] invalids, long[] inProgress, long firstShortInProgress, TransactionType type)
readPointer
- read pointer for transactiontxId
- unique identifier for the transactioninvalids
- list of invalid transactions to exclude while readinginProgress
- list of in-progress transactions to exclude while readingfirstShortInProgress
- earliest in-progress short transactiontype
- transaction typepublic Transaction(long readPointer, long txId, long writePointer, long[] invalids, long[] inProgress, long firstShortInProgress, TransactionType type, long[] checkpointPointers, Transaction.VisibilityLevel visibilityLevel)
readPointer
- read pointer for transactiontxId
- unique identifier for the transactionwritePointer
- the current pointer to be used for any writes.
For new transactions, this will be the same as txId
. For checkpointed
transactions, this will be the most recent write pointer issued.invalids
- list of invalid transactions to exclude while readinginProgress
- list of in-progress transactions to exclude while readingfirstShortInProgress
- earliest in-progress short transactiontype
- transaction typecheckpointPointers
- the list of writer pointers added from checkpoints on the transactionvisibilityLevel
- the visibility level to use for transactional readspublic Transaction(Transaction toCopy, long writePointer, long[] checkpointPointers)
toCopy
- the original transaction containing the state to copywritePointer
- the new write pointer to use for the transactioncheckpointPointers
- the list of write pointers added from checkpoints on the transactionpublic long getReadPointer()
public long getTransactionId()
public long getWritePointer()
getTransactionId()
. This method should always be used when setting the timestamp for writes
in order to ensure that the correct value is used.public long[] getInvalids()
public long[] getInProgress()
public long getFirstInProgress()
public TransactionType getType()
public long getVisibilityUpperBound()
X
such that any of the transactions newer than X
may be invisible to thisNOTE: the returned tx id can be invalid.
public long getFirstShortInProgress()
public boolean isInProgress(long version)
public boolean isExcluded(long version)
public boolean isCheckpoint(long version)
public boolean isVisible(long version)
version
- the data version to check for visibilityto control whether the current write pointer is visible.
public boolean isCurrentWrite(long version)
version
- the data versionpublic void setVisibility(Transaction.VisibilityLevel level)
public Transaction.VisibilityLevel getVisibilityLevel()
public boolean hasExcludes()
public int excludesSize()
public long[] getCheckpointWritePointers()
TransactionContext.checkpoint(Transaction)
operation is called, and the prior write pointer is added
to the array of checkpoint write pointers.
`Copyright © 2016 The Apache Software Foundation. All rights reserved.