提交 31372bc0 authored 作者: Noel Grandin's avatar Noel Grandin

split the getTransaction() method

I don't like methods that do something completely different with a null parameter
上级 5d1e64ed
...@@ -66,7 +66,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -66,7 +66,7 @@ public class MVPrimaryIndex extends BaseIndex {
ValueDataType valueType = new ValueDataType(db.getCompareMode(), db, ValueDataType valueType = new ValueDataType(db.getCompareMode(), db,
sortTypes); sortTypes);
mapName = "table." + getId(); mapName = "table." + getId();
Transaction t = mvTable.getTransaction(null); Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(mapName, keyType, valueType); dataMap = t.openMap(mapName, keyType, valueType);
t.commit(); t.commit();
if (!table.isPersistData()) { if (!table.isPersistData()) {
......
...@@ -67,7 +67,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex { ...@@ -67,7 +67,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
ValueDataType keyType = new ValueDataType( ValueDataType keyType = new ValueDataType(
db.getCompareMode(), db, sortTypes); db.getCompareMode(), db, sortTypes);
ValueDataType valueType = new ValueDataType(null, null, null); ValueDataType valueType = new ValueDataType(null, null, null);
Transaction t = mvTable.getTransaction(null); Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(mapName, keyType, valueType); dataMap = t.openMap(mapName, keyType, valueType);
t.commit(); t.commit();
if (!keyType.equals(dataMap.getKeyType())) { if (!keyType.equals(dataMap.getKeyType())) {
......
...@@ -102,7 +102,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex { ...@@ -102,7 +102,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
new MVRTreeMap.Builder<VersionedValue>(). new MVRTreeMap.Builder<VersionedValue>().
valueType(valueType); valueType(valueType);
spatialMap = db.getMvStore().getStore().openMap(mapName, mapBuilder); spatialMap = db.getMvStore().getStore().openMap(mapName, mapBuilder);
Transaction t = mvTable.getTransaction(null); Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(spatialMap); dataMap = t.openMap(spatialMap);
t.commit(); t.commit();
} }
......
...@@ -846,16 +846,22 @@ public class MVTable extends TableBase { ...@@ -846,16 +846,22 @@ public class MVTable extends TableBase {
} }
/** /**
* Get the transaction to use for this session. * Get a new transaction.
* *
* @param session the session
* @return the transaction * @return the transaction
*/ */
Transaction getTransaction(Session session) { Transaction getTransactionBegin() {
if (session == null) {
// TODO need to commit/rollback the transaction // TODO need to commit/rollback the transaction
return transactionStore.begin(); return transactionStore.begin();
} }
/**
* Get the transaction to use for this session.
*
* @param session the session
* @return the transaction
*/
Transaction getTransaction(Session session) {
return session.getTransaction(); return session.getTransaction();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论