Class DeltaBinaryEncoder
- java.lang.Object
-
- org.apache.iotdb.tsfile.encoding.encoder.Encoder
-
- org.apache.iotdb.tsfile.encoding.encoder.DeltaBinaryEncoder
-
- Direct Known Subclasses:
DeltaBinaryEncoder.IntDeltaEncoder,DeltaBinaryEncoder.LongDeltaEncoder
public abstract class DeltaBinaryEncoder extends Encoder
DeltaBinaryEncoder is a encoder for compressing data in type of integer and long. We adapt a hypothesis that contiguous data points have similar values. Thus the difference value of two adjacent points is smaller than those two point values. One integer in java takes 32-bits. If a positive number is less than 2^m, the bits of this integer which index from m to 31 are all 0. Given an array which length is n, if all values in input data array are all positive and less than 2^m, we need actually m*n, but not 32*n bits to store the array.DeltaBinaryEncoder calculates difference between two adjacent points and record the minimum of those difference values firstly. Then it saves two_diff value that difference minus minimum of them, to make sure all two_diff values are positive. Then it statistics the longest bit length
mit takes for each two_diff value, which means the bit length that maximum two_diff value takes. Only the low m bits are saved into result byte array for all two_diff values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeltaBinaryEncoder.IntDeltaEncoderstatic classDeltaBinaryEncoder.LongDeltaEncoder
-
Field Summary
Fields Modifier and Type Field Description protected static intBLOCK_DEFAULT_SIZEprotected intblockSizeprotected byte[]encodingBlockBufferprotected java.io.ByteArrayOutputStreamoutprotected intwriteIndexprotected intwriteWidth-
Fields inherited from class org.apache.iotdb.tsfile.encoding.encoder.Encoder
MAX_POINT_NUMBER, MAX_STRING_LENGTH
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDeltaBinaryEncoder(int size)constructor of DeltaBinaryEncoder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidcalcTwoDiff(int i)protected abstract intcalculateBitWidthsForDeltaBlockBuffer()voidflush(java.io.ByteArrayOutputStream out)calling this method to flush all values which haven't encoded to result byte array.protected abstract voidreset()protected abstract voidwriteHeader()protected abstract voidwriteValueToBytes(int i)
-
-
-
Field Detail
-
BLOCK_DEFAULT_SIZE
protected static final int BLOCK_DEFAULT_SIZE
- See Also:
- Constant Field Values
-
out
protected java.io.ByteArrayOutputStream out
-
blockSize
protected int blockSize
-
encodingBlockBuffer
protected byte[] encodingBlockBuffer
-
writeIndex
protected int writeIndex
-
writeWidth
protected int writeWidth
-
-
Method Detail
-
writeHeader
protected abstract void writeHeader() throws java.io.IOException- Throws:
java.io.IOException
-
writeValueToBytes
protected abstract void writeValueToBytes(int i)
-
calcTwoDiff
protected abstract void calcTwoDiff(int i)
-
reset
protected abstract void reset()
-
calculateBitWidthsForDeltaBlockBuffer
protected abstract int calculateBitWidthsForDeltaBlockBuffer()
-
-