Class IndexWriter


  • public class IndexWriter
    extends java.lang.Object
    Builds an index incrementally in memory, and serializes its contents into a sequence of bytes.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEntry​(long msb, long lsb, int offset, int size, int generation, int fullGeneration, boolean isCompacted)
      Add an entry to this index.
      static IndexWriter newIndexWriter​(int blockSize)
      Create a new IndexWriter for the specified block size.
      byte[] write()
      Serializes the content of the index.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • newIndexWriter

        public static IndexWriter newIndexWriter​(int blockSize)
        Create a new IndexWriter for the specified block size. The block size is needed to ensure that the data produced by the returned IndexWriter is aligned to a specified boundary, i.e. is a multiple of the block size.
        Parameters:
        blockSize - The block size. It must be strictly positive.
        Returns:
        An index of IndexWriter.
      • addEntry

        public void addEntry​(long msb,
                             long lsb,
                             int offset,
                             int size,
                             int generation,
                             int fullGeneration,
                             boolean isCompacted)
        Add an entry to this index.
        Parameters:
        msb - The most significant bits of the entry identifier.
        lsb - The least significant bits of the entry identifier.
        offset - The position of the entry in the file.
        size - The size of the entry.
        generation - The generation of the entry.
        fullGeneration - The full generation of the entry.
        isCompacted - Whether the entry is generated as part of a compaction operation.
      • write

        public byte[] write()
        Serializes the content of the index. The returned array of bytes is always a multiple of the block size specified when this IndexWriter was created.
        Returns:
        the serialized content of the index.