public final class DfsPackFile extends BlockBasedFile
Modifier and Type | Class and Description |
---|---|
private static class |
DfsPackFile.Delta |
Modifier and Type | Field and Description |
---|---|
private PackBitmapIndex |
bitmapIndex
Index of compressed bitmap mapping entire object graph.
|
private LongList |
corruptObjects
Objects we have tried to read, and discovered to be corrupt.
|
private PackIndex |
index
Index mapping
ObjectId to position within the pack stream. |
private java.lang.Object |
initLock
Lock for initialization of
index and corruptObjects . |
private static int |
REC_SIZE |
private PackReverseIndex |
reverseIndex
|
blockSize, cache, desc, ext, invalid, invalidatingCause, key, length
Constructor and Description |
---|
DfsPackFile(DfsBlockCache cache,
DfsPackDescription desc)
Construct a reader for an existing, packfile.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
copyAsIs(PackOutputStream out,
DfsObjectToPack src,
boolean validate,
DfsReader ctx) |
(package private) void |
copyPackAsIs(PackOutputStream out,
DfsReader ctx) |
private long |
copyPackBypassCache(PackOutputStream out,
ReadableChannel rc) |
private void |
copyPackThroughCache(PackOutputStream out,
DfsReader ctx,
ReadableChannel rc) |
private byte[] |
decompress(long position,
int sz,
DfsReader ctx) |
private long |
findDeltaBase(DfsReader ctx,
ObjectId baseId) |
(package private) long |
findOffset(DfsReader ctx,
AnyObjectId id) |
(package private) ObjectLoader |
get(DfsReader ctx,
AnyObjectId id)
Get an object from this pack.
|
(package private) PackBitmapIndex |
getBitmapIndex(DfsReader ctx) |
(package private) byte[] |
getDeltaHeader(DfsReader wc,
long pos) |
(package private) long |
getObjectCount(DfsReader ctx)
Obtain the total number of objects available in this pack.
|
(package private) long |
getObjectSize(DfsReader ctx,
AnyObjectId id) |
(package private) long |
getObjectSize(DfsReader ctx,
long pos) |
(package private) int |
getObjectType(DfsReader ctx,
long pos) |
DfsPackDescription |
getPackDescription()
Get description that was originally used to configure this pack file.
|
PackIndex |
getPackIndex(DfsReader ctx)
Get the PackIndex for this PackFile.
|
(package private) PackReverseIndex |
getReverseIdx(DfsReader ctx) |
boolean |
hasObject(DfsReader ctx,
AnyObjectId id)
Check if an object is stored within this pack.
|
private PackIndex |
idx(DfsReader ctx) |
(package private) boolean |
isCorrupt(long offset) |
(package private) boolean |
isGarbage() |
boolean |
isIndexLoaded()
Whether the pack index file is loaded and cached in memory.
|
(package private) ObjectLoader |
load(DfsReader ctx,
long pos) |
private java.nio.ByteBuffer |
newCopyBuffer(PackOutputStream out,
ReadableChannel rc) |
private java.io.IOException |
packfileIsTruncated() |
private void |
readFully(long position,
byte[] dstbuf,
int dstoff,
int cnt,
DfsReader ctx) |
(package private) void |
representation(DfsObjectRepresentation r,
long pos,
DfsReader ctx,
PackReverseIndex rev) |
(package private) void |
resolve(DfsReader ctx,
java.util.Set<ObjectId> matches,
AbbreviatedObjectId id,
int matchLimit) |
private void |
setCorrupt(long offset) |
(package private) void |
setPackIndex(PackIndex idx) |
alignToBlock, blockSize, elapsedMicros, getFileName, getOrLoadBlock, invalid, read, readOneBlock, setBlockSize, setInvalid
private static final int REC_SIZE
private final java.lang.Object initLock
index
and corruptObjects
.
This lock ensures only one thread can perform the initialization work.
private volatile PackReverseIndex reverseIndex
private volatile PackBitmapIndex bitmapIndex
private volatile LongList corruptObjects
The list is allocated after the first corruption is found, and filled in as more entries are discovered. Typically this list is never used, as pack files do not usually contain corrupt objects.
DfsPackFile(DfsBlockCache cache, DfsPackDescription desc)
cache
- cache that owns the pack data.desc
- description of the pack within the DFS.public DfsPackDescription getPackDescription()
public boolean isIndexLoaded()
void setPackIndex(PackIndex idx)
public PackIndex getPackIndex(DfsReader ctx) throws java.io.IOException
ctx
- reader context to support reading from the backing store if
the index is not already loaded in memory.java.io.IOException
- the pack index is not available, or is corrupt.final boolean isGarbage()
PackBitmapIndex getBitmapIndex(DfsReader ctx) throws java.io.IOException
java.io.IOException
PackReverseIndex getReverseIdx(DfsReader ctx) throws java.io.IOException
java.io.IOException
public boolean hasObject(DfsReader ctx, AnyObjectId id) throws java.io.IOException
ctx
- reader context to support reading from the backing store if
the index is not already loaded in memory.id
- object to be located.java.io.IOException
- the pack index is not available, or is corrupt.ObjectLoader get(DfsReader ctx, AnyObjectId id) throws java.io.IOException
ctx
- temporary working space associated with the calling thread.id
- the object to obtain from the pack. Must not be null.java.io.IOException
- the pack file or the index could not be read.long findOffset(DfsReader ctx, AnyObjectId id) throws java.io.IOException
java.io.IOException
void resolve(DfsReader ctx, java.util.Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) throws java.io.IOException
java.io.IOException
long getObjectCount(DfsReader ctx) throws java.io.IOException
ctx
- current reader for the calling thread.java.io.IOException
- the index file cannot be loaded into memory.private byte[] decompress(long position, int sz, DfsReader ctx) throws java.io.IOException, java.util.zip.DataFormatException
java.io.IOException
java.util.zip.DataFormatException
void copyPackAsIs(PackOutputStream out, DfsReader ctx) throws java.io.IOException
java.io.IOException
private void copyPackThroughCache(PackOutputStream out, DfsReader ctx, ReadableChannel rc) throws java.io.IOException
java.io.IOException
private long copyPackBypassCache(PackOutputStream out, ReadableChannel rc) throws java.io.IOException
java.io.IOException
private java.nio.ByteBuffer newCopyBuffer(PackOutputStream out, ReadableChannel rc)
void copyAsIs(PackOutputStream out, DfsObjectToPack src, boolean validate, DfsReader ctx) throws java.io.IOException, StoredObjectRepresentationNotAvailableException
java.io.IOException
StoredObjectRepresentationNotAvailableException
private java.io.IOException packfileIsTruncated()
private void readFully(long position, byte[] dstbuf, int dstoff, int cnt, DfsReader ctx) throws java.io.IOException
java.io.IOException
ObjectLoader load(DfsReader ctx, long pos) throws java.io.IOException
java.io.IOException
private long findDeltaBase(DfsReader ctx, ObjectId baseId) throws java.io.IOException, MissingObjectException
java.io.IOException
MissingObjectException
byte[] getDeltaHeader(DfsReader wc, long pos) throws java.io.IOException, java.util.zip.DataFormatException
java.io.IOException
java.util.zip.DataFormatException
int getObjectType(DfsReader ctx, long pos) throws java.io.IOException
java.io.IOException
long getObjectSize(DfsReader ctx, AnyObjectId id) throws java.io.IOException
java.io.IOException
long getObjectSize(DfsReader ctx, long pos) throws java.io.IOException
java.io.IOException
void representation(DfsObjectRepresentation r, long pos, DfsReader ctx, PackReverseIndex rev) throws java.io.IOException
java.io.IOException
boolean isCorrupt(long offset)
private void setCorrupt(long offset)