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

Improved performance.

上级 014c8a16
...@@ -258,7 +258,7 @@ public class PageStore implements CacheWriter { ...@@ -258,7 +258,7 @@ public class PageStore implements CacheWriter {
/** /**
* Open the file and read the header. * Open the file and read the header.
*/ */
public void open() { public synchronized void open() {
try { try {
metaRootPageId.put(META_TABLE_ID, PAGE_ID_META_ROOT); metaRootPageId.put(META_TABLE_ID, PAGE_ID_META_ROOT);
if (IOUtils.exists(fileName)) { if (IOUtils.exists(fileName)) {
...@@ -445,7 +445,7 @@ public class PageStore implements CacheWriter { ...@@ -445,7 +445,7 @@ public class PageStore implements CacheWriter {
* @param compactMode 0 if no compacting should happen, otherwise * @param compactMode 0 if no compacting should happen, otherwise
* TransactionCommand.SHUTDOWN_COMPACT or TransactionCommand.SHUTDOWN_DEFRAG * TransactionCommand.SHUTDOWN_COMPACT or TransactionCommand.SHUTDOWN_DEFRAG
*/ */
public void compact(int compactMode) { public synchronized void compact(int compactMode) {
if (!database.getSettings().pageStoreTrim) { if (!database.getSettings().pageStoreTrim) {
return; return;
} }
...@@ -1032,7 +1032,7 @@ public class PageStore implements CacheWriter { ...@@ -1032,7 +1032,7 @@ public class PageStore implements CacheWriter {
return getFreeList(getFreeListId(pageId)); return getFreeList(getFreeListId(pageId));
} }
private synchronized PageFreeList getFreeList(int i) { private PageFreeList getFreeList(int i) {
PageFreeList list = null; PageFreeList list = null;
if (i < freeLists.size()) { if (i < freeLists.size()) {
list = freeLists.get(i); list = freeLists.get(i);
...@@ -1099,7 +1099,7 @@ public class PageStore implements CacheWriter { ...@@ -1099,7 +1099,7 @@ public class PageStore implements CacheWriter {
* *
* @return the page id * @return the page id
*/ */
public int allocatePage() { public synchronized int allocatePage() {
int pos = allocatePage(null, 0); int pos = allocatePage(null, 0);
if (!recoveryRunning) { if (!recoveryRunning) {
if (logMode != LOG_MODE_OFF) { if (logMode != LOG_MODE_OFF) {
...@@ -1109,7 +1109,7 @@ public class PageStore implements CacheWriter { ...@@ -1109,7 +1109,7 @@ public class PageStore implements CacheWriter {
return pos; return pos;
} }
private synchronized int allocatePage(BitField exclude, int first) { private int allocatePage(BitField exclude, int first) {
int page; int page;
// TODO could remember the first possible free list page // TODO could remember the first possible free list page
for (int i = 0;; i++) { for (int i = 0;; i++) {
...@@ -1153,7 +1153,7 @@ public class PageStore implements CacheWriter { ...@@ -1153,7 +1153,7 @@ public class PageStore implements CacheWriter {
* *
* @param pageId the page id * @param pageId the page id
*/ */
public void free(int pageId) { public synchronized void free(int pageId) {
free(pageId, true); free(pageId, true);
} }
...@@ -1163,7 +1163,7 @@ public class PageStore implements CacheWriter { ...@@ -1163,7 +1163,7 @@ public class PageStore implements CacheWriter {
* @param pageId the page id * @param pageId the page id
* @param undo if the undo record must have been written * @param undo if the undo record must have been written
*/ */
synchronized void free(int pageId, boolean undo) { void free(int pageId, boolean undo) {
if (trace.isDebugEnabled()) { if (trace.isDebugEnabled()) {
// trace.debug("free " + pageId + " " + undo); // trace.debug("free " + pageId + " " + undo);
} }
...@@ -1193,7 +1193,7 @@ public class PageStore implements CacheWriter { ...@@ -1193,7 +1193,7 @@ public class PageStore implements CacheWriter {
* *
* @param pageId the page id * @param pageId the page id
*/ */
synchronized void freeUnused(int pageId) { void freeUnused(int pageId) {
if (trace.isDebugEnabled()) { if (trace.isDebugEnabled()) {
trace.debug("freeUnused {0}", pageId); trace.debug("freeUnused {0}", pageId);
} }
...@@ -1217,7 +1217,7 @@ public class PageStore implements CacheWriter { ...@@ -1217,7 +1217,7 @@ public class PageStore implements CacheWriter {
* @param pos the page id * @param pos the page id
* @return the page * @return the page
*/ */
public Data readPage(int pos) { public synchronized Data readPage(int pos) {
Data page = createData(); Data page = createData();
readPage(pos, page); readPage(pos, page);
return page; return page;
...@@ -1229,7 +1229,7 @@ public class PageStore implements CacheWriter { ...@@ -1229,7 +1229,7 @@ public class PageStore implements CacheWriter {
* @param pos the page id * @param pos the page id
* @param page the page * @param page the page
*/ */
synchronized void readPage(int pos, Data page) { void readPage(int pos, Data page) {
if (recordPageReads) { if (recordPageReads) {
if (pos >= MIN_PAGE_COUNT && recordedPagesIndex.get(pos) == IntIntHashMap.NOT_FOUND) { if (pos >= MIN_PAGE_COUNT && recordedPagesIndex.get(pos) == IntIntHashMap.NOT_FOUND) {
recordedPagesIndex.put(pos, recordedPagesList.size()); recordedPagesIndex.put(pos, recordedPagesList.size());
...@@ -1632,7 +1632,7 @@ public class PageStore implements CacheWriter { ...@@ -1632,7 +1632,7 @@ public class PageStore implements CacheWriter {
* *
* @param index the index * @param index the index
*/ */
public void addIndex(PageIndex index) { public synchronized void addIndex(PageIndex index) {
metaObjects.put(index.getId(), index); metaObjects.put(index.getId(), index);
} }
...@@ -1642,7 +1642,7 @@ public class PageStore implements CacheWriter { ...@@ -1642,7 +1642,7 @@ public class PageStore implements CacheWriter {
* @param index the index to add * @param index the index to add
* @param session the session * @param session the session
*/ */
public void addMeta(PageIndex index, Session session) { public synchronized void addMeta(PageIndex index, Session session) {
int type = index instanceof PageDataIndex ? META_TYPE_DATA_INDEX : META_TYPE_BTREE_INDEX; int type = index instanceof PageDataIndex ? META_TYPE_DATA_INDEX : META_TYPE_BTREE_INDEX;
IndexColumn[] columns = index.getIndexColumns(); IndexColumn[] columns = index.getIndexColumns();
StatementBuilder buff = new StatementBuilder(); StatementBuilder buff = new StatementBuilder();
...@@ -1684,7 +1684,7 @@ public class PageStore implements CacheWriter { ...@@ -1684,7 +1684,7 @@ public class PageStore implements CacheWriter {
* @param index the index to remove * @param index the index to remove
* @param session the session * @param session the session
*/ */
public void removeMeta(Index index, Session session) { public synchronized void removeMeta(Index index, Session session) {
if (!recoveryRunning) { if (!recoveryRunning) {
removeMetaIndex(index, session); removeMetaIndex(index, session);
metaObjects.remove(index.getId()); metaObjects.remove(index.getId());
...@@ -1717,7 +1717,7 @@ public class PageStore implements CacheWriter { ...@@ -1717,7 +1717,7 @@ public class PageStore implements CacheWriter {
* @param pageId the page where the transaction was prepared * @param pageId the page where the transaction was prepared
* @param commit if the transaction should be committed * @param commit if the transaction should be committed
*/ */
public void setInDoubtTransactionState(int sessionId, int pageId, boolean commit) { public synchronized void setInDoubtTransactionState(int sessionId, int pageId, boolean commit) {
boolean old = database.isReadOnly(); boolean old = database.isReadOnly();
try { try {
database.setReadOnly(false); database.setReadOnly(false);
...@@ -1742,7 +1742,7 @@ public class PageStore implements CacheWriter { ...@@ -1742,7 +1742,7 @@ public class PageStore implements CacheWriter {
* @return true if it is * @return true if it is
*/ */
public boolean isRecoveryRunning() { public boolean isRecoveryRunning() {
return this.recoveryRunning; return recoveryRunning;
} }
private void checkOpen() { private void checkOpen() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论