提交 f8d2786e authored 作者: Andrei Tokar's avatar Andrei Tokar

misc tiny refactorings

上级 8c10350d
......@@ -1045,7 +1045,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
public final long getVersion() {
RootReference rootReference = getRoot();
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;
}
......
......@@ -1177,10 +1177,6 @@ public class MVStore {
c.mapId = lastMapId.get();
c.next = Long.MAX_VALUE;
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<>();
for (Iterator<MVMap<?, ?>> iter = maps.values().iterator(); iter.hasNext(); ) {
MVMap<?, ?> map = iter.next();
......
......@@ -57,6 +57,7 @@ public class MVPrimaryIndex extends BaseIndex {
mapName = "table." + getId();
Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(mapName, keyType, valueType);
dataMap.map.setVolatile(!indexType.isPersistent());
t.commit();
if (!table.isPersistData() || !indexType.isPersistent()) {
dataMap.map.setVolatile(true);
......
......@@ -67,6 +67,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
ValueDataType valueType = new ValueDataType(null, null, null);
Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(mapName, keyType, valueType);
dataMap.map.setVolatile(!indexType.isPersistent());
t.commit();
if (!keyType.equals(dataMap.getKeyType())) {
throw DbException.throwInternalError(
......
......@@ -56,7 +56,7 @@ public class TransactionStore {
final MVMap<Long,Object[]> undoLogs[] = new MVMap[MAX_OPEN_TRANSACTIONS];
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[].
......@@ -125,7 +125,6 @@ public class TransactionStore {
*/
public TransactionStore(MVStore store, DataType dataType, int timeoutMillis) {
this.store = store;
this.dataType = dataType;
this.timeoutMillis = timeoutMillis;
preparedTransactions = store.openMap("openTransactions",
new MVMap.Builder<Integer, Object[]>());
......@@ -136,6 +135,9 @@ public class TransactionStore {
undoLogBuilder = new MVMap.Builder<Long, Object[]>()
.singleWriter()
.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 {
public void endLeftoverTransactions() {
List<Transaction> list = getOpenTransactions();
for (Transaction t : list) {
if (t.getStatus() == Transaction.STATUS_COMMITTED) {
int status = t.getStatus();
if (status == Transaction.STATUS_COMMITTED) {
t.commit();
} else if (t.getStatus() != Transaction.STATUS_PREPARED) {
} else if (status != Transaction.STATUS_PREPARED) {
t.rollback();
}
}
......@@ -512,10 +515,6 @@ public class TransactionStore {
// 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);
}
return map;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论