Debian Codegraph @

src/main/org/h2/mvstore/tx/VersionedValueUncommitted.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://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<T> extends VersionedValueCommitted<T> {
16 private final long operationId;
17 private final T committedValue;
18
19 private VersionedValueUncommitted(long operationId, T value, T 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 <X> type of the value to get the VersionedValue for
30 *
31 * @param operationId combined log/transaction id
32 * @param value value before commit
33 * @param committedValue value after commit
34 * @return VersionedValue instance
35 */
36 static <X> VersionedValue<X> getInstance(long operationId, X value, X committedValue) {
37 return new VersionedValueUncommitted<>(operationId, value, committedValue);
38 }
39
40 @Override
41 public boolean isCommitted() {
42 return false;
43 }
44
45 @Override
46 public long getOperationId() {
47 return operationId;
48 }
49
50 @Override
51 public T getCommittedValue() {
52 return committedValue;
53 }
54
55 @Override
56 public String toString() {
57 return super.toString() +
58 " " + TransactionStore.getTransactionId(operationId) + "/" +
59 TransactionStore.getLogId(operationId) + " " + committedValue;
60 }
61 }