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 DataOutput
Stream to write primitive type contents to while maintaining a checksum.protected final DigestOutputStream
Stream to write contents to while maintaining a checksum. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct the components of a PackReverseIndexWriter that are shared between subclasses. -
Method Summary
Modifier and TypeMethodDescriptionstatic PackReverseIndexWriter
createWriter
(OutputStream dst) Create a writer instance for the default file format version.static PackReverseIndexWriter
createWriter
(OutputStream dst, int version) Create a writer instance for the specified file format version.void
write
(List<? extends PackedObjectInfo> objectsByIndexPos, byte[] packChecksum) Write the contents of a reverse index file for the given objects.protected abstract void
writeBody
(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 void
Write the header of a reverse index file, usually the magic bytes and the file format version.
-
Field Details
-
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
-