Class RleDecoder
- java.lang.Object
-
- org.apache.iotdb.tsfile.encoding.decoder.Decoder
-
- org.apache.iotdb.tsfile.encoding.decoder.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 classRleDecoder.Mode
-
Field Summary
Fields Modifier and Type Field Description protected intbitPackingNumnumber of bit-packing group in which is saved in header.protected intbitWidthbit width for bit-packing and rle to decode.protected java.nio.ByteBufferbyteCachebuffer to save data format like [<bitwidth> <encoded-data>] for decoder.protected TSFileConfigconfigprotected intcurrentCountnumber of data left for reading in current buffer.protected booleanisLengthAndBitWidthReadeda flag to indicate whether current pattern is end.protected intlengthhow many bytes for all encoded data like [<bitwidth> <encoded-data>] in inputstream.protected RleDecoder.Modemodemode to indicate current encoding type 0 - RLE 1 - BIT_PACKED.
-
Constructor Summary
Constructors Modifier Constructor Description protectedRleDecoder()a constructor, init with endianType, default encoding isTSEncoding.RLE.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcallReadBitPackingBuffer(int header)intgetHeader()get header for both rle and bit-packing current encode mode which is saved in first bit of header.booleanhasNext(java.nio.ByteBuffer buffer)Check whether there is number left for reading.protected booleanhasNextPackage()Check whether there is another pattern left for reading.protected abstract voidinitPacker()java.math.BigDecimalreadBigDecimal(java.nio.ByteBuffer buffer)BinaryreadBinary(java.nio.ByteBuffer buffer)protected abstract voidreadBitPackingBuffer(int bitPackedGroupCount, int lastBitPackedNum)Read bit-packing package and save them in buffer.booleanreadBoolean(java.nio.ByteBuffer buffer)doublereadDouble(java.nio.ByteBuffer buffer)floatreadFloat(java.nio.ByteBuffer buffer)intreadInt(java.nio.ByteBuffer buffer)protected voidreadLengthAndBitWidth(java.nio.ByteBuffer buffer)read length and bit width of current package before we decode number.longreadLong(java.nio.ByteBuffer buffer)protected voidreadNext()get all encoded data according to mode.protected abstract voidreadNumberInRle()Read rle package and save them in buffer.shortreadShort(java.nio.ByteBuffer buffer)voidreset()-
Methods inherited from class org.apache.iotdb.tsfile.encoding.decoder.Decoder
getDecoderByType, getType, setType
-
-
-
-
Field Detail
-
config
protected TSFileConfig config
-
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.
-
-
Method Detail
-
getHeader
public int getHeader() throws java.io.IOExceptionget 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.IOExceptionget 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.IOExceptionCheck whether there is number left for reading.
-
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.IOExceptionRead 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.IOExceptionRead bit-packing package and save them in buffer.- Parameters:
bitPackedGroupCount- number of group numberlastBitPackedNum- number of useful value in last group- Throws:
java.io.IOException- cannot read bit pack
-
readBoolean
public boolean readBoolean(java.nio.ByteBuffer buffer)
- Overrides:
readBooleanin classDecoder
-
readDouble
public double readDouble(java.nio.ByteBuffer buffer)
- Overrides:
readDoublein classDecoder
-
readBinary
public Binary readBinary(java.nio.ByteBuffer buffer)
- Overrides:
readBinaryin classDecoder
-
readBigDecimal
public java.math.BigDecimal readBigDecimal(java.nio.ByteBuffer buffer)
- Overrides:
readBigDecimalin classDecoder
-
-