提交 9a695218 authored 作者: Thomas Mueller's avatar Thomas Mueller

New system properties h2.maxCompactCount and h2.maxCompactTime

上级 8d64639e
......@@ -311,6 +311,19 @@ public class SysProperties {
*/
public static final String LOG_ALL_ERRORS_FILE = getStringSetting("h2.logAllErrorsFile", "h2errors.txt");
/**
* System property <code>h2.maxCompactCount</code>
* (default: Integer.MAX_VALUE).<br />
* The maximum number of pages to move when closing a database.
*/
public static final int MAX_COMPACT_COUNT = getIntSetting("h2.maxCompactCount", Integer.MAX_VALUE);
/**
* System property <code>h2.maxCompactTime</code> (default: 1000).<br />
* The maximum time in milliseconds used to compact a database when closing.
*/
public static final int MAX_COMPACT_TIME = getIntSetting("h2.maxCompactTime", 1000);
/**
* System property <code>h2.maxFileRetry</code> (default: 16).<br />
* Number of times to retry file delete and rename. in Windows, files can't
......
......@@ -113,6 +113,8 @@ public class PageStore implements CacheWriter {
// remove Database.objectIds
// remove TableData.checkRowCount
// remove Row.setPos
// remove database URL option RECOVER=1 option
// remove old database URL options and documentation
/**
* The smallest possible page size.
......@@ -143,9 +145,6 @@ public class PageStore implements CacheWriter {
private static final int META_TYPE_BTREE_INDEX = 1;
private static final int META_TABLE_ID = -1;
private static final int MAX_COMPACT_TIME = 2000;
private static final int MAX_COMPACT_COUNT = Integer.MAX_VALUE;
private static final SearchRow[] EMPTY_SEARCH_ROW = new SearchRow[0];
private Database database;
......@@ -352,8 +351,10 @@ public class PageStore implements CacheWriter {
/**
* Shrink the file so there are no empty pages at the end.
*
* @param fully if the database should be fully compressed
*/
public void trim() throws SQLException {
public void compact(boolean fully) throws SQLException {
if (!SysProperties.PAGE_STORE_TRIM) {
return;
}
......@@ -378,8 +379,12 @@ public class PageStore implements CacheWriter {
recoveryRunning = false;
}
long start = System.currentTimeMillis();
int maxCompactTime = MAX_COMPACT_TIME;
int maxMove = MAX_COMPACT_COUNT;
int maxCompactTime = SysProperties.MAX_COMPACT_TIME;
int maxMove = SysProperties.MAX_COMPACT_COUNT;
if (fully) {
maxCompactTime = Integer.MAX_VALUE;
maxMove = Integer.MAX_VALUE;
}
for (int x = lastUsed, j = 0; x > MIN_PAGE_COUNT && j < maxMove; x--, j++) {
compact(x);
long now = System.currentTimeMillis();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论