提交 38f2504c authored 作者: Andrei Tokar's avatar Andrei Tokar

limit visibility

unused methods removed
min0r refactoring
上级 daa433f0
...@@ -109,10 +109,7 @@ public class MVTableEngine implements TableEngine { ...@@ -109,10 +109,7 @@ public class MVTableEngine implements TableEngine {
public TableBase createTable(CreateTableData data) { public TableBase createTable(CreateTableData data) {
Database db = data.session.getDatabase(); Database db = data.session.getDatabase();
Store store = init(db); Store store = init(db);
MVTable table = new MVTable(data, store); return store.createTable(data);
table.init(data.session);
store.tableMap.put(table.getMapName(), table);
return table;
} }
/** /**
...@@ -124,8 +121,8 @@ public class MVTableEngine implements TableEngine { ...@@ -124,8 +121,8 @@ public class MVTableEngine implements TableEngine {
* The map of open tables. * The map of open tables.
* Key: the map name, value: the table. * Key: the map name, value: the table.
*/ */
final ConcurrentHashMap<String, MVTable> tableMap = private final ConcurrentHashMap<String, MVTable> tableMap =
new ConcurrentHashMap<>(); new ConcurrentHashMap<>();
/** /**
* The store. * The store.
...@@ -152,7 +149,7 @@ public class MVTableEngine implements TableEngine { ...@@ -152,7 +149,7 @@ public class MVTableEngine implements TableEngine {
* @param builder the builder * @param builder the builder
* @param encrypted whether the store is encrypted * @param encrypted whether the store is encrypted
*/ */
void open(Database db, MVStore.Builder builder, boolean encrypted) { private void open(Database db, MVStore.Builder builder, boolean encrypted) {
this.encrypted = encrypted; this.encrypted = encrypted;
try { try {
this.store = builder.open(); this.store = builder.open();
...@@ -166,7 +163,6 @@ public class MVTableEngine implements TableEngine { ...@@ -166,7 +163,6 @@ public class MVTableEngine implements TableEngine {
this.transactionStore = new TransactionStore( this.transactionStore = new TransactionStore(
store, store,
new ValueDataType(db.getCompareMode(), db, null), db.getLockTimeout()); new ValueDataType(db.getCompareMode(), db, null), db.getLockTimeout());
// transactionStore.init();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
throw convertIllegalStateException(e); throw convertIllegalStateException(e);
} }
...@@ -195,6 +191,10 @@ public class MVTableEngine implements TableEngine { ...@@ -195,6 +191,10 @@ public class MVTableEngine implements TableEngine {
throw DbException.get( throw DbException.get(
ErrorCode.IO_EXCEPTION_1, ErrorCode.IO_EXCEPTION_1,
e, fileName); e, fileName);
} else if (errorCode == DataUtils.ERROR_INTERNAL) {
throw DbException.get(
ErrorCode.GENERAL_ERROR_1,
e, fileName);
} }
throw DbException.get( throw DbException.get(
ErrorCode.FILE_CORRUPTED_1, ErrorCode.FILE_CORRUPTED_1,
...@@ -214,6 +214,19 @@ public class MVTableEngine implements TableEngine { ...@@ -214,6 +214,19 @@ public class MVTableEngine implements TableEngine {
return tableMap.get(tableName); return tableMap.get(tableName);
} }
/**
* Create a table.
*
* @param data CreateTableData
* @return table created
*/
public MVTable createTable(CreateTableData data) {
MVTable table = new MVTable(data, this);
table.init(data.session);
tableMap.put(table.getMapName(), table);
return table;
}
/** /**
* Remove a table. * Remove a table.
* *
......
...@@ -436,7 +436,7 @@ public class Transaction { ...@@ -436,7 +436,7 @@ public class Transaction {
return store.getChanges(this, getLogId(), savepointId); return store.getChanges(this, getLogId(), savepointId);
} }
long getLogId() { private long getLogId() {
return getLogId(statusAndLogId.get()); return getLogId(statusAndLogId.get());
} }
...@@ -454,7 +454,7 @@ public class Transaction { ...@@ -454,7 +454,7 @@ public class Transaction {
/** /**
* Check whether this transaction is open or prepared. * Check whether this transaction is open or prepared.
*/ */
void checkNotClosed() { private void checkNotClosed() {
if (getStatus() == STATUS_CLOSED) { if (getStatus() == STATUS_CLOSED) {
throw DataUtils.newIllegalStateException( throw DataUtils.newIllegalStateException(
DataUtils.ERROR_CLOSED, "Transaction {0} is closed", transactionId); DataUtils.ERROR_CLOSED, "Transaction {0} is closed", transactionId);
......
...@@ -89,11 +89,6 @@ public class TransactionStore { ...@@ -89,11 +89,6 @@ public class TransactionStore {
private final AtomicReferenceArray<Transaction> transactions = private final AtomicReferenceArray<Transaction> transactions =
new AtomicReferenceArray<>(MAX_OPEN_TRANSACTIONS + 1); new AtomicReferenceArray<>(MAX_OPEN_TRANSACTIONS + 1);
/**
* The next id of a temporary map.
*/
private int nextTempMapId;
private static final String UNDO_LOG_NAME_PEFIX = "undoLog"; private static final String UNDO_LOG_NAME_PEFIX = "undoLog";
private static final char UNDO_LOG_COMMITTED = '-'; // must come before open in lexicographical order private static final char UNDO_LOG_COMMITTED = '-'; // must come before open in lexicographical order
private static final char UNDO_LOG_OPEN = '.'; private static final char UNDO_LOG_OPEN = '.';
...@@ -517,29 +512,6 @@ public class TransactionStore { ...@@ -517,29 +512,6 @@ public class TransactionStore {
return map; return map;
} }
/**
* Create a temporary map. Such maps are removed when opening the store.
*
* @return the map
*/
synchronized MVMap<Object, Integer> createTempMap() {
String mapName = "temp." + nextTempMapId++;
return openTempMap(mapName);
}
/**
* Open a temporary map.
*
* @param mapName the map name
* @return the map
*/
private MVMap<Object, Integer> openTempMap(String mapName) {
MVMap.Builder<Object, Integer> mapBuilder =
new MVMap.Builder<Object, Integer>().
keyType(dataType);
return store.openMap(mapName, mapBuilder);
}
/** /**
* End this transaction. Change status to CLOSED and vacate transaction slot. * End this transaction. Change status to CLOSED and vacate transaction slot.
* Will try to commit MVStore if autocommitDelay is 0 or if database is idle * Will try to commit MVStore if autocommitDelay is 0 or if database is idle
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论