提交 a8693704 authored 作者: Thomas Mueller's avatar Thomas Mueller

New experimental page store.

上级 2376a5e1
......@@ -9,6 +9,7 @@ package org.h2.command.dml;
import java.sql.SQLException;
import org.h2.command.Prepared;
import org.h2.constant.SysProperties;
import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.log.LogSystem;
......@@ -123,8 +124,8 @@ public class TransactionCommand extends Prepared {
break;
case CHECKPOINT:
session.getUser().checkAdmin();
PageStore store = session.getDatabase().getPageStore();
if (store != null) {
if (SysProperties.PAGE_STORE) {
PageStore store = session.getDatabase().getPageStore();
store.checkpoint();
}
session.getDatabase().getLog().checkpoint();
......
......@@ -2091,7 +2091,7 @@ public class Database implements DataHandler {
}
public PageStore getPageStore() throws SQLException {
if (pageStore == null) {
if (pageStore == null && SysProperties.PAGE_STORE) {
pageStore = new PageStore(this, databaseName + Constants.SUFFIX_PAGE_FILE, accessModeData,
SysProperties.CACHE_SIZE_DEFAULT);
pageStore.open();
......
......@@ -42,7 +42,7 @@ public class LogSystem {
private LogFile currentLog;
private String fileNamePrefix;
private HashMap storages = new HashMap();
private HashMap sessions = new HashMap();
private HashMap sessionStates = new HashMap();
private DataPage rowBuff;
private ObjectArray undo;
// TODO log file / deleteOldLogFilesAutomatically:
......@@ -252,7 +252,7 @@ public class LogSystem {
database.getIndexFile().flushRedoLog();
}
int end = currentLog.getPos();
Object[] states = sessions.values().toArray();
Object[] states = sessionStates.values().toArray();
inDoubtTransactions = new ObjectArray();
for (int i = 0; i < states.length; i++) {
SessionState state = (SessionState) states[i];
......@@ -260,10 +260,10 @@ public class LogSystem {
inDoubtTransactions.add(state.inDoubtTransaction);
}
}
for (int i = undo.size() - 1; i >= 0 && sessions.size() > 0; i--) {
for (int i = undo.size() - 1; i >= 0 && sessionStates.size() > 0; i--) {
database.setProgress(DatabaseEventListener.STATE_RECOVER, null, undo.size() - 1 - i, undo.size());
LogRecord record = (LogRecord) undo.get(i);
if (sessions.get(ObjectUtils.getInteger(record.sessionId)) != null) {
if (sessionStates.get(ObjectUtils.getInteger(record.sessionId)) != null) {
// undo only if the session is not yet committed
record.log.undo(record.logRecordId);
database.getDataFile().flushRedoLog();
......@@ -359,7 +359,7 @@ public class LogSystem {
*/
boolean isSessionCommitted(int sessionId, int logId, int pos) {
Integer key = ObjectUtils.getInteger(sessionId);
SessionState state = (SessionState) sessions.get(key);
SessionState state = (SessionState) sessionStates.get(key);
if (state == null) {
return true;
}
......@@ -389,10 +389,10 @@ public class LogSystem {
*/
SessionState getOrAddSessionState(int sessionId) {
Integer key = ObjectUtils.getInteger(sessionId);
SessionState state = (SessionState) sessions.get(key);
SessionState state = (SessionState) sessionStates.get(key);
if (state == null) {
state = new SessionState();
sessions.put(key, state);
sessionStates.put(key, state);
state.sessionId = sessionId;
}
return state;
......@@ -433,7 +433,7 @@ public class LogSystem {
* @param sessionId the session id
*/
void removeSession(int sessionId) {
sessions.remove(ObjectUtils.getInteger(sessionId));
sessionStates.remove(ObjectUtils.getInteger(sessionId));
}
/**
......
......@@ -15,22 +15,22 @@ public class SessionState {
/**
* The session id
*/
int sessionId;
public int sessionId;
/**
* The last log file id where a commit for this session is found.
*/
int lastCommitLog;
public int lastCommitLog;
/**
* The position where a commit for this session is found.
*/
int lastCommitPos;
public int lastCommitPos;
/**
* The in-doubt transaction if there is one.
*/
InDoubtTransaction inDoubtTransaction;
public InDoubtTransaction inDoubtTransaction;
/**
* Check if this session state is already committed at this point.
......@@ -39,7 +39,7 @@ public class SessionState {
* @param pos the position in the log file
* @return true if it is committed
*/
boolean isCommitted(int logId, int pos) {
public boolean isCommitted(int logId, int pos) {
if (logId != lastCommitLog) {
return lastCommitLog > logId;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论