| 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 java.util.BitSet; |
| 9 |
|
| 10 |
import org.h2.mvstore.RootReference; |
| 11 |
|
| 12 |
/** |
| 13 |
* Snapshot of the map root and committing transactions. |
| 14 |
*/ |
| 15 |
final class Snapshot<K,V> { |
| 16 |
|
| 17 |
/** |
| 18 |
* The root reference. |
| 19 |
*/ |
| 20 |
final RootReference<K,V> root; |
| 21 |
|
| 22 |
/** |
| 23 |
* The committing transactions (see also TransactionStore.committingTransactions). |
| 24 |
*/ |
| 25 |
final BitSet committingTransactions; |
| 26 |
|
| 27 |
Snapshot(RootReference<K,V> root, BitSet committingTransactions) { |
| 28 |
this.root = root; |
| 29 |
this.committingTransactions = committingTransactions; |
| 30 |
} |
| 31 |
|
| 32 |
@Override |
| 33 |
public int hashCode() { |
| 34 |
final int prime = 31; |
| 35 |
int result = 1; |
| 36 |
result = prime * result + committingTransactions.hashCode(); |
| 37 |
result = prime * result + root.hashCode(); |
| 38 |
return result; |
| 39 |
} |
| 40 |
|
| 41 |
@SuppressWarnings("unchecked") |
| 42 |
@Override |
| 43 |
public boolean equals(Object obj) { |
| 44 |
if (this == obj) { |
| 45 |
return true; |
| 46 |
} |
| 47 |
if (!(obj instanceof Snapshot)) { |
| 48 |
return false; |
| 49 |
} |
| 50 |
Snapshot<K,V> other = (Snapshot<K,V>) obj; |
| 51 |
return committingTransactions == other.committingTransactions && root == other.root; |
| 52 |
} |
| 53 |
|
| 54 |
} |