提交 a4f34782 authored 作者: Thomas Mueller's avatar Thomas Mueller

Delayed array allocation.

上级 5a524835
...@@ -69,7 +69,7 @@ public class LobStorage { ...@@ -69,7 +69,7 @@ public class LobStorage {
private HashMap<String, PreparedStatement> prepared = New.hashMap(); private HashMap<String, PreparedStatement> prepared = New.hashMap();
private long nextBlock; private long nextBlock;
private CompressTool compress = CompressTool.getInstance(); private CompressTool compress = CompressTool.getInstance();
private long[] hashBlocks = new long[HASH_CACHE_SIZE * 2]; private long[] hashBlocks;
private final DataHandler handler; private final DataHandler handler;
private boolean init; private boolean init;
...@@ -620,6 +620,7 @@ public class LobStorage { ...@@ -620,6 +620,7 @@ public class LobStorage {
private long getHashCacheBlock(int hash) { private long getHashCacheBlock(int hash) {
if (HASH_CACHE_SIZE > 0) { if (HASH_CACHE_SIZE > 0) {
initHashCache();
int index = hash & (HASH_CACHE_SIZE - 1); int index = hash & (HASH_CACHE_SIZE - 1);
long oldHash = hashBlocks[index]; long oldHash = hashBlocks[index];
if (oldHash == hash) { if (oldHash == hash) {
...@@ -631,12 +632,19 @@ public class LobStorage { ...@@ -631,12 +632,19 @@ public class LobStorage {
private void setHashCacheBlock(int hash, long block) { private void setHashCacheBlock(int hash, long block) {
if (HASH_CACHE_SIZE > 0) { if (HASH_CACHE_SIZE > 0) {
initHashCache();
int index = hash & (HASH_CACHE_SIZE - 1); int index = hash & (HASH_CACHE_SIZE - 1);
hashBlocks[index] = hash; hashBlocks[index] = hash;
hashBlocks[index + HASH_CACHE_SIZE] = block; hashBlocks[index + HASH_CACHE_SIZE] = block;
} }
} }
private void initHashCache() {
if (hashBlocks == null) {
hashBlocks = new long[HASH_CACHE_SIZE * 2];
}
}
/** /**
* Store a block in the LOB storage. * Store a block in the LOB storage.
* *
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论