class PackIndexV2 extends PackIndex
| Modifier and Type | Class and Description |
|---|---|
private class |
PackIndexV2.EntriesIteratorV2 |
PackIndex.EntriesIterator, PackIndex.MutableEntry| Modifier and Type | Field and Description |
|---|---|
private byte[][] |
crc32
256 arrays of the CRC-32 of objects, matching
names. |
private static int |
FANOUT |
private long[] |
fanoutTable |
private static long |
IS_O64 |
(package private) int[][] |
names
256 arrays of contiguous object names.
|
private static byte[] |
NO_BYTES |
private static int[] |
NO_INTS |
private long |
objectCnt |
(package private) byte[][] |
offset32
256 arrays of the 32 bit offset data, matching
names. |
(package private) byte[] |
offset64
64 bit offset table.
|
packChecksum| Constructor and Description |
|---|
PackIndexV2(java.io.InputStream fd) |
| Modifier and Type | Method and Description |
|---|---|
private int |
binarySearchLevelTwo(AnyObjectId objId,
int levelOne) |
long |
findCRC32(AnyObjectId objId)
Retrieve stored CRC32 checksum of the requested object raw-data
(including header).
|
private int |
findLevelOne(long nthPosition) |
long |
findOffset(AnyObjectId objId)
Locate the file offset position for the requested object.
|
private int |
getLevelTwo(long nthPosition,
int levelOne) |
long |
getObjectCount()
Obtain the total number of objects described by this index.
|
ObjectId |
getObjectId(long nthPosition)
Get ObjectId for the n-th object entry returned by
PackIndex.iterator(). |
private long |
getOffset(int levelOne,
int levelTwo) |
long |
getOffset(long nthPosition)
Get offset in a pack for the n-th object entry returned by
PackIndex.iterator(). |
long |
getOffset64Count()
Obtain the total number of objects needing 64 bit offsets.
|
boolean |
hasCRC32Support()
Check whether this index supports (has) CRC32 checksums for objects.
|
private static int |
idOffset(int p) |
java.util.Iterator<PackIndex.MutableEntry> |
iterator() |
void |
resolve(java.util.Set<ObjectId> matches,
AbbreviatedObjectId id,
int matchLimit)
Find objects matching the prefix abbreviation.
|
contains, getObjectId, hasObject, open, readprivate static final long IS_O64
private static final int FANOUT
private static final int[] NO_INTS
private static final byte[] NO_BYTES
private long objectCnt
private final long[] fanoutTable
int[][] names
byte[][] offset32
names.private byte[][] crc32
names.byte[] offset64
PackIndexV2(java.io.InputStream fd)
throws java.io.IOException
java.io.IOExceptionpublic long getObjectCount()
getObjectCount in class PackIndexpublic long getOffset64Count()
getOffset64Count in class PackIndexprivate int findLevelOne(long nthPosition)
private int getLevelTwo(long nthPosition,
int levelOne)
public ObjectId getObjectId(long nthPosition)
PackIndex.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();
getObjectId in class PackIndexnthPosition - position within the traversal of PackIndex.iterator() that the
caller needs the object for. The first returned
PackIndex.MutableEntry
is 0, the second is 1, etc.public long getOffset(long nthPosition)
PackIndex.iterator().getOffset in class PackIndexnthPosition - unsigned 32 bit position within the traversal of
PackIndex.iterator() for which the caller needs the offset. The
first returned PackIndex.MutableEntry is 0, the second is 1,
etc. Positions past 2**31-1 are negative, but still valid.public long findOffset(AnyObjectId objId)
findOffset in class PackIndexobjId - name of the object to locate within the pack.private long getOffset(int levelOne,
int levelTwo)
public long findCRC32(AnyObjectId objId) throws MissingObjectException
findCRC32 in class PackIndexobjId - id of object to look forMissingObjectException - when requested ObjectId was not found in this indexpublic boolean hasCRC32Support()
hasCRC32Support in class PackIndexpublic java.util.Iterator<PackIndex.MutableEntry> 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.
iterator in interface java.lang.Iterable<PackIndex.MutableEntry>iterator in class PackIndexpublic void resolve(java.util.Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit) throws java.io.IOException
resolve in class PackIndexmatches - 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.java.io.IOException - the index cannot be read.private static int idOffset(int p)
private int binarySearchLevelTwo(AnyObjectId objId, int levelOne)