Class BlockLine.Serializer

  • All Implemented Interfaces:
    Accountable
    Direct Known Subclasses:
    STBlockLine.Serializer
    Enclosing class:
    BlockLine

    public static class BlockLine.Serializer
    extends java.lang.Object
    implements Accountable
    Reads/writes block lines with terms encoded incrementally inside a block. This class keeps a state of the previous term read to decode the next term.
    • Field Detail

      • BASE_RAM_USAGE

        private static final long BASE_RAM_USAGE
      • currentTerm

        protected final BytesRef currentTerm
    • Constructor Detail

      • Serializer

        public Serializer()
    • Method Detail

      • readLine

        public BlockLine readLine​(DataInput blockInput,
                                  boolean isIncrementalEncodingSeed,
                                  BlockLine reuse)
                           throws java.io.IOException
        Reads the current line.
        Parameters:
        isIncrementalEncodingSeed - Whether the term is a seed of the incremental encoding. true for the first and middle term, false for other terms.
        reuse - A BlockLine instance to reuse; or null if none.
        Throws:
        java.io.IOException
      • writeLine

        public void writeLine​(DataOutput blockOutput,
                              BlockLine line,
                              BlockLine previousLine,
                              int termStateRelativeOffset,
                              boolean isIncrementalEncodingSeed)
                       throws java.io.IOException
        Writes a line and its offset to the corresponding term state details in the details region.
        Parameters:
        blockOutput - The output pointing to the block terms region.
        termStateRelativeOffset - The offset to the corresponding term state details in the details region.
        isIncrementalEncodingSeed - Whether the term is a seed of the incremental encoding. true for the first and middle term, false for other terms.
        Throws:
        java.io.IOException
      • writeLineTermState

        protected void writeLineTermState​(DataOutput termStatesOutput,
                                          BlockLine line,
                                          FieldInfo fieldInfo,
                                          DeltaBaseTermStateSerializer encoder)
                                   throws java.io.IOException
        Writes the term state details of a line in the details region.
        Parameters:
        termStatesOutput - The output pointing to the details region.
        Throws:
        java.io.IOException
      • writeIncrementallyEncodedTerm

        protected void writeIncrementallyEncodedTerm​(TermBytes termBytes,
                                                     TermBytes previousTermBytes,
                                                     boolean isIncrementalEncodingSeed,
                                                     DataOutput blockOutput)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readIncrementallyEncodedTerm

        protected TermBytes readIncrementallyEncodedTerm​(DataInput blockInput,
                                                         boolean isIncrementalEncodingSeed,
                                                         TermBytes reuse)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readBytes

        protected void readBytes​(DataInput input,
                                 BytesRef bytes,
                                 int offset,
                                 int length)
                          throws java.io.IOException
        Reads length bytes from the given DataInput and stores them at offset in bytes.bytes.
        Throws:
        java.io.IOException
      • ramBytesUsed

        public long ramBytesUsed()
        Description copied from interface: Accountable
        Return the memory usage of this object in bytes. Negative values are illegal.
        Specified by:
        ramBytesUsed in interface Accountable
      • numBitsToEncode

        protected static int numBitsToEncode​(int i)
        Gets the number of bits required to encode the value of the provided int. Returns 0 for int value 0. Equivalent to (log2(i) + 1).