提交 9ca551f6 authored 作者: andrei's avatar andrei

Merge branch 'free_space_bs' into mv_nb

# Conflicts:
#	h2/src/main/org/h2/mvstore/FreeSpaceBitSet.java
#	h2/src/main/org/h2/mvstore/MVStore.java
...@@ -54,12 +54,12 @@ public class FileStore { ...@@ -54,12 +54,12 @@ public class FileStore {
/** /**
* The file name. * The file name.
*/ */
protected String fileName; private String fileName;
/** /**
* Whether this store is read-only. * Whether this store is read-only.
*/ */
protected boolean readOnly; private boolean readOnly;
/** /**
* The file size (cached). * The file size (cached).
...@@ -69,7 +69,7 @@ public class FileStore { ...@@ -69,7 +69,7 @@ public class FileStore {
/** /**
* The file. * The file.
*/ */
protected FileChannel file; private FileChannel file;
/** /**
* The encrypted file (if encryption is used). * The encrypted file (if encryption is used).
......
...@@ -113,6 +113,8 @@ public class FreeSpaceBitSet { ...@@ -113,6 +113,8 @@ public class FreeSpaceBitSet {
int start = set.nextClearBit(i); int start = set.nextClearBit(i);
int end = set.nextSetBit(start + 1); int end = set.nextSetBit(start + 1);
if (end < 0 || end - start >= blocks) { if (end < 0 || end - start >= blocks) {
assert set.nextSetBit(start) == -1 || set.nextSetBit(start) >= start + blocks :
"Double alloc: " + Integer.toHexString(start) + "/" + Integer.toHexString(blocks) + " " + this;
if (allocate) { if (allocate) {
set.set(start, start + blocks); set.set(start, start + blocks);
} }
...@@ -132,7 +134,7 @@ public class FreeSpaceBitSet { ...@@ -132,7 +134,7 @@ public class FreeSpaceBitSet {
int start = getBlock(pos); int start = getBlock(pos);
int blocks = getBlockCount(length); int blocks = getBlockCount(length);
assert set.nextSetBit(start) == -1 || set.nextSetBit(start) >= start + blocks : assert set.nextSetBit(start) == -1 || set.nextSetBit(start) >= start + blocks :
start + "/" + blocks + " " + this; "Double mark: " + Integer.toHexString(start) + "/" + Integer.toHexString(blocks) + " " + this;
set.set(start, start + blocks); set.set(start, start + blocks);
} }
...@@ -145,7 +147,8 @@ public class FreeSpaceBitSet { ...@@ -145,7 +147,8 @@ public class FreeSpaceBitSet {
public void free(long pos, int length) { public void free(long pos, int length) {
int start = getBlock(pos); int start = getBlock(pos);
int blocks = getBlockCount(length); int blocks = getBlockCount(length);
assert set.nextClearBit(start) >= start + blocks : start + "/" + blocks + " " + this; assert set.nextClearBit(start) >= start + blocks :
"Double free: " + Integer.toHexString(start) + "/" + Integer.toHexString(blocks) + " " + this;
set.clear(start, start + blocks); set.clear(start, start + blocks);
} }
......
...@@ -738,6 +738,8 @@ public final class MVStore { ...@@ -738,6 +738,8 @@ public final class MVStore {
if (lastStoredVersion == INITIAL_VERSION) { if (lastStoredVersion == INITIAL_VERSION) {
lastStoredVersion = currentVersion - 1; lastStoredVersion = currentVersion - 1;
} }
assert fileStore.getFileLengthInUse() == measureFileLengthInUse() :
fileStore.getFileLengthInUse() + " != " + measureFileLengthInUse();
} }
private void loadChunkMeta() { private void loadChunkMeta() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论