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

pack-priv final Class PackReverseIndexComputed

extends Object
implements PackReverseIndex
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.internal.storage.file.PackReverseIndex
Imports
java.text.MessageFormat, org.eclipse.jgit.errors.CorruptObjectException, .PackMismatchException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry, org.eclipse.jgit.lib.ObjectId

Reverse index for forward pack index which is computed from the forward pack index.

Creating an instance uses an insertion sort of the entries in the forward index, so it runs in quadratic time on average.

Field Summary

Modifier and TypeField and Description
private final long
bucketSize

The difference in offset between the start of an offset bucket and the start of its succeeding bucket.

private final PackIndex
index

Index we were created from, and that has our ObjectId data.

private final int[]
indexPosInOffsetOrder

Mapping from indices in offset order to indices in SHA-1 order.

private final int[]
nextBucketStart

The indexes into indexPosInOffsetOrder at which the next bucket starts.

Constructor Summary

AccessConstructor and Description
pack-priv
PackReverseIndexComputed(PackIndex
forward index - entries to (reverse) index.
packIndex
)

Create reverse index from straight/forward pack index, by indexing all its entries.

Method Summary

Modifier and TypeMethod and Description
private int
binarySearch(long offset)

public long
findNextOffset(long
start offset of previous object (must be valid-existing offset).
offset
,
long
maximum offset in a pack (returned when there is no next offset).
maxOffset
)

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.findNextOffset.

Search for the next offset to the specified offset in this pack (reverse) index.

public ObjectId
findObject(long
start offset of object to find.
offset
)

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.findObject.

Search for object id with the specified start offset in this pack (reverse) index.

public ObjectId
findObjectByPosition(int
the position of the object in the reverse index
nthPosition
)

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.findObjectByPosition.

Find the object that is in the given position in the reverse index.

public int
findPosition(long
the pack offset of the object
offset
)

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

Find the position in the reverse index of the object at the given pack offset.

public void
verifyPackChecksum(String
the path to display in event of a mismatch
packFilePath
)

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.verifyPackChecksum.

Verify that the pack checksum found in the reverse index matches that from the pack file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bucketSizeback to summary
private final long bucketSize

The difference in offset between the start of an offset bucket and the start of its succeeding bucket.

indexback to summary
private final PackIndex index

Index we were created from, and that has our ObjectId data.

indexPosInOffsetOrderback to summary
private final int[] indexPosInOffsetOrder

Mapping from indices in offset order to indices in SHA-1 order.

nextBucketStartback to summary
private final int[] nextBucketStart

The indexes into indexPosInOffsetOrder at which the next bucket starts.

For example, given offset o (and therefore bucket = o / bucketSize), the indexPos corresponding to o will be contained in the range indexPosInOffsetOrder[nextBucketStart[bucket - 1]] inclusive to indexPosInOffsetOrder[nextBucketStart[bucket]] exclusive.

This range information can speed up #binarySearch by identifying the relevant bucket and only searching within its range.

See binarySearch

Constructor Detail

PackReverseIndexComputedback to summary
pack-priv PackReverseIndexComputed(PackIndex packIndex)

Create reverse index from straight/forward pack index, by indexing all its entries.

Parameters
packIndex:PackIndex

forward index - entries to (reverse) index.

Method Detail

binarySearchback to summary
private int binarySearch(long offset)
findNextOffsetback to summary
public long findNextOffset(long offset, long maxOffset) throws CorruptObjectException

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.findNextOffset.

Doc from org.eclipse.jgit.internal.storage.file.PackReverseIndex.findNextOffset.

Search for the next offset to the specified offset in this pack (reverse) index.

Parameters
offset:long

start offset of previous object (must be valid-existing offset).

maxOffset:long

maximum offset in a pack (returned when there is no next offset).

Returns:long

offset of the next object in a pack or maxOffset if provided offset was the last one.

Annotations
@Override
Exceptions
CorruptObjectException:
when there is no object with the provided offset.
findObjectback to summary
public ObjectId findObject(long offset)

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.findObject.

Doc from org.eclipse.jgit.internal.storage.file.PackReverseIndex.findObject.

Search for object id with the specified start offset in this pack (reverse) index.

Parameters
offset:long

start offset of object to find.

Returns:ObjectId

object id for this offset, or null if no object was found.

Annotations
@Override
findObjectByPositionback to summary
public ObjectId findObjectByPosition(int nthPosition)

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.findObjectByPosition.

Doc from org.eclipse.jgit.internal.storage.file.PackReverseIndex.findObjectByPosition.

Find the object that is in the given position in the reverse index.

Parameters
nthPosition:int

the position of the object in the reverse index

Returns:ObjectId

the object in that position

Annotations
@Override
findPositionback to summary
public int findPosition(long offset)

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

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

Find the position in the reverse index of the object at the given pack offset.

Parameters
offset:long

the pack offset of the object

Returns:int

the position in the reverse index of the object

Annotations
@Override
verifyPackChecksumback to summary
public void verifyPackChecksum(String packFilePath) throws PackMismatchException

Implements org.eclipse.jgit.internal.storage.file.PackReverseIndex.verifyPackChecksum.

Doc from org.eclipse.jgit.internal.storage.file.PackReverseIndex.verifyPackChecksum.

Verify that the pack checksum found in the reverse index matches that from the pack file.

Parameters
packFilePath:String

the path to display in event of a mismatch

Annotations
@Override
Exceptions
PackMismatchException:
if the checksums do not match