org.eclipse.jgit.internal.storage.file.Pack .
Pack index files (the .idx suffix in a pack file pair) provides
random access to any object in the pack by associating an ObjectId to the
byte offset within the pack where the object's data can be read.
| Modifier and Type | Field and Description |
|---|---|
| protected List | entries
The entries this writer must pack. |
| protected final DigestOutputStream | out
The index data stream we are responsible for creating. |
| protected byte[] | packChecksum
SHA-1 checksum for the entire pack data. |
| protected final byte[] | tmp
A temporary buffer for use during IO to {link #out}. |
| protected static final byte[] | TOC
Magic constant indicating post-version 1 format. |
| Access | Constructor and Description |
|---|---|
| protected | BasePackIndexWriter(OutputStream
the stream this instance outputs to. If not already buffered
it will be automatically wrapped in a buffered stream. dst)Create a new writer instance. |
| Modifier and Type | Method and Description |
|---|---|
| public static PackIndexWriter | Returns: a new writer to output an index file of the requested format to the supplied stream.the stream the index data will be written to. If not already
buffered it will be automatically wrapped in a buffered
stream. Callers are always responsible for closing the stream. dst, final List<? extends PackedObjectInfo> the objects the caller needs to store in the index. Entries
will be examined until a format can be conclusively selected. objs)Create a new writer for the oldest (most widely understood) format. |
| public static PackIndexWriter | Returns: a new writer to output an index file of the requested format to the supplied stream.the stream the index data will be written to. If not already
buffered it will be automatically wrapped in a buffered
stream. Callers are always responsible for closing the stream. dst, final int index format version number required by the caller. Exactly
this formatted version will be written. version)Create a new writer instance for a specific index format version. |
| public static int | Returns: the index format.the objects the caller needs to store in the index. Entries
will be examined until a format can be conclusively selected. objs)Return the oldest (most widely understood) index format. |
| public void | write(final List<? extends PackedObjectInfo>
sorted list of objects to store in the index. The caller must
have previously sorted the list using
toStore, final byte[] org.'s native
java. implementation.checksum signature of the entire pack data content. This is
traditionally the last 20 bytes of the pack file's own stream. packDataChecksum)Implements org. Write all object entries to the index stream. |
| protected void | |
| protected void | |
| protected abstract void | |
| protected void | writeTOC(int
version number of this index format being written. version)Output the version 2 (and later) TOC header, with version number. |
| entries | back to summary |
|---|---|
| protected List<? extends PackedObjectInfo> entries The entries this writer must pack. | |
| out | back to summary |
|---|---|
| protected final DigestOutputStream out The index data stream we are responsible for creating. | |
| packChecksum | back to summary |
|---|---|
| protected byte[] packChecksum SHA-1 checksum for the entire pack data. | |
| tmp | back to summary |
|---|---|
| protected final byte[] tmp A temporary buffer for use during IO to {link #out}. | |
| TOC | back to summary |
|---|---|
| protected static final byte[] TOC Magic constant indicating post-version 1 format. | |
| BasePackIndexWriter | back to summary |
|---|---|
| protected BasePackIndexWriter(OutputStream dst) Create a new writer instance.
| |
| createOldestPossible | back to summary |
|---|---|
| public static PackIndexWriter createOldestPossible(final OutputStream dst, final List<? extends PackedObjectInfo> objs) Create a new writer for the oldest (most widely understood) format. This method selects an index format that can accurate describe the supplied objects and that will be the most compatible format with older Git implementations. Index version 1 is widely recognized by all Git implementations, but index version 2 (and later) is not as well recognized as it was introduced more than a year later. Index version 1 can only be used if the resulting pack file is under 4 gigabytes in size; packs larger than that limit must use index version 2.
| |
| createVersion | back to summary |
|---|---|
| public static PackIndexWriter createVersion(final OutputStream dst, final int version) Create a new writer instance for a specific index format version.
| |
| oldestPossibleFormat | back to summary |
|---|---|
| public static int oldestPossibleFormat(final List<? extends PackedObjectInfo> objs) Return the oldest (most widely understood) index format. This method selects an index format that can accurate describe the supplied objects and that will be the most compatible format with older Git implementations. Index version 1 is widely recognized by all Git implementations, but index version 2 (and later) is not as well recognized as it was introduced more than a year later. Index version 1 can only be used if the resulting pack file is under 4 gigabytes in size; packs larger than that limit must use index version 2.
| |
| write | back to summary |
|---|---|
| public void write(final List<? extends PackedObjectInfo> toStore, final byte[] packDataChecksum) throws IOException Implements org. Write all object entries to the index stream. After writing the stream passed to the factory is flushed but remains open. Callers are always responsible for closing the output stream.
| |
| writeChecksumFooter | back to summary |
|---|---|
| protected void writeChecksumFooter() throws IOException Output the standard two-checksum index footer. The standard footer contains two checksums (20 byte SHA-1 values):
| |
| writeFanOutTable | back to summary |
|---|---|
| protected void writeFanOutTable() throws IOException Output the standard 256 entry first-level fan-out table.
The fan-out table is 4 KB in size, holding 256 32-bit unsigned integer
counts. Each count represents the number of objects within this index
whose
| |
| writeImpl | back to summary |
|---|---|
| protected abstract void writeImpl() throws IOException Writes the index file to Implementations should go something like: writeFanOutTable(); for (final PackedObjectInfo po : entries) writeOneEntry(po); writeChecksumFooter();
Where the logic for
| |
| writeTOC | back to summary |
|---|---|
| protected void writeTOC(int version) throws IOException Output the version 2 (and later) TOC header, with version number. Post version 1 all index files start with a TOC header that makes the file an invalid version 1 file, and then includes the version number. This header is necessary to recognize a version 1 from a version 2 formatted index.
| |