Class PackReverseIndexWriter

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 Details

    • 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 Details

    • 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 Details

    • 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 to
      version - 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 IOException
      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