Class PackIndexV1
java.lang.Object
org.eclipse.jgit.internal.storage.file.PackIndex
org.eclipse.jgit.internal.storage.file.PackIndexV1
- All Implemented Interfaces:
Iterable<PackIndex.MutableEntry>,ObjectIdSet
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.eclipse.jgit.internal.storage.file.PackIndex
PackIndex.EntriesIterator, PackIndex.MutableEntry -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int(package private) byte[][]private final long[]private longFields inherited from class org.eclipse.jgit.internal.storage.file.PackIndex
packChecksum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongfindCRC32(AnyObjectId objId) Retrieve stored CRC32 checksum of the requested object raw-data (including header).private intfindLevelOne(long nthPosition) longfindOffset(AnyObjectId objId) Locate the file offset position for the requested object.private intgetLevelTwo(long nthPosition, int levelOne) longObtain the total number of objects described by this index.getObjectId(long nthPosition) Get ObjectId for the n-th object entry returned byPackIndex.iterator().(package private) longgetOffset(long nthPosition) Get offset in a pack for the n-th object entry returned byPackIndex.iterator().longObtain the total number of objects needing 64 bit offsets.booleanCheck whether this index supports (has) CRC32 checksums for objects.private static intidOffset(int mid) iterator()voidresolve(Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) Find objects matching the prefix abbreviation.Methods inherited from class org.eclipse.jgit.internal.storage.file.PackIndex
contains, getChecksum, getObjectId, hasObject, open, readMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
IDX_HDR_LEN
private static final int IDX_HDR_LEN- See Also:
-
idxHeader
private final long[] idxHeader -
idxdata
byte[][] idxdata -
objectCnt
private long objectCnt
-
-
Constructor Details
-
PackIndexV1
PackIndexV1(InputStream fd, byte[] hdr) throws CorruptObjectException, IOException - Throws:
CorruptObjectExceptionIOException
-
-
Method Details
-
getObjectCount
public long getObjectCount()Obtain the total number of objects described by this index.- Specified by:
getObjectCountin classPackIndex- Returns:
- number of objects in this index, and likewise in the associated pack that this index was generated from.
-
getOffset64Count
public long getOffset64Count()Obtain the total number of objects needing 64 bit offsets.- Specified by:
getOffset64Countin classPackIndex- Returns:
- number of objects in this index using a 64 bit offset; that is an object positioned after the 2 GB position within the file.
-
findLevelOne
private int findLevelOne(long nthPosition) -
getLevelTwo
private int getLevelTwo(long nthPosition, int levelOne) -
getObjectId
Get ObjectId for the n-th object entry returned byPackIndex.iterator().This method is a constant-time replacement for the following loop:
Iterator<MutableEntry> eItr = index.iterator(); int curPosition = 0; while (eItr.hasNext() && curPosition++ < nthPosition) eItr.next(); ObjectId result = eItr.next().toObjectId();- Specified by:
getObjectIdin classPackIndex- Parameters:
nthPosition- position within the traversal ofPackIndex.iterator()that the caller needs the object for. The first returnedPackIndex.MutableEntryis 0, the second is 1, etc.- Returns:
- the ObjectId for the corresponding entry.
-
getOffset
long getOffset(long nthPosition) Description copied from class:PackIndexGet offset in a pack for the n-th object entry returned byPackIndex.iterator().- Specified by:
getOffsetin classPackIndex- Parameters:
nthPosition- unsigned 32 bit position within the traversal ofPackIndex.iterator()for which the caller needs the offset. The first returnedPackIndex.MutableEntryis 0, the second is 1, etc. Positions past 2**31-1 are negative, but still valid.- Returns:
- the offset in a pack for the corresponding entry.
-
findOffset
Locate the file offset position for the requested object.- Specified by:
findOffsetin classPackIndex- Parameters:
objId- name of the object to locate within the pack.- Returns:
- offset of the object's header and compressed content; -1 if the object does not exist in this index and is thus not stored in the associated pack.
-
findCRC32
Retrieve stored CRC32 checksum of the requested object raw-data (including header). -
hasCRC32Support
public boolean hasCRC32Support()Check whether this index supports (has) CRC32 checksums for objects.- Specified by:
hasCRC32Supportin classPackIndex- Returns:
- true if CRC32 is stored, false otherwise
-
iterator
Provide iterator that gives access to index entries. Note, that iterator returns reference to mutable object, the same reference in each call - for performance reason. If client needs immutable objects, it must copy returned object on its own.
Iterator returns objects in SHA-1 lexicographical order.
- Specified by:
iteratorin interfaceIterable<PackIndex.MutableEntry>- Specified by:
iteratorin classPackIndex
-
resolve
public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) throws IOException Find objects matching the prefix abbreviation.- Specified by:
resolvein classPackIndex- Parameters:
matches- set to add any located ObjectIds to. This is an output parameter.id- prefix to search for.matchLimit- maximum number of results to return. At most this many ObjectIds should be added to matches before returning.- Throws:
IOException- the index cannot be read.
-
idOffset
private static int idOffset(int mid)
-