提交 7a86246f authored 作者: Andrei Tokar's avatar Andrei Tokar

Streamline last chunk verification on startup

上级 4ce2a984
...@@ -751,13 +751,9 @@ public class MVStore { ...@@ -751,13 +751,9 @@ public class MVStore {
private void loadChunkMeta() { private void loadChunkMeta() {
// load the chunk metadata: we can load in any order, // load the chunk metadata: we can load in any order,
// because loading chunk metadata might recursively load another chunk // because loading chunk metadata might recursively load another chunk
for (Iterator<String> it = meta.keyIterator("chunk."); it.hasNext();) { Cursor<String, String> cursor = meta.cursor("chunk.");
String s = it.next(); while (cursor.hasNext() && cursor.next().startsWith("chunk.")) {
if (!s.startsWith("chunk.")) { Chunk c = Chunk.fromString(cursor.getValue());
break;
}
s = meta.get(s);
Chunk c = Chunk.fromString(s);
if (c.version < lastChunk.version) { if (c.version < lastChunk.version) {
if (chunks.putIfAbsent(c.id, c) == null) { if (chunks.putIfAbsent(c.id, c) == null) {
if (c.block == Long.MAX_VALUE) { if (c.block == Long.MAX_VALUE) {
...@@ -808,15 +804,11 @@ public class MVStore { ...@@ -808,15 +804,11 @@ public class MVStore {
validIds.set(c.id); validIds.set(c.id);
try { try {
MVMap<String, String> oldMeta = meta.openReadOnly(c.metaRootPos, c.version); Cursor<String, Object> cursor = new Cursor<>(readPage(meta, c.metaRootPos), "chunk.");
boolean valid = true; boolean valid = true;
for(Iterator<String> iter = oldMeta.keyIterator("chunk."); valid && iter.hasNext(); ) { String key;
String s = iter.next(); while (valid && cursor.hasNext() && (key = cursor.next()).startsWith("chunk.")) {
if (!s.startsWith("chunk.")) { valid = validIds.get((int) Long.parseLong(key.substring("chunk.".length()), 16));
break;
}
s = oldMeta.get(s);
valid = validIds.get(Chunk.fromString(s).id);
} }
if (valid) { if (valid) {
newestValidChunk = c.id; newestValidChunk = c.id;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论