Top Inners Fields Constructors Methods
org.eclipse.jgit.internal.storage.file

pack-priv Class PackIndexV1

extends Object
implements PackIndex
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.internal.storage.file.PackIndex, org.eclipse.jgit.lib.ObjectIdSet, java.lang.Iterable
Imports
java.io.IOException, .InputStream, java.util.Arrays, .Iterator, .NoSuchElementException, .Set, org.eclipse.jgit.errors.CorruptObjectException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.AbbreviatedObjectId, .AnyObjectId, .Constants, .ObjectId, org.eclipse.jgit.util.IO, .NB

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final int
pack-priv byte[][]
private final long[]
private long
protected byte[]
packChecksum

Footer checksum applied on the bottom of the pack file.

private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
PackIndexV1(final InputStream fd, final byte[] hdr)

Method Summary

Modifier and TypeMethod and Description
public long
findCRC32(AnyObjectId
id of object to look for
objId
)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.findCRC32.

Retrieve stored CRC32 checksum of the requested object raw-data (including header).

private int
findLevelOne(long nthPosition)

public long
findOffset(AnyObjectId
name of the object to locate within the pack.
objId
)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.findOffset.

Locate the file offset position for the requested object.

public int
findPosition(AnyObjectId
name of the object to locate within the index
objId
)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.findPosition.

Locate the position of this id in the list of object-ids in the index

public byte[]
private int
getLevelTwo(long nthPosition, int levelOne)

public long
getObjectCount()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getObjectCount.

Obtain the total number of objects described by this index.

public ObjectId
getObjectId(long
position within the traversal of iterator() that the caller needs the object for. The first returned org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry is 0, the second is 1, etc.
nthPosition
)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getObjectId.

Get ObjectId for the n-th object entry returned by iterator().

public long
getOffset(long
unsigned 32 bit position within the traversal of iterator() for which the caller needs the offset. The first returned MutableEntry is 0, the second is 1, etc. Positions past 2**31-1 are negative, but still valid.
nthPosition
)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getOffset.

Get offset in a pack for the n-th object entry returned by iterator().

public long
getOffset64Count()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getOffset64Count.

Obtain the total number of objects needing 64 bit offsets.

public boolean
hasCRC32Support()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.hasCRC32Support.

Check whether this index supports (has) CRC32 checksums for objects.

private static int
idOffset(int mid)

public Iterator<PackIndex.MutableEntry>
iterator()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.iterator.

Returns an iterator over elements of type T.

private int

Returns:

position in the byte[] where the objectId starts. -1 if not found.
levelTwoPosition
(AnyObjectId
ObjectId we are looking for
objId
,
byte[]
Blob of second level data with a series of (offset, objectid) pairs where we should find objId
data
)

Find position in level two data of this objectId Records are (offset, objectId), so to read the corresponding offset, caller must substract from this position.

public void
resolve(Set<ObjectId>
set to add any located ObjectIds to. This is an output parameter.
matches
,
AbbreviatedObjectId
prefix to search for.
id
,
int
maximum number of results to return. At most this many ObjectIds should be added to matches before returning.
matchLimit
)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.resolve.

Find objects matching the prefix abbreviation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IDX_HDR_LENback to summary
private static final int IDX_HDR_LEN
idxdataback to summary
pack-priv byte[][] idxdata
idxHeaderback to summary
private final long[] idxHeader
objectCntback to summary
private long objectCnt
packChecksumback to summary
protected byte[] packChecksum

Footer checksum applied on the bottom of the pack file.

RECORD_SIZEback to summary
private static final int RECORD_SIZE

Constructor Detail

PackIndexV1back to summary
pack-priv PackIndexV1(final InputStream fd, final byte[] hdr) throws CorruptObjectException, IOException

Method Detail

findCRC32back to summary
public long findCRC32(AnyObjectId objId)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.findCRC32.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.findCRC32.

Retrieve stored CRC32 checksum of the requested object raw-data (including header).

Parameters
objId:AnyObjectId

id of object to look for

Returns:long

CRC32 checksum of specified object (at 32 less significant bits)

Annotations
@Override
findLevelOneback to summary
private int findLevelOne(long nthPosition)
findOffsetback to summary
public long findOffset(AnyObjectId objId)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.findOffset.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.findOffset.

Locate the file offset position for the requested object.

Parameters
objId:AnyObjectId

name of the object to locate within the pack.

Returns:long

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.

Annotations
@Override
findPositionback to summary
public int findPosition(AnyObjectId objId)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.findPosition.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.findPosition.

Locate the position of this id in the list of object-ids in the index

Parameters
objId:AnyObjectId

name of the object to locate within the index

Returns:int

position of the object-id in the lexicographically ordered list of ids stored in this index; -1 if the object does not exist in this index and is thus not stored in the associated pack.

Annotations
@Override
getChecksumback to summary
public byte[] getChecksum()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getChecksum.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.getChecksum.

Get pack checksum

Returns:byte[]

the checksum of the pack; caller must not modify it

Annotations
@Override
getLevelTwoback to summary
private int getLevelTwo(long nthPosition, int levelOne)
getObjectCountback to summary
public long getObjectCount()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getObjectCount.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.getObjectCount.

Obtain the total number of objects described by this index.

Returns:long

number of objects in this index, and likewise in the associated pack that this index was generated from.

Annotations
@Override
getObjectIdback to summary
public ObjectId getObjectId(long nthPosition)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getObjectId.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.getObjectId.

Get ObjectId for the n-th object entry returned by 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();
Parameters
nthPosition:long

position within the traversal of iterator() that the caller needs the object for. The first returned org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry is 0, the second is 1, etc.

Returns:ObjectId

the ObjectId for the corresponding entry.

Annotations
@Override
getOffsetback to summary
public long getOffset(long nthPosition)

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getOffset.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.getOffset.

Get offset in a pack for the n-th object entry returned by iterator().

Parameters
nthPosition:long

unsigned 32 bit position within the traversal of iterator() for which the caller needs the offset. The first returned MutableEntry is 0, the second is 1, etc. Positions past 2**31-1 are negative, but still valid.

Returns:long

the offset in a pack for the corresponding entry.

Annotations
@Override
getOffset64Countback to summary
public long getOffset64Count()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.getOffset64Count.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.getOffset64Count.

Obtain the total number of objects needing 64 bit offsets.

Returns:long

number of objects in this index using a 64 bit offset; that is an object positioned after the 2 GB position within the file.

Annotations
@Override
hasCRC32Supportback to summary
public boolean hasCRC32Support()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.hasCRC32Support.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.hasCRC32Support.

Check whether this index supports (has) CRC32 checksums for objects.

Returns:boolean

true if CRC32 is stored, false otherwise

Annotations
@Override
idOffsetback to summary
private static int idOffset(int mid)
iteratorback to summary
public Iterator<PackIndex.MutableEntry> iterator()

Implements org.eclipse.jgit.internal.storage.file.PackIndex.iterator.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.iterator.

Returns an iterator over elements of type T.

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.

Returns:Iterator<PackIndex.MutableEntry>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
levelTwoPositionback to summary
private int levelTwoPosition(AnyObjectId objId, byte[] data)

Find position in level two data of this objectId Records are (offset, objectId), so to read the corresponding offset, caller must substract from this position.

Parameters
objId:AnyObjectId

ObjectId we are looking for

data:byte[]

Blob of second level data with a series of (offset, objectid) pairs where we should find objId

Returns:int

position in the byte[] where the objectId starts. -1 if not found.

resolveback to summary
public void resolve(Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) throws IOException

Implements org.eclipse.jgit.internal.storage.file.PackIndex.resolve.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.resolve.

Find objects matching the prefix abbreviation.

Parameters
matches:Set<ObjectId>

set to add any located ObjectIds to. This is an output parameter.

id:AbbreviatedObjectId

prefix to search for.

matchLimit:int

maximum number of results to return. At most this many ObjectIds should be added to matches before returning.

Annotations
@Override
Exceptions
IOException:
the index cannot be read.
org.eclipse.jgit.internal.storage.file back to summary

private Class PackIndexV1.EntriesIteratorV1

extends EntriesIterator
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private int
private final PackIndexV1

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
readNext()

Implements abstract org.eclipse.jgit.internal.storage.file.PackIndex.EntriesIterator.readNext.

Used by subclasses to load the next entry into the MutableEntry.

Inherited from org.eclipse.jgit.internal.storage.file.PackIndex.EntriesIterator:
hasNextnextremovesetIdBuffersetIdBuffersetOffset

Field Detail

levelOneback to summary
private int levelOne
levelTwoback to summary
private int levelTwo
packIndexback to summary
private final PackIndexV1 packIndex

Constructor Detail

EntriesIteratorV1back to summary
private EntriesIteratorV1(PackIndexV1 packIndex)

Method Detail

readNextback to summary
protected void readNext()

Implements abstract org.eclipse.jgit.internal.storage.file.PackIndex.EntriesIterator.readNext.

Doc from org.eclipse.jgit.internal.storage.file.PackIndex.EntriesIterator.readNext.

Used by subclasses to load the next entry into the MutableEntry.

Subclasses are expected to populate the entry with setIdBuffer and setOffset.

Annotations
@Override