提交 b8a04500 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

MVStore CLOB and BLOB larger than about 25 MB: An exception could be thrown

上级 7014d46a
......@@ -21,7 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>-
<li>MVStore CLOB and BLOB larger than about 25 MB: An exception could be thrown
when using the MVStore storage.
</li>
</ul>
......
......@@ -264,9 +264,13 @@ public class StreamStore {
// indirect: 2, total len (long), blockId (long)
DataUtils.readVarLong(idBuffer);
long k2 = DataUtils.readVarLong(idBuffer);
// recurse
maxKey = k2;
byte[] r = map.get(k2);
maxKey = Math.max(maxKey, getMaxBlockKey(r));
// recurse
long m = getMaxBlockKey(r);
if (m >= 0) {
maxKey = Math.max(maxKey, m);
}
break;
default:
throw DataUtils.newIllegalArgumentException(
......
......@@ -13,6 +13,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
import org.h2.mvstore.DataUtils;
......@@ -41,6 +42,7 @@ public class TestStreamStore extends TestBase {
@Override
public void test() throws IOException {
testMaxBlockKey();
testIOException();
testSaveCount();
testExceptionDuringStore();
......@@ -54,6 +56,23 @@ public class TestStreamStore extends TestBase {
testLoop();
}
private void testMaxBlockKey() throws IOException {
TreeMap<Long, byte[]> map = new TreeMap<Long, byte[]>();
StreamStore s = new StreamStore(map);
s.setMaxBlockSize(128);
s.setMinBlockSize(64);
map.clear();
for (int len = 1; len < 1024 * 1024; len *= 2) {
byte[] id = s.put(new ByteArrayInputStream(new byte[len]));
long max = s.getMaxBlockKey(id);
if (max == -1) {
assertTrue(map.isEmpty());
} else {
assertEquals(map.lastKey(), max);
}
}
}
private void testIOException() throws IOException {
HashMap<Long, byte[]> map = New.hashMap();
StreamStore s = new StreamStore(map);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论