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
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  RleDecoder.Mode  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int bitPackingNum
      number of bit-packing group in which is saved in header.
      protected int bitWidth
      bit width for bit-packing and rle to decode.
      protected java.nio.ByteBuffer byteCache
      buffer to save data format like [<bitwidth> <encoded-data>] for decoder.
      protected TSFileConfig config  
      protected int currentCount
      number of data left for reading in current buffer.
      protected boolean isLengthAndBitWidthReaded
      a flag to indicate whether current pattern is end.
      protected int length
      how many bytes for all encoded data like [<bitwidth> <encoded-data>] in inputstream.
      protected RleDecoder.Mode mode
      mode to indicate current encoding type 0 - RLE 1 - BIT_PACKED.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected RleDecoder()
      a constructor, init with endianType, default encoding is TSEncoding.RLE.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void callReadBitPackingBuffer​(int header)  
      int getHeader()
      get header for both rle and bit-packing current encode mode which is saved in first bit of header.
      boolean hasNext​(java.nio.ByteBuffer buffer)
      Check whether there is number left for reading.
      protected boolean hasNextPackage()
      Check whether there is another pattern left for reading.
      protected abstract void initPacker()  
      java.math.BigDecimal readBigDecimal​(java.nio.ByteBuffer buffer)  
      Binary readBinary​(java.nio.ByteBuffer buffer)  
      protected abstract void readBitPackingBuffer​(int bitPackedGroupCount, int lastBitPackedNum)
      Read bit-packing package and save them in buffer.
      boolean readBoolean​(java.nio.ByteBuffer buffer)  
      double readDouble​(java.nio.ByteBuffer buffer)  
      float readFloat​(java.nio.ByteBuffer buffer)  
      int readInt​(java.nio.ByteBuffer buffer)  
      protected void readLengthAndBitWidth​(java.nio.ByteBuffer buffer)
      read length and bit width of current package before we decode number.
      long readLong​(java.nio.ByteBuffer buffer)  
      protected void readNext()
      get all encoded data according to mode.
      protected abstract void readNumberInRle()
      Read rle package and save them in buffer.
      short readShort​(java.nio.ByteBuffer buffer)  
      void reset()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 java.nio.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 java.io.IOException
        get header for both rle and bit-packing current encode mode which is saved in first bit of header.
        Returns:
        int value
        Throws:
        java.io.IOException - cannot get header
      • readNext

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

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

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

        public boolean hasNext​(java.nio.ByteBuffer buffer)
                        throws java.io.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:
        java.io.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 java.io.IOException
        Read rle package and save them in buffer.
        Throws:
        java.io.IOException - cannot read number
      • readBitPackingBuffer

        protected abstract void readBitPackingBuffer​(int bitPackedGroupCount,
                                                     int lastBitPackedNum)
                                              throws java.io.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:
        java.io.IOException - cannot read bit pack
      • readBoolean

        public boolean readBoolean​(java.nio.ByteBuffer buffer)
        Overrides:
        readBoolean in class Decoder
      • readShort

        public short readShort​(java.nio.ByteBuffer buffer)
        Overrides:
        readShort in class Decoder
      • readInt

        public int readInt​(java.nio.ByteBuffer buffer)
        Overrides:
        readInt in class Decoder
      • readLong

        public long readLong​(java.nio.ByteBuffer buffer)
        Overrides:
        readLong in class Decoder
      • readFloat

        public float readFloat​(java.nio.ByteBuffer buffer)
        Overrides:
        readFloat in class Decoder
      • readDouble

        public double readDouble​(java.nio.ByteBuffer buffer)
        Overrides:
        readDouble in class Decoder
      • readBigDecimal

        public java.math.BigDecimal readBigDecimal​(java.nio.ByteBuffer buffer)
        Overrides:
        readBigDecimal in class Decoder