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

MVStore file format documentation.

上级 5e3a0621
...@@ -510,23 +510,20 @@ s.close(); ...@@ -510,23 +510,20 @@ s.close();
will result in the following two chunks (excluding metadata): will result in the following two chunks (excluding metadata):
</p> </p>
<p> <p>
<b>Chunk 1:</b> <b>Chunk 1:</b><br />
- Page 1: leaf with 140 entries (keys 0 - 139)<br />
- Page 2: leaf with 260 entries (keys 140 - 399)<br />
- Page 3: (root) node with 2 entries pointing to page 1 and 2<br />
</p> </p>
<ul><li>Page 1: leaf with 140 entries (keys 0 - 139)
</li><li>Page 2: leaf with 260 entries (keys 140 - 399)
</li><li>Page 3: node with 2 entries pointing to page 1 and 2 (the root)
</li></ul>
<p> <p>
<b>Chunk 2:</b> <b>Chunk 2:</b><br />
- Page 4: leaf with 140 entries (keys 0 - 139)<br />
- Page 5: (root) node with 2 entries pointing to page 4 and 2<br />
</p> </p>
<ul><li>Page 4: leaf with 140 entries (keys 0 - 139)
</li><li>Page 5: node with 2 entries pointing to page 4 and 1 (the root)
</li></ul>
<p> <p>
That means each chunk contains the changes of one version, That means each chunk contains the changes of one version:
that means the new version of the changed pages and the parent pages, the new version of the changed pages and the parent pages, recursively, up to the root page.
recursively, up to the root page. Pages in subsequent chunks refer to Pages in subsequent chunks refer to pages in earlier chunks.
pages in earlier chunks.
</p> </p>
<h3>File Header</h3> <h3>File Header</h3>
......
...@@ -657,13 +657,13 @@ public class MVStore { ...@@ -657,13 +657,13 @@ public class MVStore {
* @return the chunk, or null if not successful * @return the chunk, or null if not successful
*/ */
private Chunk readChunkFooter(long end) { private Chunk readChunkFooter(long end) {
// read the chunk footer of the last block of the file
ByteBuffer lastBlock = fileStore.readFully(
end - Chunk.FOOTER_LENGTH, Chunk.FOOTER_LENGTH);
byte[] buff = new byte[Chunk.FOOTER_LENGTH];
lastBlock.get(buff);
// the following can fail for various reasons // the following can fail for various reasons
try { try {
// read the chunk footer of the last block of the file
ByteBuffer lastBlock = fileStore.readFully(
end - Chunk.FOOTER_LENGTH, Chunk.FOOTER_LENGTH);
byte[] buff = new byte[Chunk.FOOTER_LENGTH];
lastBlock.get(buff);
String s = new String(buff, DataUtils.LATIN).trim(); String s = new String(buff, DataUtils.LATIN).trim();
HashMap<String, String> m = DataUtils.parseMap(s); HashMap<String, String> m = DataUtils.parseMap(s);
int check = DataUtils.readHexInt(m, "fletcher", 0); int check = DataUtils.readHexInt(m, "fletcher", 0);
......
...@@ -299,5 +299,10 @@ class FileUnstable extends FileBase { ...@@ -299,5 +299,10 @@ class FileUnstable extends FileBase {
public synchronized FileLock tryLock(long position, long size, boolean shared) throws IOException { public synchronized FileLock tryLock(long position, long size, boolean shared) throws IOException {
return channel.tryLock(position, size, shared); return channel.tryLock(position, size, shared);
} }
@Override
public String toString() {
return "unstable:" + file.toString();
}
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论