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

pack-priv Class PackIndexV2

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.text.MessageFormat, java.util.Arrays, .Iterator, .NoSuchElementException, .Set, org.eclipse.jgit.errors.MissingObjectException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.AbbreviatedObjectId, .AnyObjectId, .Constants, .ObjectId, org.eclipse.jgit.util.IO, .NB

Support for the pack index v2 format.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private byte[][]
crc32

256 arrays of the CRC-32 of objects, matching names.

private static final int
private final long[]
private static final long
pack-priv int[][]
names

256 arrays of contiguous object names.

private static final byte[]
private static final int[]
private long
pack-priv byte[][]
offset32

256 arrays of the 32 bit offset data, matching names.

pack-priv byte[]
offset64

64 bit offset table.

protected byte[]
packChecksum

Footer checksum applied on the bottom of the pack file.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private int
binarySearchLevelTwo(AnyObjectId objId, int levelOne)

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().

private long
getOffset(int levelOne, int levelTwo)

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 p)

public Iterator<PackIndex.MutableEntry>
iterator()

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

Returns an iterator over elements of type T.

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

crc32back to summary
private byte[][] crc32

256 arrays of the CRC-32 of objects, matching names.

FANOUTback to summary
private static final int FANOUT
fanoutTableback to summary
private final long[] fanoutTable
IS_O64back to summary
private static final long IS_O64
namesback to summary
pack-priv int[][] names

256 arrays of contiguous object names.

NO_BYTESback to summary
private static final byte[] NO_BYTES
NO_INTSback to summary
private static final int[] NO_INTS
objectCntback to summary
private long objectCnt
offset32back to summary
pack-priv byte[][] offset32

256 arrays of the 32 bit offset data, matching names.

offset64back to summary
pack-priv byte[] offset64

64 bit offset table.

packChecksumback to summary
protected byte[] packChecksum

Footer checksum applied on the bottom of the pack file.

Constructor Detail

PackIndexV2back to summary
pack-priv PackIndexV2(final InputStream fd) throws IOException

Method Detail

binarySearchLevelTwoback to summary
private int binarySearchLevelTwo(AnyObjectId objId, int levelOne)
findCRC32back to summary
public long findCRC32(AnyObjectId objId) throws MissingObjectException

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
Exceptions
MissingObjectException:
when requested ObjectId was not found in this index
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
getOffsetback to summary
private long getOffset(int levelOne, int levelTwo)
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 p)
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
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 PackIndexV2.EntriesIteratorV2

extends EntriesIterator
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private int
private final PackIndexV2

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 PackIndexV2 packIndex

Constructor Detail

EntriesIteratorV2back to summary
private EntriesIteratorV2(PackIndexV2 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