Class SBIIndexWriter


  • public final class SBIIndexWriter
    extends Object
    Writes SBI files as understood by SBIIndex.

    To use this class, first construct an instance from an output stream, and a desired granularity. Then for each record in the file being indexed, pass the virtual file offset of the record to the processRecord(long) method. The indexer will keep a count of the records passed in an index every nth record. When there are no records left call finish(long, long) to complete writing the index.

    • Constructor Detail

      • SBIIndexWriter

        public SBIIndexWriter​(OutputStream out)
        Prepare to write an SBI index with the default granularity.
        Parameters:
        out - the stream to write the index to
      • SBIIndexWriter

        public SBIIndexWriter​(OutputStream out,
                              long granularity)
        Prepare to write an SBI index.
        Parameters:
        out - the stream to write the index to
        granularity - write the offset of every nth record to the index
    • Method Detail

      • processRecord

        public void processRecord​(long virtualOffset)
        Process a record for the index: the offset of every nth record will be written to the index.
        Parameters:
        virtualOffset - virtual file pointer of the record
      • finish

        public void finish​(long finalVirtualOffset,
                           long dataFileLength)
        Complete the index, and close the output stream.
        Parameters:
        finalVirtualOffset - the virtual offset at which the next record would start if it were added to the file
        dataFileLength - the length of the data file in bytes
      • finish

        public void finish​(long finalVirtualOffset,
                           long dataFileLength,
                           byte[] md5,
                           byte[] uuid)
        Complete the index, and close the output stream.
        Parameters:
        finalVirtualOffset - the virtual offset at which the next record would start if it were added to the file
        dataFileLength - the length of the data file in bytes
        md5 - the MD5 hash of the data file, or null if not specified
        uuid - the UUID for the data file, or null if not specified