java.lang.Object
org.eclipse.jgit.internal.storage.file.PackReverseIndexWriter
Writes reverse index files conforming to the requested version.
The reverse index file format is specified at https://git-scm.com/docs/pack-format#_pack_rev_files_have_the_format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataOutputStream to write primitive type contents to while maintaining a checksum.protected static byte[]Magic bytes that uniquely identify git reverse index files.protected final DigestOutputStreamStream to write contents to while maintaining a checksum.protected static final intThe first reverse index file version. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct the components of a PackReverseIndexWriter that are shared between subclasses. -
Method Summary
Modifier and TypeMethodDescriptionstatic PackReverseIndexWritercreateWriter(OutputStream dst) Create a writer instance for the default file format version.static PackReverseIndexWritercreateWriter(OutputStream dst, int version) Create a writer instance for the specified file format version.voidwrite(List<? extends PackedObjectInfo> objectsByIndexPos, byte[] packChecksum) Write the contents of a reverse index file for the given objects.protected abstract voidwriteBody(List<? extends PackedObjectInfo> objectsSortedByIndexPosition) Write the body of a reverse index file, usually the forward index positions of the given objects, sorted by those objects' pack file offsets.protected abstract voidWrite the header of a reverse index file, usually the magic bytes and the file format version.
-
Field Details
-
MAGIC
protected static byte[] MAGICMagic bytes that uniquely identify git reverse index files. -
VERSION_1
protected static final int VERSION_1The first reverse index file version.- See Also:
-
out
Stream to write contents to while maintaining a checksum. -
dataOutput
Stream to write primitive type contents to while maintaining a checksum.
-
-
Constructor Details
-
PackReverseIndexWriter
Construct the components of a PackReverseIndexWriter that are shared between subclasses.- Parameters:
dst- the OutputStream that the instance will write contents to
-
-
Method Details
-
createWriter
Create a writer instance for the default file format version.- Parameters:
dst- the OutputStream that contents will be written to- Returns:
- the new writer instance
-
createWriter
Create a writer instance for the specified file format version.- Parameters:
dst- the OutputStream that contents will be written toversion- the reverse index format version to write contents as- Returns:
- the new writer instance
-
write
public void write(List<? extends PackedObjectInfo> objectsByIndexPos, byte[] packChecksum) throws IOException Write the contents of a reverse index file for the given objects.- Parameters:
objectsByIndexPos- the objects whose forward index file positions should be written, sorted by forward index file position (currently SHA1 ordering)packChecksum- the checksum of the corresponding pack file- Throws:
IOException- if writing the output fails
-
writeHeader
Write the header of a reverse index file, usually the magic bytes and the file format version.- Throws:
IOException- if writing the output fails
-
writeBody
protected abstract void writeBody(List<? extends PackedObjectInfo> objectsSortedByIndexPosition) throws IOException Write the body of a reverse index file, usually the forward index positions of the given objects, sorted by those objects' pack file offsets.- Parameters:
objectsSortedByIndexPosition- the objects whose forward index file positions should be written, sorted by forward index file position; not modified during method- Throws:
IOException- if writing the output fails
-