Class IndexWriter


  • public class IndexWriter
    extends Object
    Builds an index incrementally in memory, and serializes its contents into a sequence of bytes.
    • 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.