Class DfsPackFile
java.lang.Object
org.eclipse.jgit.internal.storage.dfs.BlockBasedFile
org.eclipse.jgit.internal.storage.dfs.DfsPackFile
A Git version 2 pack file representation. A pack file contains Git objects in
delta packed format yielding high compression of lots of object where some
objects are similar.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PackBitmapIndexIndex of compressed bitmap mapping entire object graph.private LongListObjects we have tried to read, and discovered to be corrupt.private final ObjectLock forcorruptObjects.private PackIndexIndex mappingObjectIdto position within the pack stream.private static final intprivate static final longprivate PackReverseIndexFields inherited from class org.eclipse.jgit.internal.storage.dfs.BlockBasedFile
blockSize, cache, desc, ext, invalid, invalidatingCause, key, length -
Constructor Summary
ConstructorsConstructorDescriptionDfsPackFile(DfsBlockCache cache, DfsPackDescription desc) Construct a reader for an existing, packfile. -
Method Summary
Modifier and TypeMethodDescription(package private) voidcopyAsIs(PackOutputStream out, DfsObjectToPack src, boolean validate, DfsReader ctx) (package private) voidcopyPackAsIs(PackOutputStream out, DfsReader ctx) private longprivate voidcopyPackThroughCache(PackOutputStream out, DfsReader ctx, ReadableChannel rc) private byte[]decompress(long position, int sz, DfsReader ctx) private longfindDeltaBase(DfsReader ctx, ObjectId baseId) (package private) longfindOffset(DfsReader ctx, AnyObjectId id) (package private) ObjectLoaderget(DfsReader ctx, AnyObjectId id) Get an object from this pack.getBitmapIndex(DfsReader ctx) Get the BitmapIndex for this PackFile.(package private) byte[]getDeltaHeader(DfsReader wc, long pos) (package private) longgetObjectCount(DfsReader ctx) Obtain the total number of objects available in this pack.(package private) longgetObjectSize(DfsReader ctx, long pos) (package private) longgetObjectSize(DfsReader ctx, AnyObjectId id) (package private) intgetObjectType(DfsReader ctx, long pos) Get description that was originally used to configure this pack file.getPackIndex(DfsReader ctx) Get the PackIndex for this PackFile.(package private) PackReverseIndexgetReverseIdx(DfsReader ctx) booleanhasObject(DfsReader ctx, AnyObjectId id) Check if an object is stored within this pack.private PackIndex(package private) booleanisCorrupt(long offset) (package private) final booleanbooleanWhether the pack index file is loaded and cached in memory.(package private) ObjectLoaderprivate DfsBlockCache.Ref<PackBitmapIndex>loadBitmapIndex(DfsReader ctx, DfsStreamKey bitmapKey) private DfsBlockCache.Ref<PackIndex>loadPackIndex(DfsReader ctx, DfsStreamKey idxKey) private DfsBlockCache.Ref<PackReverseIndex>loadReverseIdx(DfsReader ctx, DfsStreamKey revKey, PackIndex idx) private ByteBuffernewCopyBuffer(PackOutputStream out, ReadableChannel rc) private IOExceptionprivate void(package private) voidrepresentation(DfsObjectRepresentation r, long pos, DfsReader ctx, PackReverseIndex rev) (package private) voidresolve(DfsReader ctx, Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) private voidsetCorrupt(long offset) (package private) voidsetPackIndex(PackIndex idx) Methods inherited from class org.eclipse.jgit.internal.storage.dfs.BlockBasedFile
alignToBlock, blockSize, elapsedMicros, getFileName, getOrLoadBlock, invalid, read, readOneBlock, setBlockSize, setInvalid
-
Field Details
-
REC_SIZE
private static final int REC_SIZE- See Also:
-
REF_POSITION
private static final long REF_POSITION- See Also:
-
index
Index mappingObjectIdto position within the pack stream. -
reverseIndex
-
bitmapIndex
Index of compressed bitmap mapping entire object graph. -
corruptObjects
Objects we have tried to read, and discovered to be corrupt.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.
-
corruptObjectsLock
Lock forcorruptObjects.
-
-
Constructor Details
-
DfsPackFile
DfsPackFile(DfsBlockCache cache, DfsPackDescription desc) Construct a reader for an existing, packfile.- Parameters:
cache- cache that owns the pack data.desc- description of the pack within the DFS.
-
-
Method Details
-
getPackDescription
Get description that was originally used to configure this pack file.- Returns:
- description that was originally used to configure this pack file.
-
isIndexLoaded
public boolean isIndexLoaded()Whether the pack index file is loaded and cached in memory.- Returns:
- whether the pack index file is loaded and cached in memory.
-
setPackIndex
-
getPackIndex
Get the PackIndex for this PackFile.- Parameters:
ctx- reader context to support reading from the backing store if the index is not already loaded in memory.- Returns:
- the PackIndex.
- Throws:
IOException- the pack index is not available, or is corrupt.
-
idx
- Throws:
IOException
-
isGarbage
final boolean isGarbage() -
getBitmapIndex
Get the BitmapIndex for this PackFile.- Parameters:
ctx- reader context to support reading from the backing store if the index is not already loaded in memory.- Returns:
- the BitmapIndex.
- Throws:
IOException- the bitmap index is not available, or is corrupt.
-
getReverseIdx
- Throws:
IOException
-
hasObject
Check if an object is stored within this pack.- Parameters:
ctx- reader context to support reading from the backing store if the index is not already loaded in memory.id- object to be located.- Returns:
- true if the object exists in this pack; false if it does not.
- Throws:
IOException- the pack index is not available, or is corrupt.
-
get
Get an object from this pack.- Parameters:
ctx- temporary working space associated with the calling thread.id- the object to obtain from the pack. Must not be null.- Returns:
- the object loader for the requested object if it is contained in this pack; null if the object was not found.
- Throws:
IOException- the pack file or the index could not be read.
-
findOffset
- Throws:
IOException
-
resolve
void resolve(DfsReader ctx, Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) throws IOException - Throws:
IOException
-
getObjectCount
Obtain the total number of objects available in this pack. This method relies on pack index, giving number of effectively available objects.- Parameters:
ctx- current reader for the calling thread.- Returns:
- number of objects in index of this pack, likewise in this pack
- Throws:
IOException- the index file cannot be loaded into memory.
-
decompress
private byte[] decompress(long position, int sz, DfsReader ctx) throws IOException, DataFormatException - Throws:
IOExceptionDataFormatException
-
copyPackAsIs
- Throws:
IOException
-
copyPackThroughCache
private void copyPackThroughCache(PackOutputStream out, DfsReader ctx, ReadableChannel rc) throws IOException - Throws:
IOException
-
copyPackBypassCache
- Throws:
IOException
-
newCopyBuffer
-
copyAsIs
void copyAsIs(PackOutputStream out, DfsObjectToPack src, boolean validate, DfsReader ctx) throws IOException, StoredObjectRepresentationNotAvailableException -
packfileIsTruncated
-
readFully
private void readFully(long position, byte[] dstbuf, int dstoff, int cnt, DfsReader ctx) throws IOException - Throws:
IOException
-
load
- Throws:
IOException
-
findDeltaBase
private long findDeltaBase(DfsReader ctx, ObjectId baseId) throws IOException, MissingObjectException - Throws:
IOExceptionMissingObjectException
-
getDeltaHeader
- Throws:
IOExceptionDataFormatException
-
getObjectType
- Throws:
IOException
-
getObjectSize
- Throws:
IOException
-
getObjectSize
- Throws:
IOException
-
representation
void representation(DfsObjectRepresentation r, long pos, DfsReader ctx, PackReverseIndex rev) throws IOException - Throws:
IOException
-
isCorrupt
boolean isCorrupt(long offset) -
setCorrupt
private void setCorrupt(long offset) -
loadPackIndex
private DfsBlockCache.Ref<PackIndex> loadPackIndex(DfsReader ctx, DfsStreamKey idxKey) throws IOException - Throws:
IOException
-
loadReverseIdx
private DfsBlockCache.Ref<PackReverseIndex> loadReverseIdx(DfsReader ctx, DfsStreamKey revKey, PackIndex idx) -
loadBitmapIndex
private DfsBlockCache.Ref<PackBitmapIndex> loadBitmapIndex(DfsReader ctx, DfsStreamKey bitmapKey) throws IOException - Throws:
IOException
-