提交 31b01cb2 authored 作者: Thomas Mueller's avatar Thomas Mueller

Fix bug in "jdbc:h2:nioMemFS" isRoot() function. Also, the page size was increased to 64 KB.

上级 34f598a3
......@@ -259,12 +259,12 @@ public final class CompressLZF implements Compressor {
* Compress a number of bytes.
*
* @param in the input data
* @param inPos the offset at the input buffer
* @param out the output area
* @param outPos the offset at the output array
* @return the end position
*/
public int compress(ByteBuffer in, byte[] out, int outPos) {
int inPos = in.position();
public int compress(ByteBuffer in, int inPos, byte[] out, int outPos) {
int inLen = in.capacity() - inPos;
if (cachedHashTable == null) {
cachedHashTable = new int[HASH_SIZE];
......
......@@ -194,7 +194,14 @@ public class FilePathNioMem extends FilePath {
return name.equals(getScheme() + ":");
}
private static String getCanonicalPath(String fileName) {
/**
* Get the canonical path of a file (with backslashes replaced with forward
* slashes).
*
* @param fileName the file name
* @return the canonical path
*/
protected static String getCanonicalPath(String fileName) {
fileName = fileName.replace('\\', '/');
int idx = fileName.indexOf(':') + 1;
if (fileName.length() > idx && fileName.charAt(idx) != '/') {
......@@ -229,6 +236,13 @@ class FilePathNioMemLZF extends FilePathNioMem {
return true;
}
@Override
public FilePathNioMem getPath(String path) {
FilePathNioMemLZF p = new FilePathNioMemLZF();
p.name = getCanonicalPath(path);
return p;
}
@Override
public String getScheme() {
return "nioMemLZF";
......@@ -366,7 +380,8 @@ class FileNioMem extends FileBase {
class FileNioMemData {
private static final int CACHE_SIZE = 8;
private static final int BLOCK_SIZE_SHIFT = 10;
private static final int BLOCK_SIZE_SHIFT = 16;
private static final int BLOCK_SIZE = 1 << BLOCK_SIZE_SHIFT;
private static final int BLOCK_SIZE_MASK = BLOCK_SIZE - 1;
private static final CompressLZF LZF = new CompressLZF();
......@@ -508,6 +523,7 @@ class FileNioMemData {
ByteBuffer out = ByteBuffer.allocateDirect(BLOCK_SIZE);
if (d != COMPRESSED_EMPTY_BLOCK) {
synchronized (LZF) {
d.position(0);
CompressLZF.expand(d, out);
}
}
......@@ -523,7 +539,7 @@ class FileNioMemData {
static void compress(ByteBuffer[] data, int page) {
ByteBuffer d = data[page];
synchronized (LZF) {
int len = LZF.compress(d, BUFFER, 0);
int len = LZF.compress(d, 0, BUFFER, 0);
d = ByteBuffer.allocateDirect(len);
d.put(BUFFER, 0, len);
data[page] = d;
......
......@@ -308,7 +308,7 @@ public class TestCompress extends TestBase {
}
ByteBuffer buff = ByteBuffer.wrap(b);
byte[] temp = new byte[100 + b.length * 2];
int compLen = comp.compress(buff, temp, 0);
int compLen = comp.compress(buff, 0, temp, 0);
ByteBuffer test = ByteBuffer.wrap(temp, 0, compLen);
byte[] exp = new byte[b.length];
CompressLZF.expand(test, ByteBuffer.wrap(exp));
......
......@@ -525,6 +525,7 @@ public class TestFileSystem extends TestBase {
FileUtils.delete(s);
}
FileUtils.createDirectories(fsBase + "/test");
assertTrue(FileUtils.exists(fsBase));
FileUtils.delete(fsBase + "/test");
FileUtils.delete(fsBase + "/test2");
assertTrue(FileUtils.createFile(fsBase + "/test"));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论