Unverified 提交 771b643c authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #1240 from grandinj/optimise_lob_comparison

Optimise ValueLobDB comparison methods
...@@ -311,8 +311,14 @@ public class ValueLobDb extends Value { ...@@ -311,8 +311,14 @@ public class ValueLobDb extends Value {
// convert hex to string // convert hex to string
return super.getBytes(); return super.getBytes();
} }
byte[] data = getBytesNoCopy(); if (small != null) {
return Utils.cloneByteArray(data); return Utils.cloneByteArray(small);
}
try {
return IOUtils.readBytesAndClose(getInputStream(), Integer.MAX_VALUE);
} catch (IOException e) {
throw DbException.convertIOException(e, toString());
}
} }
@Override @Override
...@@ -342,7 +348,11 @@ public class ValueLobDb extends Value { ...@@ -342,7 +348,11 @@ public class ValueLobDb extends Value {
if (valueType == CLOB) { if (valueType == CLOB) {
hash = getString().hashCode(); hash = getString().hashCode();
} else { } else {
hash = Utils.getByteArrayHash(getBytes()); if (small != null) {
hash = Utils.getByteArrayHash(small);
} else {
hash = Utils.getByteArrayHash(getBytes());
}
} }
} }
return hash; return hash;
...@@ -484,7 +494,12 @@ public class ValueLobDb extends Value { ...@@ -484,7 +494,12 @@ public class ValueLobDb extends Value {
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
return other instanceof ValueLobDb && compareSecure((Value) other, null) == 0; if (!(other instanceof ValueLobDb))
return false;
ValueLobDb otherLob = (ValueLobDb) other;
if (hashCode() != otherLob.hashCode())
return false;
return compareSecure((Value) other, null) == 0;
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论