| 1 |
/* |
| 2 |
* Copyright 2004-2019 H2 Group. Multiple-Licensed under the MPL 2.0, |
| 3 |
* and the EPL 1.0 (http://h2database.com/html/license.html). |
| 4 |
* Initial Developer: H2 Group |
| 5 |
*/ |
| 6 |
package org.h2.mvstore.tx; |
| 7 |
|
| 8 |
import org.h2.value.VersionedValue; |
| 9 |
|
| 10 |
/** |
| 11 |
* Class VersionedValueUncommitted. |
| 12 |
* |
| 13 |
* @author <a href='mailto:[email protected]'>Andrei Tokar</a> |
| 14 |
*/ |
| 15 |
class VersionedValueUncommitted extends VersionedValueCommitted { |
| 16 |
private final long operationId; |
| 17 |
private final Object committedValue; |
| 18 |
|
| 19 |
private VersionedValueUncommitted(long operationId, Object value, Object committedValue) { |
| 20 |
super(value); |
| 21 |
assert operationId != 0; |
| 22 |
this.operationId = operationId; |
| 23 |
this.committedValue = committedValue; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Create new VersionedValueUncommitted. |
| 28 |
* |
| 29 |
* @param operationId combined log/transaction id |
| 30 |
* @param value value before commit |
| 31 |
* @param committedValue value after commit |
| 32 |
* @return VersionedValue instance |
| 33 |
*/ |
| 34 |
static VersionedValue getInstance(long operationId, Object value, Object committedValue) { |
| 35 |
return new VersionedValueUncommitted(operationId, value, committedValue); |
| 36 |
} |
| 37 |
|
| 38 |
@Override |
| 39 |
public boolean isCommitted() { |
| 40 |
return false; |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public long getOperationId() { |
| 45 |
return operationId; |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public Object getCommittedValue() { |
| 50 |
return committedValue; |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public String toString() { |
| 55 |
return super.toString() + |
| 56 |
" " + TransactionStore.getTransactionId(operationId) + "/" + |
| 57 |
TransactionStore.getLogId(operationId) + " " + committedValue; |
| 58 |
} |
| 59 |
} |