- java.lang.Object
-
- org.eclipse.jgit.internal.storage.file.PackReverseIndexWriter
-
public abstract class PackReverseIndexWriter extends Object
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
Fields Modifier and Type Field Description protected DataOutputdataOutputStream to write primitive type contents to while maintaining a checksum.protected static byte[]MAGICMagic bytes that uniquely identify git reverse index files.protected DigestOutputStreamoutStream to write contents to while maintaining a checksum.protected static intVERSION_1The first reverse index file version.
-
Constructor Summary
Constructors Modifier Constructor Description protectedPackReverseIndexWriter(OutputStream dst)Construct the components of a PackReverseIndexWriter that are shared between subclasses.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static 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 voidwriteHeader()Write the header of a reverse index file, usually the magic bytes and the file format version.
-
-
-
Field Detail
-
MAGIC
protected static byte[] MAGIC
Magic bytes that uniquely identify git reverse index files.
-
VERSION_1
protected static final int VERSION_1
The first reverse index file version.- See Also:
- Constant Field Values
-
out
protected final DigestOutputStream out
Stream to write contents to while maintaining a checksum.
-
dataOutput
protected final DataOutput dataOutput
Stream to write primitive type contents to while maintaining a checksum.
-
-
Constructor Detail
-
PackReverseIndexWriter
protected PackReverseIndexWriter(OutputStream dst)
Construct the components of a PackReverseIndexWriter that are shared between subclasses.- Parameters:
dst- the OutputStream that the instance will write contents to
-
-
Method Detail
-
createWriter
public static PackReverseIndexWriter createWriter(OutputStream dst)
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
public static PackReverseIndexWriter createWriter(OutputStream dst, int version)
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
protected abstract void writeHeader() throws IOExceptionWrite 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
-
-