提交 1a10f1ea authored 作者: Thomas Mueller's avatar Thomas Mueller

In-memory databases don't write LOBs to files any longer.

上级 c341aeff
...@@ -1895,7 +1895,7 @@ public class Database implements DataHandler { ...@@ -1895,7 +1895,7 @@ public class Database implements DataHandler {
} }
public int getMaxLengthInplaceLob() { public int getMaxLengthInplaceLob() {
return maxLengthInplaceLob; return persistent ? maxLengthInplaceLob : Integer.MAX_VALUE;
} }
public void setIgnoreCase(boolean b) { public void setIgnoreCase(boolean b) {
......
...@@ -158,9 +158,16 @@ public class ValueLob extends Value { ...@@ -158,9 +158,16 @@ public class ValueLob extends Value {
remaining = length; remaining = length;
} }
int len = getBufferSize(handler, compress, remaining); int len = getBufferSize(handler, compress, remaining);
char[] buff = new char[len]; char[] buff;
if (len >= Integer.MAX_VALUE) {
String data = IOUtils.readStringAndClose(in, -1);
buff = data.toCharArray();
len = buff.length;
} else {
buff = new char[len];
len = IOUtils.readFully(in, buff, len); len = IOUtils.readFully(in, buff, len);
len = len < 0 ? 0 : len; len = len < 0 ? 0 : len;
}
if (len <= handler.getMaxLengthInplaceLob()) { if (len <= handler.getMaxLengthInplaceLob()) {
byte[] small = StringUtils.utf8Encode(new String(buff, 0, len)); byte[] small = StringUtils.utf8Encode(new String(buff, 0, len));
return ValueLob.createSmallLob(Value.CLOB, small); return ValueLob.createSmallLob(Value.CLOB, small);
...@@ -342,8 +349,14 @@ public class ValueLob extends Value { ...@@ -342,8 +349,14 @@ public class ValueLob extends Value {
remaining = length; remaining = length;
} }
int len = getBufferSize(handler, compress, remaining); int len = getBufferSize(handler, compress, remaining);
byte[] buff = ByteUtils.newBytes(len); byte[] buff;
if (len >= Integer.MAX_VALUE) {
buff = IOUtils.readBytesAndClose(in, -1);
len = buff.length;
} else {
buff = ByteUtils.newBytes(len);
len = IOUtils.readFully(in, buff, 0, len); len = IOUtils.readFully(in, buff, 0, len);
}
if (len <= handler.getMaxLengthInplaceLob()) { if (len <= handler.getMaxLengthInplaceLob()) {
byte[] small = ByteUtils.newBytes(len); byte[] small = ByteUtils.newBytes(len);
System.arraycopy(buff, 0, small, 0, len); System.arraycopy(buff, 0, small, 0, len);
...@@ -369,7 +382,7 @@ public class ValueLob extends Value { ...@@ -369,7 +382,7 @@ public class ValueLob extends Value {
synchronized (handler) { synchronized (handler) {
if (handler.getLobFilesInDirectories()) { if (handler.getLobFilesInDirectories()) {
objectId = getNewObjectId(handler); objectId = getNewObjectId(handler);
fileName = getFileNamePrefix(handler.getDatabasePath(), objectId) + ".temp.db"; fileName = getFileNamePrefix(handler.getDatabasePath(), objectId) + Constants.SUFFIX_TEMP_FILE;
} else { } else {
objectId = handler.allocateObjectId(false, true); objectId = handler.allocateObjectId(false, true);
fileName = handler.createTempFile(); fileName = handler.createTempFile();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论