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

Delayed array allocation.

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