Class RleDecoder

  • Direct Known Subclasses:
    IntRleDecoder, LongRleDecoder

    public abstract class RleDecoder
    extends Decoder
    Abstract class for all rle decoder. Decoding values according to following grammar: <length> <bitwidth> <encoded-data>. For more information about rle format, see RleEncoder
    • Field Detail

      • mode

        protected RleDecoder.Mode mode
        mode to indicate current encoding type 0 - RLE 1 - BIT_PACKED.
      • bitWidth

        protected int bitWidth
        bit width for bit-packing and rle to decode.
      • currentCount

        protected int currentCount
        number of data left for reading in current buffer.
      • length

        protected int length
        how many bytes for all encoded data like [<bitwidth> <encoded-data>] in inputstream.
      • isLengthAndBitWidthReaded

        protected boolean isLengthAndBitWidthReaded
        a flag to indicate whether current pattern is end. false - need to start reading a new page true - current page isn't over.
      • byteCache

        protected ByteBuffer byteCache
        buffer to save data format like [<bitwidth> <encoded-data>] for decoder.
      • bitPackingNum

        protected int bitPackingNum
        number of bit-packing group in which is saved in header.
    • Constructor Detail

      • RleDecoder

        protected RleDecoder()
        a constructor, init with endianType, default encoding is TSEncoding.RLE.
    • Method Detail

      • reset

        public void reset()
        Specified by:
        reset in class Decoder
      • getHeader

        public int getHeader()
                      throws IOException
        get header for both rle and bit-packing current encode mode which is saved in first bit of header.
        Returns:
        int value
        Throws:
        IOException - cannot get header
      • readNext

        protected void readNext()
                         throws IOException
        get all encoded data according to mode.
        Throws:
        IOException - cannot read next value
      • callReadBitPackingBuffer

        protected void callReadBitPackingBuffer​(int header)
                                         throws IOException
        Throws:
        IOException
      • readLengthAndBitWidth

        protected void readLengthAndBitWidth​(ByteBuffer buffer)
        read length and bit width of current package before we decode number.
        Parameters:
        buffer - ByteBuffer
      • hasNext

        public boolean hasNext​(ByteBuffer buffer)
                        throws IOException
        Check whether there is number left for reading.
        Specified by:
        hasNext in class Decoder
        Parameters:
        buffer - decoded data saved in ByteBuffer
        Returns:
        true or false to indicate whether there is number left
        Throws:
        IOException - cannot check next value
      • hasNextPackage

        protected boolean hasNextPackage()
        Check whether there is another pattern left for reading.
        Returns:
        true or false to indicate whether there is another pattern left
      • initPacker

        protected abstract void initPacker()
      • readNumberInRle

        protected abstract void readNumberInRle()
                                         throws IOException
        Read rle package and save them in buffer.
        Throws:
        IOException - cannot read number
      • readBitPackingBuffer

        protected abstract void readBitPackingBuffer​(int bitPackedGroupCount,
                                                     int lastBitPackedNum)
                                              throws IOException
        Read bit-packing package and save them in buffer.
        Parameters:
        bitPackedGroupCount - number of group number
        lastBitPackedNum - number of useful value in last group
        Throws:
        IOException - cannot read bit pack