TransactionStore

A store that supports concurrent MVCC read-committed transactions.

Methods
static long getLogId(long operationId)
Get the log id for the given operation id.
static long getLogId(long operationId)
Get the log id for the given operation id.
Parameters:
operationId - the operation id
Returns:
the log id
static long getOperationId(int transactionId, long logId)
Combine the transaction id and the log id to an operation id.
static long getOperationId(int transactionId, long logId)
Combine the transaction id and the log id to an operation id.
Parameters:
transactionId - the transaction id
logId - the log id
Returns:
the operation id
static int getTransactionId(long operationId)
Get the transaction id for the given operation id.
static int getTransactionId(long operationId)
Get the transaction id for the given operation id.
Parameters:
operationId - the operation id
Returns:
the transaction id
TransactionStore(MVStore store)
Create a new transaction store.
TransactionStore(MVStore store)
Create a new transaction store.
Parameters:
store - the store
TransactionStore(MVStore store, DataType dataType)
Create a new transaction store.
TransactionStore(MVStore store, DataType dataType)
Create a new transaction store.
Parameters:
store - the store
dataType - the data type for map keys and values
TransactionStore.Transaction begin()
Begin a new transaction.
TransactionStore.Transaction begin()
Begin a new transaction.
Returns:
the transaction
void close()
Close the transaction store.
void close()
Close the transaction store.
void commit(TransactionStore.Transaction t, long maxLogId)
Commit a transaction.
void commit(TransactionStore.Transaction t, long maxLogId)
Commit a transaction.
Parameters:
t - the transaction
maxLogId - the last log id
MVMap createTempMap()
Create a temporary map.
MVMap createTempMap()
Create a temporary map. Such maps are removed when opening the store.
Returns:
the map
void endTransaction(TransactionStore.Transaction t, int oldStatus)
End this transaction
void endTransaction(TransactionStore.Transaction t, int oldStatus)
End this transaction
Parameters:
t - the transaction
oldStatus - status of this transaction
Iterator getChanges(TransactionStore.Transaction t, long maxLogId, long toLogId)
Get the changes of the given transaction, starting from the latest log id back to the given log id.
Iterator getChanges(TransactionStore.Transaction t, long maxLogId, long toLogId)
Get the changes of the given transaction, starting from the latest log id back to the given log id.
Parameters:
t - the transaction
maxLogId - the maximum log id
toLogId - the minimum log id
Returns:
the changes
List getOpenTransactions()
Get the list of unclosed transactions that have pending writes.
List getOpenTransactions()
Get the list of unclosed transactions that have pending writes.
Returns:
the list of transactions (sorted by id)
void init()
Initialize the store.
void init()
Initialize the store. This is needed before a transaction can be opened. If the transaction store is corrupt, this method can throw an exception, in which case the store can only be used for reading.
void log(TransactionStore.Transaction t, long logId, int mapId, Object key, Object oldValue)
Log an entry.
void log(TransactionStore.Transaction t, long logId, int mapId, Object key, Object oldValue)
Log an entry.
Parameters:
t - the transaction
logId - the log id
mapId - the map id
key - the key
oldValue - the old value
void logUndo(TransactionStore.Transaction t, long logId)
Remove a log entry.
void logUndo(TransactionStore.Transaction t, long logId)
Remove a log entry.
Parameters:
t - the transaction
logId - the log id
MVMap openMap(String name, DataType keyType, DataType valueType)
Open the map with the given name.
MVMap openMap(String name, DataType keyType, DataType valueType)
Open the map with the given name.
Parameters:
name - the map name
keyType - the key type
valueType - the value type
Returns:
the map
MVMap openMap(int mapId)
Open the map with the given id.
MVMap openMap(int mapId)
Open the map with the given id.
Parameters:
mapId - the id
Returns:
the map
MVMap openTempMap(String mapName)
Open a temporary map.
MVMap openTempMap(String mapName)
Open a temporary map.
Parameters:
mapName - the map name
Returns:
the map
void removeMap(TransactionStore.TransactionMap map)
Remove the given map.
void removeMap(TransactionStore.TransactionMap map)
Remove the given map.
Parameters:
map - the map
void rollbackTo(TransactionStore.Transaction t, long maxLogId, long toLogId)
Rollback to an old savepoint.
void rollbackTo(TransactionStore.Transaction t, long maxLogId, long toLogId)
Rollback to an old savepoint.
Parameters:
t - the transaction
maxLogId - the last log id
toLogId - the log id to roll back to
void setMaxTransactionId(int max)
Set the maximum transaction id, after which ids are re-used.
void setMaxTransactionId(int max)
Set the maximum transaction id, after which ids are re-used. If the old transaction is still in use when re-using an old id, the new transaction fails.
Parameters:
max - the maximum id
void storeTransaction(TransactionStore.Transaction t)
Store a transaction.
void storeTransaction(TransactionStore.Transaction t)
Store a transaction.
Parameters:
t - the transaction

Fields
static MVMap preparedTransactions
static ReentrantReadWriteLock rwLock
static MVStore store
static MVMap undoLog

preparedTransactions

The persisted map of prepared transactions. Key: transactionId, value: [ status, name ].

rwLock

the reader/writer lock for the undo-log. Allows us to process multiple selects in parallel.

store

The store.

undoLog

The undo log.

If the first entry for a transaction doesn't have a logId of 0, then the transaction is partially committed (which means rollback is not possible). Log entries are written before the data is changed (write-ahead).

Key: opId, value: [ mapId, key, oldValue ].