Unverified 提交 763da31b authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Merge pull request #1174 from h2database/remove-mapid

Remove mapid
......@@ -345,8 +345,7 @@ public class Transaction {
*/
public <K, V> TransactionMap<K, V> openMap(MVMap<K, VersionedValue> map) {
checkNotClosed();
int mapId = map.getId();
return new TransactionMap<>(this, map, mapId);
return new TransactionMap<>(this, map);
}
/**
......
......@@ -24,11 +24,6 @@ import java.util.Map;
*/
public class TransactionMap<K, V> {
/**
* The map id.
*/
final int mapId;
/**
* If a record was read that was updated by this transaction, and the
* update occurred before this log id, the older version is read. This
......@@ -50,11 +45,9 @@ public class TransactionMap<K, V> {
*/
final Transaction transaction;
TransactionMap(Transaction transaction, MVMap<K, VersionedValue> map,
int mapId) {
TransactionMap(Transaction transaction, MVMap<K, VersionedValue> map) {
this.transaction = transaction;
this.map = map;
this.mapId = mapId;
}
/**
......@@ -77,7 +70,7 @@ public class TransactionMap<K, V> {
public TransactionMap<K, V> getInstance(Transaction transaction,
long savepoint) {
TransactionMap<K, V> m =
new TransactionMap<>(transaction, map, mapId);
new TransactionMap<>(transaction, map);
m.setSavepoint(savepoint);
return m;
}
......@@ -141,7 +134,7 @@ public class TransactionMap<K, V> {
cursor.next();
Object[] op = cursor.getValue();
int m = (int) op[0];
if (m != mapId) {
if (m != map.getId()) {
// a different map - ignore
continue;
}
......
......@@ -8,7 +8,6 @@ package org.h2.mvstore.tx;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
......@@ -53,12 +52,6 @@ public class TransactionStore {
*/
final MVMap<Long, Object[]> undoLog;
/**
* The map of maps.
*/
private final HashMap<Integer, MVMap<Object, VersionedValue>> maps =
new HashMap<>();
private final DataType dataType;
/**
......@@ -408,7 +401,6 @@ public class TransactionStore {
* @param map the map
*/
synchronized <K, V> void removeMap(TransactionMap<K, V> map) {
maps.remove(map.mapId);
store.removeMap(map.map);
}
......@@ -476,7 +468,7 @@ public class TransactionStore {
* @param valueType the value type
* @return the map
*/
synchronized <K> MVMap<K, VersionedValue> openMap(String name,
<K> MVMap<K, VersionedValue> openMap(String name,
DataType keyType, DataType valueType) {
if (keyType == null) {
keyType = new ObjectDataType();
......@@ -490,9 +482,6 @@ public class TransactionStore {
new MVMap.Builder<K, VersionedValue>().
keyType(keyType).valueType(vt);
map = store.openMap(name, builder);
@SuppressWarnings("unchecked")
MVMap<Object, VersionedValue> m = (MVMap<Object, VersionedValue>) map;
maps.put(map.getId(), m);
return map;
}
......@@ -502,22 +491,20 @@ public class TransactionStore {
* @param mapId the id
* @return the map
*/
synchronized MVMap<Object, VersionedValue> openMap(int mapId) {
MVMap<Object, VersionedValue> map = maps.get(mapId);
if (map != null) {
return map;
}
String mapName = store.getMapName(mapId);
if (mapName == null) {
// the map was removed later on
return null;
MVMap<Object, VersionedValue> openMap(int mapId) {
MVMap<Object, VersionedValue> map = store.getMap(mapId);
if (map == null) {
String mapName = store.getMapName(mapId);
if (mapName == null) {
// the map was removed later on
return null;
}
DataType vt = new VersionedValue.Type(dataType);
MVMap.Builder<Object, VersionedValue> mapBuilder =
new MVMap.Builder<Object, VersionedValue>().
keyType(dataType).valueType(vt);
map = store.openMap(mapName, mapBuilder);
}
DataType vt = new VersionedValue.Type(dataType);
MVMap.Builder<Object, VersionedValue> mapBuilder =
new MVMap.Builder<Object, VersionedValue>().
keyType(dataType).valueType(vt);
map = store.openMap(mapName, mapBuilder);
maps.put(mapId, map);
return map;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论