提交 14111f79 authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting and documentation

上级 12500cfb
...@@ -27,15 +27,18 @@ Change Log ...@@ -27,15 +27,18 @@ Change Log
</li><li>File system abstraction: support replacing existing files using move </li><li>File system abstraction: support replacing existing files using move
(currently not for Windows). (currently not for Windows).
</li><li>The statement "shutdown defrag" now compresses the database (with the MVStore). </li><li>The statement "shutdown defrag" now compresses the database (with the MVStore).
</li><li>The MVStore now automatically shrinks the file in the background if there is no read or write activity. This command can greatly reduce the file size, and is relatively fast,
This might be a bit too aggressive; feedback is welcome! but is not incremental.
</li><li>The MVStore now automatically compacts the store in the background if there is no read or write activity,
which should (after some time; sometimes about one minute) reduce the file size.
This is still work in progress, feedback is welcome!
</li><li>Change default value of PAGE_SIZE from 2048 to 4096 to more closely match most file systems block size </li><li>Change default value of PAGE_SIZE from 2048 to 4096 to more closely match most file systems block size
(PageStore only; the MVStore already used 4096). (PageStore only; the MVStore already used 4096).
</li><li>Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings by the amount of available RAM. Gives a better </li><li>Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings by the amount of available RAM. Gives a better
out of box experience for people with more powerful machines. out of box experience for people with more powerful machines.
</li><li>Handle tabs like 4 spaces in web console, patch by Martin Grajcar </li><li>Handle tabs like 4 spaces in web console, patch by Martin Grajcar.
</li><li>Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in JdbcConnection.java, </li><li>Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in JdbcConnection.java,
patch by BigMichi1 patch by BigMichi1.
</li></ul> </li></ul>
<h2>Version 1.4.180 Beta (2014-07-13)</h2> <h2>Version 1.4.180 Beta (2014-07-13)</h2>
......
...@@ -1767,24 +1767,26 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1767,24 +1767,26 @@ public class JdbcConnection extends TraceObject implements Connection {
* Return an object of this class if possible. * Return an object of this class if possible.
* *
* @param iface the class * @param iface the class
* @return this
*/ */
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException { public <T> T unwrap(Class<T> iface) throws SQLException {
if (isWrapperFor(iface)) { if (isWrapperFor(iface)) {
return (T) this; return (T) this;
} }
throw DbException.getInvalidValueException("iface", iface); throw DbException.getInvalidValueException("iface", iface);
} }
/** /**
* Checks if unwrap can return an object of this class. * Checks if unwrap can return an object of this class.
* *
* @param iface the class * @param iface the class
* @return whether or not the interface is assignable from this class
*/ */
@Override @Override
public boolean isWrapperFor(Class<?> iface) throws SQLException { public boolean isWrapperFor(Class<?> iface) throws SQLException {
return (iface != null && iface.isAssignableFrom(getClass())); return iface != null && iface.isAssignableFrom(getClass());
} }
/** /**
......
...@@ -89,7 +89,7 @@ public class Chunk { ...@@ -89,7 +89,7 @@ public class Chunk {
* When this chunk was created, in milliseconds after the store was created. * When this chunk was created, in milliseconds after the store was created.
*/ */
public long time; public long time;
/** /**
* When this chunk was no longer needed, in milliseconds after the store was * When this chunk was no longer needed, in milliseconds after the store was
* created. After this, the chunk is kept alive for at least half the * created. After this, the chunk is kept alive for at least half the
......
...@@ -969,7 +969,7 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -969,7 +969,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
/** /**
* Get the map id. Please note the map id may be different after compacting * Get the map id. Please note the map id may be different after compacting
* a store. * a store.
* *
* @return the map id * @return the map id
*/ */
public int getId() { public int getId() {
......
...@@ -105,12 +105,12 @@ MVStore: ...@@ -105,12 +105,12 @@ MVStore:
- compact: copy whole pages (without having to open all maps) - compact: copy whole pages (without having to open all maps)
- maybe change the length code to have lower gaps - maybe change the length code to have lower gaps
- test with very low limits (such as: short chunks, small pages) - test with very low limits (such as: short chunks, small pages)
- maybe allow to read beyond the retention time: - maybe allow to read beyond the retention time:
when compacting, move live pages in old chunks when compacting, move live pages in old chunks
to a map (possibly the metadata map) - to a map (possibly the metadata map) -
this requires a change in the compaction code, plus this requires a change in the compaction code, plus
a map lookup when reading old data; also, this a map lookup when reading old data; also, this
old data map needs to be cleaned up somehow; old data map needs to be cleaned up somehow;
maybe using an additional timeout maybe using an additional timeout
*/ */
...@@ -133,7 +133,7 @@ public class MVStore { ...@@ -133,7 +133,7 @@ public class MVStore {
private static final int FORMAT_WRITE = 1; private static final int FORMAT_WRITE = 1;
private static final int FORMAT_READ = 1; private static final int FORMAT_READ = 1;
/** /**
* Used to mark a chunk as free, when it was detected that live bookkeeping * Used to mark a chunk as free, when it was detected that live bookkeeping
* is incorrect. * is incorrect.
...@@ -255,7 +255,7 @@ public class MVStore { ...@@ -255,7 +255,7 @@ public class MVStore {
private int autoCompactFillRate; private int autoCompactFillRate;
private long autoCompactLastFileOpCount; private long autoCompactLastFileOpCount;
private Object compactSync = new Object(); private Object compactSync = new Object();
/** /**
...@@ -848,11 +848,6 @@ public class MVStore { ...@@ -848,11 +848,6 @@ public class MVStore {
} }
return c; return c;
} }
boolean isChunkKnown(long pos) {
int chunkId = DataUtils.getPageChunkId(pos);
return chunks.containsKey(chunkId);
}
private Chunk getChunkIfFound(long pos) { private Chunk getChunkIfFound(long pos) {
int chunkId = DataUtils.getPageChunkId(pos); int chunkId = DataUtils.getPageChunkId(pos);
...@@ -863,7 +858,7 @@ public class MVStore { ...@@ -863,7 +858,7 @@ public class MVStore {
// access (if synchronization on this was forgotten) // access (if synchronization on this was forgotten)
throw DataUtils.newIllegalStateException( throw DataUtils.newIllegalStateException(
DataUtils.ERROR_CHUNK_NOT_FOUND, DataUtils.ERROR_CHUNK_NOT_FOUND,
"Chunk {0} no longer exists", "Chunk {0} no longer exists",
chunkId); chunkId);
} }
String s = meta.get(Chunk.getMetaKey(chunkId)); String s = meta.get(Chunk.getMetaKey(chunkId));
...@@ -1594,7 +1589,7 @@ public class MVStore { ...@@ -1594,7 +1589,7 @@ public class MVStore {
return true; return true;
} }
} }
private ArrayList<Chunk> compactGetOldChunks(int targetFillRate, int write) { private ArrayList<Chunk> compactGetOldChunks(int targetFillRate, int write) {
if (lastChunk == null) { if (lastChunk == null) {
// nothing to do // nothing to do
...@@ -1679,7 +1674,7 @@ public class MVStore { ...@@ -1679,7 +1674,7 @@ public class MVStore {
} }
return old; return old;
} }
private void compactRewrite(ArrayList<Chunk> old) { private void compactRewrite(ArrayList<Chunk> old) {
HashSet<Integer> set = New.hashSet(); HashSet<Integer> set = New.hashSet();
for (Chunk c : old) { for (Chunk c : old) {
...@@ -1708,7 +1703,7 @@ public class MVStore { ...@@ -1708,7 +1703,7 @@ public class MVStore {
commitAndSave(); commitAndSave();
} }
} }
private synchronized void compactFixLive(Chunk chunk) { private synchronized void compactFixLive(Chunk chunk) {
long start = chunk.block * BLOCK_SIZE; long start = chunk.block * BLOCK_SIZE;
int length = chunk.len * BLOCK_SIZE; int length = chunk.len * BLOCK_SIZE;
...@@ -1761,13 +1756,10 @@ public class MVStore { ...@@ -1761,13 +1756,10 @@ public class MVStore {
} }
} }
if (!pendingChanges) { if (!pendingChanges) {
;
new Exception(fileStore.getFileName() + " chunk " + chunk.id + " fix live! " + chunk).printStackTrace(System.out);
// bookkeeping is broken for this chunk: // bookkeeping is broken for this chunk:
// fix it // fix it
registerFreePage(currentVersion, chunk.id, registerFreePage(currentVersion, chunk.id,
chunk.maxLenLive + MARKED_FREE, chunk.maxLenLive + MARKED_FREE,
chunk.pageCountLive + MARKED_FREE); chunk.pageCountLive + MARKED_FREE);
} }
} }
...@@ -1936,7 +1928,7 @@ new Exception(fileStore.getFileName() + " chunk " + chunk.id + " fix live! " + c ...@@ -1936,7 +1928,7 @@ new Exception(fileStore.getFileName() + " chunk " + chunk.id + " fix live! " + c
* while traversing over the entries of a map. * while traversing over the entries of a map.
* <p> * <p>
* This setting is not persisted. * This setting is not persisted.
* *
* @param ms how many milliseconds to retain old chunks (0 to overwrite them * @param ms how many milliseconds to retain old chunks (0 to overwrite them
* as early as possible) * as early as possible)
*/ */
......
...@@ -102,7 +102,7 @@ public class Page { ...@@ -102,7 +102,7 @@ public class Page {
* The array might be larger than needed, to avoid frequent re-sizing. * The array might be larger than needed, to avoid frequent re-sizing.
*/ */
private Page[] childrenPages; private Page[] childrenPages;
/** /**
* Whether the page is an in-memory (not stored, or not yet stored) page, * Whether the page is an in-memory (not stored, or not yet stored) page,
* and it is removed. This is to keep track of pages that concurrently * and it is removed. This is to keep track of pages that concurrently
......
...@@ -1399,7 +1399,8 @@ public class TransactionStore { ...@@ -1399,7 +1399,8 @@ public class TransactionStore {
k = cursor.next(); k = cursor.next();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// TODO this is a bit ugly // TODO this is a bit ugly
if (DataUtils.getErrorCode(e.getMessage()) == DataUtils.ERROR_CHUNK_NOT_FOUND) { if (DataUtils.getErrorCode(e.getMessage()) ==
DataUtils.ERROR_CHUNK_NOT_FOUND) {
cursor = map.cursor(currentKey); cursor = map.cursor(currentKey);
// we (should) get the current key again, // we (should) get the current key again,
// we need to ignore that one // we need to ignore that one
...@@ -1443,7 +1444,7 @@ public class TransactionStore { ...@@ -1443,7 +1444,7 @@ public class TransactionStore {
throw DataUtils.newUnsupportedOperationException( throw DataUtils.newUnsupportedOperationException(
"Removing is not supported"); "Removing is not supported");
} }
}; };
} }
/** /**
...@@ -1469,7 +1470,8 @@ public class TransactionStore { ...@@ -1469,7 +1470,8 @@ public class TransactionStore {
k = cursor.next(); k = cursor.next();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// TODO this is a bit ugly // TODO this is a bit ugly
if (DataUtils.getErrorCode(e.getMessage()) == DataUtils.ERROR_CHUNK_NOT_FOUND) { if (DataUtils.getErrorCode(e.getMessage()) ==
DataUtils.ERROR_CHUNK_NOT_FOUND) {
cursor = map.cursor(currentKey); cursor = map.cursor(currentKey);
// we (should) get the current key again, // we (should) get the current key again,
// we need to ignore that one // we need to ignore that one
......
...@@ -237,7 +237,7 @@ public class TestCompatibility extends TestBase { ...@@ -237,7 +237,7 @@ public class TestCompatibility extends TestBase {
stat.execute("use schema public"); stat.execute("use schema public");
assertResult("PUBLIC", stat, assertResult("PUBLIC", stat,
"select schema()"); "select schema()");
stat.execute("SELECT 1"); stat.execute("SELECT 1");
stat.execute("DROP TABLE IF EXISTS TEST"); stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
......
...@@ -60,7 +60,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -60,7 +60,7 @@ public class TestConcurrent extends TestMVStore {
testConcurrentWrite(); testConcurrentWrite();
testConcurrentRead(); testConcurrentRead();
} }
private void testConcurrentAutoCommitAndChange() throws InterruptedException { private void testConcurrentAutoCommitAndChange() throws InterruptedException {
String fileName = "memFS:testConcurrentChangeAndBackgroundCompact"; String fileName = "memFS:testConcurrentChangeAndBackgroundCompact";
FileUtils.delete(fileName); FileUtils.delete(fileName);
...@@ -102,10 +102,10 @@ public class TestConcurrent extends TestMVStore { ...@@ -102,10 +102,10 @@ public class TestConcurrent extends TestMVStore {
assertEquals(10 * i, dataMap.get(i).intValue()); assertEquals(10 * i, dataMap.get(i).intValue());
} }
} finally { } finally {
s.close(); s.close();
} }
} }
private void testConcurrentReplaceAndRead() throws InterruptedException { private void testConcurrentReplaceAndRead() throws InterruptedException {
final MVStore s = new MVStore.Builder().open(); final MVStore s = new MVStore.Builder().open();
final MVMap<Integer, Integer> map = s.openMap("data"); final MVMap<Integer, Integer> map = s.openMap("data");
...@@ -133,7 +133,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -133,7 +133,7 @@ public class TestConcurrent extends TestMVStore {
task.get(); task.get();
s.close(); s.close();
} }
private void testConcurrentChangeAndCompact() throws InterruptedException { private void testConcurrentChangeAndCompact() throws InterruptedException {
String fileName = "memFS:testConcurrentChangeAndBackgroundCompact"; String fileName = "memFS:testConcurrentChangeAndBackgroundCompact";
FileUtils.delete(fileName); FileUtils.delete(fileName);
...@@ -163,7 +163,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -163,7 +163,7 @@ public class TestConcurrent extends TestMVStore {
Thread.sleep(1); Thread.sleep(1);
for (int i = 0; !task.isFinished() && !task2.isFinished() && i < 1000; i++) { for (int i = 0; !task.isFinished() && !task2.isFinished() && i < 1000; i++) {
MVMap<Integer, Integer> map = s.openMap("d" + (i % 3)); MVMap<Integer, Integer> map = s.openMap("d" + (i % 3));
// MVMap<Integer, Integer> map = s.openMap("d" + (i % 3), // MVMap<Integer, Integer> map = s.openMap("d" + (i % 3),
// new MVMapConcurrent.Builder<Integer, Integer>()); // new MVMapConcurrent.Builder<Integer, Integer>());
map.put(0, i); map.put(0, i);
map.get(0); map.get(0);
......
...@@ -79,19 +79,22 @@ public class TestMVTableEngine extends TestBase { ...@@ -79,19 +79,22 @@ public class TestMVTableEngine extends TestBase {
testLocking(); testLocking();
testSimple(); testSimple();
} }
private void testLowRetentionTime() throws SQLException { private void testLowRetentionTime() throws SQLException {
deleteDb("testLowRetentionTime"); deleteDb("testLowRetentionTime");
Connection conn = getConnection("testLowRetentionTime;RETENTION_TIME=10;WRITE_DELAY=10"); Connection conn = getConnection(
"testLowRetentionTime;RETENTION_TIME=10;WRITE_DELAY=10");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
Connection conn2 = getConnection("testLowRetentionTime"); Connection conn2 = getConnection("testLowRetentionTime");
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
stat.execute("create alias sleep as $$void sleep(int ms) throws Exception { Thread.sleep(ms); }$$"); stat.execute("create alias sleep as " +
stat.execute("create table test(id identity, name varchar) as select x, 'Init' from system_range(0, 1999)"); "$$void sleep(int ms) throws Exception { Thread.sleep(ms); }$$");
stat.execute("create table test(id identity, name varchar) " +
"as select x, 'Init' from system_range(0, 1999)");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
stat.execute("insert into test values(null, 'Hello')"); stat.execute("insert into test values(null, 'Hello')");
// create and delete a large table: this will force compaction // create and delete a large table: this will force compaction
stat.execute("create table temp(id identity, name varchar) as " + stat.execute("create table temp(id identity, name varchar) as " +
"select x, space(1000000) from system_range(0, 10)"); "select x, space(1000000) from system_range(0, 10)");
stat.execute("drop table temp"); stat.execute("drop table temp");
} }
......
...@@ -761,4 +761,4 @@ reinstated uninteresting dead defendant doctrines beat factual fair suspended ...@@ -761,4 +761,4 @@ reinstated uninteresting dead defendant doctrines beat factual fair suspended
exploit noise ongoing disclaimers shrinks remedy party desirable timely construe exploit noise ongoing disclaimers shrinks remedy party desirable timely construe
deque synchronizers affero kevent nikolaj hohmuth grajcar jens fogh hostnames deque synchronizers affero kevent nikolaj hohmuth grajcar jens fogh hostnames
operate resized jni yjp ownable starvation reaper biased introduce epoll hangs operate resized jni yjp ownable starvation reaper biased introduce epoll hangs
compaction aggressive powerful compaction aggressive powerful traversing pietrzak michi karl
...@@ -24,32 +24,32 @@ public class ThreadDumpCleaner { ...@@ -24,32 +24,32 @@ public class ThreadDumpCleaner {
private static final String[] PATTERN = { private static final String[] PATTERN = {
"\\$\\$YJP\\$\\$", "\\$\\$YJP\\$\\$",
"\"(Attach|Service|VM|GC|DestroyJavaVM|Signal|AWT|AppKit|C2 |Low Mem|" + "\"(Attach|Service|VM|GC|DestroyJavaVM|Signal|AWT|AppKit|C2 |Low Mem|" +
"process reaper|YJPAgent-).*?\"(?s).*?\n\n", "process reaper|YJPAgent-).*?\"(?s).*?\n\n",
" Locked ownable synchronizers:(?s).*?\n\n", " Locked ownable synchronizers:(?s).*?\n\n",
"\".*?\".*?\n java.lang.Thread.State: (TIMED_)?WAITING(?s).*?\n\n", "\".*?\".*?\n java.lang.Thread.State: (TIMED_)?WAITING(?s).*?\n\n",
"\".*?\".*?\n java.lang.Thread.State:.*\n\t" + "\".*?\".*?\n java.lang.Thread.State:.*\n\t" +
"at sun.nio.ch.KQueueArrayWrapper.kevent0(?s).*?\n\n", "at sun.nio.ch.KQueueArrayWrapper.kevent0(?s).*?\n\n",
"\".*?\".*?\n java.lang.Thread.State:.*\n\t" + "\".*?\".*?\n java.lang.Thread.State:.*\n\t" +
"at java.io.FileInputStream.readBytes(?s).*?\n\n", "at java.io.FileInputStream.readBytes(?s).*?\n\n",
"\".*?\".*?\n java.lang.Thread.State:.*\n\t" + "\".*?\".*?\n java.lang.Thread.State:.*\n\t" +
"at sun.nio.ch.ServerSocketChannelImpl.accept(?s).*?\n\n", "at sun.nio.ch.ServerSocketChannelImpl.accept(?s).*?\n\n",
"\".*?\".*?\n java.lang.Thread.State:.*\n\t" + "\".*?\".*?\n java.lang.Thread.State:.*\n\t" +
"at sun.nio.ch.EPollArrayWrapper.epollWait(?s).*?\n\n", "at sun.nio.ch.EPollArrayWrapper.epollWait(?s).*?\n\n",
"\".*?\".*?\n java.lang.Thread.State:.*\n\t" + "\".*?\".*?\n java.lang.Thread.State:.*\n\t" +
"at java.lang.Object.wait(?s).*?\n\n", "at java.lang.Object.wait(?s).*?\n\n",
"\".*?\".*?\n java.lang.Thread.State:.*\n\t" + "\".*?\".*?\n java.lang.Thread.State:.*\n\t" +
"at java.net.PlainSocketImpl.socketAccept(?s).*?\n\n", "at java.net.PlainSocketImpl.socketAccept(?s).*?\n\n",
"JNI global references:.*\n\n", "JNI global references:.*\n\n",
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论