| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | PackObjectSizeIndexWriter.
Object size index v1. |
| Modifier and Type | Field and Description |
|---|---|
| protected static final byte[] | HEADER
Magic constant for the object size index file |
| private static final int | |
| private static final PackObjectSizeIndexWriter |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static PackObjectSizeIndexWriter | Returns: the index writerOutput stream where to write the index os, int objects strictly smaller than this size won't be added to the
index. Negative size won't write AT ALL. Other sizes could write
an empty index. minSize)Returns a writer for the latest index version |
| public abstract void | write(List<? extends PackedObjectInfo>
objects in the pack, in sha1 order. Their position in the list
matches their position in the primary index. objs)Add the objects to the index |
| HEADER | back to summary |
|---|---|
| protected static final byte[] HEADER Magic constant for the object size index file | |
| MAX_24BITS_UINT | back to summary |
|---|---|
| private static final int MAX_24BITS_UINT | |
| NULL_WRITER | back to summary |
|---|---|
| private static final PackObjectSizeIndexWriter NULL_WRITER | |
| PackObjectSizeIndexWriter | back to summary |
|---|---|
| public PackObjectSizeIndexWriter() | |
| createWriter | back to summary |
|---|---|
| public static PackObjectSizeIndexWriter createWriter(OutputStream os, int minSize) Returns a writer for the latest index version
| |
| write | back to summary |
|---|---|
| public abstract void write(List<? extends PackedObjectInfo> objs) throws IOException Add the objects to the index
| |
Positions in the main index fit well in unsigned 24 bits (16M) for most repositories, but some outliers have even more objects, so we need to store also 32 bits positions.
Sizes are stored as a first array parallel to positions. If a size doesn't fit in an element of that array, then we encode there a position on the next-size array. This "overflow" array doesn't have entries for all positions.
positions [10, 500, 1000, 1001]
sizes (32bits) [15MB, -1, 6MB, -2]
___/ ______/
/ /
sizes (64 bits) [3GB, 6GB]
For sizes we use 32 bits as the first level and 64 for the rare objects over 2GB.
A 24/32/64 bits hierarchy of arrays saves space if we have a lot of small objects, but wastes space if we have only big ones. The min size to index is controlled by conf and in principle we want to index only rather big objects (e.g. > 10MB). We could support more dynamics read/write of sizes (e.g. 24 only if the threshold will include many of those objects) but it complicates a lot code and spec. If needed it could go for a v2 of the protocol.
Format:
Blocks of
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | |
| private final int | |
| private final OutputStream |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static void | applyToRange(int[] allPositions, int start, int end, PackObjectSizeIndexWriter.
|
| private PackObjectSizeIndexWriter. | |
| private int[] | |
| private boolean | |
| public void | write(List<? extends PackedObjectInfo>
objects in the pack, in sha1 order. Their position in the list
matches their position in the primary index. allObjects)Implements abstract org. Add the objects to the index |
| private void | |
| private void | |
| private void | writeSizes(List<? extends PackedObjectInfo> allObjects, int[] indexablePositions, int objsBiggerThan2Gb)
|
| private void |
| intBuffer | back to summary |
|---|---|
| private final byte[] intBuffer | |
| minObjSize | back to summary |
|---|---|
| private final int minObjSize | |
| os | back to summary |
|---|---|
| private final OutputStream os | |
| PackObjectSizeWriterV1 | back to summary |
|---|---|
| pack-priv PackObjectSizeWriterV1(OutputStream os, int minSize) | |
| applyToRange | back to summary |
|---|---|
| private static void applyToRange(int[] allPositions, int start, int end, PackObjectSizeIndexWriter. | |
| countIndexableObjects | back to summary |
|---|---|
| private PackObjectSizeIndexWriter. | |
| findIndexablePositions | back to summary |
|---|---|
| private int[] findIndexablePositions(List<? extends PackedObjectInfo> allObjects, int indexableObjs) | |
| shouldIndex | back to summary |
|---|---|
| private boolean shouldIndex(PackedObjectInfo o) | |
| write | back to summary |
|---|---|
| public void write(List<? extends PackedObjectInfo> allObjects) throws IOException Implements abstract org. Doc from org. Add the objects to the index
| |
| writeInt24 | back to summary |
|---|---|
| private void writeInt24(int i) throws IOException | |
| writeInt32 | back to summary |
|---|---|
| private void writeInt32(int i) throws IOException | |
| writeSizes | back to summary |
|---|---|
| private void writeSizes(List<? extends PackedObjectInfo> allObjects, int[] indexablePositions, int objsBiggerThan2Gb) throws IOException | |
| writeUInt8 | back to summary |
|---|---|
| private void writeUInt8(int i) throws IOException | |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| encode | back to summary |
|---|---|
| public void encode(int i) throws IOException | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| private |
| indexableObjs | back to summary |
|---|---|
| pack-priv int indexableObjs | |
| pos24Bits | back to summary |
|---|---|
| pack-priv int pos24Bits | |
| pos31Bits | back to summary |
|---|---|
| pack-priv int pos31Bits | |
| sizeOver2GB | back to summary |
|---|---|
| pack-priv int sizeOver2GB | |
| PackedObjectStats | back to summary |
|---|---|
| private PackedObjectStats() | |