|
|
@@ -144,8 +144,8 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
void setPackIndex(PackIndex idx) { |
|
|
|
long objCnt = idx.getObjectCount(); |
|
|
|
int recSize = Constants.OBJECT_ID_LENGTH + 8; |
|
|
|
int sz = (int) Math.min(objCnt * recSize, Integer.MAX_VALUE); |
|
|
|
index = cache.put(desc.getStreamKey(INDEX), 0, sz, idx); |
|
|
|
long sz = objCnt * recSize; |
|
|
|
index = cache.putRef(desc.getStreamKey(INDEX), sz, idx); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -184,6 +184,16 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
return idx; |
|
|
|
} |
|
|
|
|
|
|
|
DfsStreamKey idxKey = desc.getStreamKey(INDEX); |
|
|
|
idxref = cache.getRef(idxKey); |
|
|
|
if (idxref != null) { |
|
|
|
PackIndex idx = idxref.get(); |
|
|
|
if (idx != null) { |
|
|
|
index = idxref; |
|
|
|
return idx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PackIndex idx; |
|
|
|
try { |
|
|
|
ctx.stats.readIdx++; |
|
|
@@ -205,18 +215,14 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
} |
|
|
|
} catch (EOFException e) { |
|
|
|
invalid = true; |
|
|
|
IOException e2 = new IOException(MessageFormat.format( |
|
|
|
throw new IOException(MessageFormat.format( |
|
|
|
DfsText.get().shortReadOfIndex, |
|
|
|
desc.getFileName(INDEX))); |
|
|
|
e2.initCause(e); |
|
|
|
throw e2; |
|
|
|
desc.getFileName(INDEX)), e); |
|
|
|
} catch (IOException e) { |
|
|
|
invalid = true; |
|
|
|
IOException e2 = new IOException(MessageFormat.format( |
|
|
|
throw new IOException(MessageFormat.format( |
|
|
|
DfsText.get().cannotReadIndex, |
|
|
|
desc.getFileName(INDEX))); |
|
|
|
e2.initCause(e); |
|
|
|
throw e2; |
|
|
|
desc.getFileName(INDEX)), e); |
|
|
|
} |
|
|
|
|
|
|
|
setPackIndex(idx); |
|
|
@@ -229,8 +235,9 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
} |
|
|
|
|
|
|
|
PackBitmapIndex getBitmapIndex(DfsReader ctx) throws IOException { |
|
|
|
if (invalid || isGarbage()) |
|
|
|
if (invalid || isGarbage() || !desc.hasFileExt(BITMAP_INDEX)) |
|
|
|
return null; |
|
|
|
|
|
|
|
DfsBlockCache.Ref<PackBitmapIndex> idxref = bitmapIndex; |
|
|
|
if (idxref != null) { |
|
|
|
PackBitmapIndex idx = idxref.get(); |
|
|
@@ -238,9 +245,6 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
return idx; |
|
|
|
} |
|
|
|
|
|
|
|
if (!desc.hasFileExt(BITMAP_INDEX)) |
|
|
|
return null; |
|
|
|
|
|
|
|
synchronized (initLock) { |
|
|
|
idxref = bitmapIndex; |
|
|
|
if (idxref != null) { |
|
|
@@ -249,6 +253,16 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
return idx; |
|
|
|
} |
|
|
|
|
|
|
|
DfsStreamKey bitmapKey = desc.getStreamKey(BITMAP_INDEX); |
|
|
|
idxref = cache.getRef(bitmapKey); |
|
|
|
if (idxref != null) { |
|
|
|
PackBitmapIndex idx = idxref.get(); |
|
|
|
if (idx != null) { |
|
|
|
bitmapIndex = idxref; |
|
|
|
return idx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
long size; |
|
|
|
PackBitmapIndex idx; |
|
|
|
try { |
|
|
@@ -273,22 +287,16 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
ctx.stats.readIdxMicros += elapsedMicros(start); |
|
|
|
} |
|
|
|
} catch (EOFException e) { |
|
|
|
IOException e2 = new IOException(MessageFormat.format( |
|
|
|
throw new IOException(MessageFormat.format( |
|
|
|
DfsText.get().shortReadOfIndex, |
|
|
|
desc.getFileName(BITMAP_INDEX))); |
|
|
|
e2.initCause(e); |
|
|
|
throw e2; |
|
|
|
desc.getFileName(BITMAP_INDEX)), e); |
|
|
|
} catch (IOException e) { |
|
|
|
IOException e2 = new IOException(MessageFormat.format( |
|
|
|
throw new IOException(MessageFormat.format( |
|
|
|
DfsText.get().cannotReadIndex, |
|
|
|
desc.getFileName(BITMAP_INDEX))); |
|
|
|
e2.initCause(e); |
|
|
|
throw e2; |
|
|
|
desc.getFileName(BITMAP_INDEX)), e); |
|
|
|
} |
|
|
|
|
|
|
|
bitmapIndex = cache.put( |
|
|
|
desc.getStreamKey(BITMAP_INDEX), |
|
|
|
0, (int) Math.min(size, Integer.MAX_VALUE), idx); |
|
|
|
bitmapIndex = cache.putRef(bitmapKey, size, idx); |
|
|
|
return idx; |
|
|
|
} |
|
|
|
} |
|
|
@@ -309,13 +317,21 @@ public final class DfsPackFile extends BlockBasedFile { |
|
|
|
return revidx; |
|
|
|
} |
|
|
|
|
|
|
|
DfsStreamKey revKey = |
|
|
|
new DfsStreamKey.ForReverseIndex(desc.getStreamKey(INDEX)); |
|
|
|
revref = cache.getRef(revKey); |
|
|
|
if (revref != null) { |
|
|
|
PackReverseIndex idx = revref.get(); |
|
|
|
if (idx != null) { |
|
|
|
reverseIndex = revref; |
|
|
|
return idx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PackIndex idx = idx(ctx); |
|
|
|
PackReverseIndex revidx = new PackReverseIndex(idx); |
|
|
|
int sz = (int) Math.min( |
|
|
|
idx.getObjectCount() * 8, Integer.MAX_VALUE); |
|
|
|
reverseIndex = cache.put( |
|
|
|
new DfsStreamKey.ForReverseIndex(desc.getStreamKey(INDEX)), |
|
|
|
0, sz, revidx); |
|
|
|
long cnt = idx.getObjectCount(); |
|
|
|
reverseIndex = cache.putRef(revKey, cnt * 8, revidx); |
|
|
|
return revidx; |
|
|
|
} |
|
|
|
} |