Top Description Inners Constructors Methods
org.eclipse.jgit.junit

public Class FakeIndexFactory

extends Object
Class Inheritance
Static Imports
java.util.function.Function.identity, java.util.stream.Collectors.toMap, .Collectors.toUnmodifiableList

Create indexes with predefined data
Since
7.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
public static record
FakeIndexFactory.IndexObject

An object for the fake index

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PackIndex

Returns:

a PackIndex implementation
indexOf
(List<FakeIndexFactory.IndexObject>
objects to be indexed
objs
)

Return an index populated with these objects

public static PackReverseIndex

Returns:

a PackReverseIndex implementation
reverseIndexOf
(List<FakeIndexFactory.IndexObject>
objects to be indexed
objs
)

Return a reverse pack index with these objects

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

FakeIndexFactoryback to summary
private FakeIndexFactory()

Method Detail

indexOfback to summary
public static PackIndex indexOf(List<FakeIndexFactory.IndexObject> objs)

Return an index populated with these objects

Parameters
objs:List<FakeIndexFactory.IndexObject>

objects to be indexed

Returns:PackIndex

a PackIndex implementation

reverseIndexOfback to summary
public static PackReverseIndex reverseIndexOf(List<FakeIndexFactory.IndexObject> objs)

Return a reverse pack index with these objects

Parameters
objs:List<FakeIndexFactory.IndexObject>

objects to be indexed

Returns:PackReverseIndex

a PackReverseIndex implementation

org.eclipse.jgit.junit back to summary

private Class FakeIndexFactory.FakeEntriesIterator

extends EntriesIterator
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final byte[]
private final Iterator<FakeIndexFactory.IndexObject>

Constructor Summary

AccessConstructor and Description
pack-priv

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

bufferback to summary
private static final byte[] buffer
itback to summary
private final Iterator<FakeIndexFactory.IndexObject> it

Constructor Detail

FakeEntriesIteratorback to summary
pack-priv FakeEntriesIterator(List<FakeIndexFactory.IndexObject> objs)

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
org.eclipse.jgit.junit back to summary

private Class FakeIndexFactory.FakePackIndex

extends Object
implements PackIndex
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.internal.storage.file.PackIndex, org.eclipse.jgit.lib.ObjectIdSet, java.lang.Iterable

Field Summary

Modifier and TypeField and Description
private final Map<String, FakeIndexFactory.IndexObject>
private final long
private static final Comparator<FakeIndexFactory.IndexObject>
private final List<FakeIndexFactory.IndexObject>

Constructor Summary

AccessConstructor and Description
pack-priv

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

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[]
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.

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

idxback to summary
private final Map<String, FakeIndexFactory.IndexObject> idx
offset64countback to summary
private final long offset64count
SHA1_COMPARATORback to summary
private static final Comparator<FakeIndexFactory.IndexObject> SHA1_COMPARATOR
sha1Orderedback to summary
private final List<FakeIndexFactory.IndexObject> sha1Ordered

Constructor Detail

FakePackIndexback to summary
pack-priv FakePackIndex(List<FakeIndexFactory.IndexObject> objs)

Method Detail

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
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
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
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.junit back to summary

private Class FakeIndexFactory.FakeReverseIndex

extends Object
implements PackReverseIndex
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.internal.storage.file.PackReverseIndex

Field Summary

Modifier and TypeField and Description
private final List<FakeIndexFactory.IndexObject>
private static final Comparator<FakeIndexFactory.IndexObject>
private final Map<Long, FakeIndexFactory.IndexObject>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
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

byOffsetback to summary
private final List<FakeIndexFactory.IndexObject> byOffset
OFFSET_COMPARATORback to summary
private static final Comparator<FakeIndexFactory.IndexObject> OFFSET_COMPARATOR
ridxback to summary
private final Map<Long, FakeIndexFactory.IndexObject> ridx

Constructor Detail

FakeReverseIndexback to summary
pack-priv FakeReverseIndex(List<FakeIndexFactory.IndexObject> objs)

Method Detail

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)

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
org.eclipse.jgit.junit back to summary

public final Record FakeIndexFactory.IndexObject

extends Record
Class Inheritance
Record Components
name:String
a sha1
offset:long
the (fake) position of the object in the pack

An object for the fake index

Field Summary

Modifier and TypeField and Description
private final String
name

Record Component accessed by name().

a sha1
private final long
offset

Record Component accessed by offset().

the (fake) position of the object in the pack

Constructor Summary

AccessConstructor and Description
public
IndexObject(String name, long offset)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public ObjectId

Returns:

name (a sha1) as an objectId.
getObjectId
()

Name (sha1) as an objectId

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
name()

Record Component getter of name.

Record Component a sha1

public long
offset()

Record Component getter of offset.

Record Component the (fake) position of the object in the pack

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

nameback to summary
private final String name

Record Component accessed by name().

a sha1

offsetback to summary
private final long offset

Record Component accessed by offset().

the (fake) position of the object in the pack

Constructor Detail

IndexObjectback to summary
public IndexObject(String name, long offset)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

getObjectIdback to summary
public ObjectId getObjectId()

Name (sha1) as an objectId

Returns:ObjectId

name (a sha1) as an objectId.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

nameback to summary
public String name()

Record Component getter of name.

Record Component
a sha1
offsetback to summary
public long offset()

Record Component getter of offset.

Record Component
the (fake) position of the object in the pack
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.