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

Merge pull request #1256 from h2database/misc-tiny

misc tiny refactorings
...@@ -1045,7 +1045,8 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -1045,7 +1045,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
public final long getVersion() { public final long getVersion() {
RootReference rootReference = getRoot(); RootReference rootReference = getRoot();
RootReference previous = rootReference.previous; RootReference previous = rootReference.previous;
return previous == null || previous.root != rootReference.root ? return previous == null || previous.root != rootReference.root ||
previous.appendCounter != rootReference.appendCounter ?
rootReference.version : previous.version; rootReference.version : previous.version;
} }
......
...@@ -1177,10 +1177,6 @@ public class MVStore { ...@@ -1177,10 +1177,6 @@ public class MVStore {
c.mapId = lastMapId.get(); c.mapId = lastMapId.get();
c.next = Long.MAX_VALUE; c.next = Long.MAX_VALUE;
chunks.put(c.id, c); chunks.put(c.id, c);
// force a metadata update
meta.put(Chunk.getMetaKey(c.id), c.asString());
meta.remove(Chunk.getMetaKey(c.id));
markMetaChanged();
ArrayList<Page> changed = new ArrayList<>(); ArrayList<Page> changed = new ArrayList<>();
for (Iterator<MVMap<?, ?>> iter = maps.values().iterator(); iter.hasNext(); ) { for (Iterator<MVMap<?, ?>> iter = maps.values().iterator(); iter.hasNext(); ) {
MVMap<?, ?> map = iter.next(); MVMap<?, ?> map = iter.next();
......
...@@ -57,6 +57,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -57,6 +57,7 @@ public class MVPrimaryIndex extends BaseIndex {
mapName = "table." + getId(); mapName = "table." + getId();
Transaction t = mvTable.getTransactionBegin(); Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(mapName, keyType, valueType); dataMap = t.openMap(mapName, keyType, valueType);
dataMap.map.setVolatile(!indexType.isPersistent());
t.commit(); t.commit();
if (!table.isPersistData() || !indexType.isPersistent()) { if (!table.isPersistData() || !indexType.isPersistent()) {
dataMap.map.setVolatile(true); dataMap.map.setVolatile(true);
......
...@@ -67,6 +67,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex { ...@@ -67,6 +67,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
ValueDataType valueType = new ValueDataType(null, null, null); ValueDataType valueType = new ValueDataType(null, null, null);
Transaction t = mvTable.getTransactionBegin(); Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(mapName, keyType, valueType); dataMap = t.openMap(mapName, keyType, valueType);
dataMap.map.setVolatile(!indexType.isPersistent());
t.commit(); t.commit();
if (!keyType.equals(dataMap.getKeyType())) { if (!keyType.equals(dataMap.getKeyType())) {
throw DbException.throwInternalError( throw DbException.throwInternalError(
......
...@@ -101,6 +101,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex { ...@@ -101,6 +101,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
spatialMap = db.getMvStore().getStore().openMap(mapName, mapBuilder); spatialMap = db.getMvStore().getStore().openMap(mapName, mapBuilder);
Transaction t = mvTable.getTransactionBegin(); Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(spatialMap); dataMap = t.openMap(spatialMap);
dataMap.map.setVolatile(!indexType.isPersistent());
t.commit(); t.commit();
} }
......
...@@ -56,7 +56,7 @@ public class TransactionStore { ...@@ -56,7 +56,7 @@ public class TransactionStore {
final MVMap<Long,Object[]> undoLogs[] = new MVMap[MAX_OPEN_TRANSACTIONS]; final MVMap<Long,Object[]> undoLogs[] = new MVMap[MAX_OPEN_TRANSACTIONS];
private final MVMap.Builder<Long,Object[]> undoLogBuilder; private final MVMap.Builder<Long,Object[]> undoLogBuilder;
private final DataType dataType; private final MVMap.Builder<Object, VersionedValue> mapBuilder;
/** /**
* This BitSet is used as vacancy indicator for transaction slots in transactions[]. * This BitSet is used as vacancy indicator for transaction slots in transactions[].
...@@ -125,7 +125,6 @@ public class TransactionStore { ...@@ -125,7 +125,6 @@ public class TransactionStore {
*/ */
public TransactionStore(MVStore store, DataType dataType, int timeoutMillis) { public TransactionStore(MVStore store, DataType dataType, int timeoutMillis) {
this.store = store; this.store = store;
this.dataType = dataType;
this.timeoutMillis = timeoutMillis; this.timeoutMillis = timeoutMillis;
preparedTransactions = store.openMap("openTransactions", preparedTransactions = store.openMap("openTransactions",
new MVMap.Builder<Integer, Object[]>()); new MVMap.Builder<Integer, Object[]>());
...@@ -136,6 +135,9 @@ public class TransactionStore { ...@@ -136,6 +135,9 @@ public class TransactionStore {
undoLogBuilder = new MVMap.Builder<Long, Object[]>() undoLogBuilder = new MVMap.Builder<Long, Object[]>()
.singleWriter() .singleWriter()
.valueType(undoLogValueType); .valueType(undoLogValueType);
DataType vt = new VersionedValue.Type(dataType);
mapBuilder = new MVMap.Builder<Object, VersionedValue>()
.keyType(dataType).valueType(vt);
} }
/** /**
...@@ -198,9 +200,10 @@ public class TransactionStore { ...@@ -198,9 +200,10 @@ public class TransactionStore {
public void endLeftoverTransactions() { public void endLeftoverTransactions() {
List<Transaction> list = getOpenTransactions(); List<Transaction> list = getOpenTransactions();
for (Transaction t : list) { for (Transaction t : list) {
if (t.getStatus() == Transaction.STATUS_COMMITTED) { int status = t.getStatus();
if (status == Transaction.STATUS_COMMITTED) {
t.commit(); t.commit();
} else if (t.getStatus() != Transaction.STATUS_PREPARED) { } else if (status != Transaction.STATUS_PREPARED) {
t.rollback(); t.rollback();
} }
} }
...@@ -512,10 +515,6 @@ public class TransactionStore { ...@@ -512,10 +515,6 @@ public class TransactionStore {
// the map was removed later on // the map was removed later on
return null; 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); map = store.openMap(mapName, mapBuilder);
} }
return map; return map;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论