Class LongPacker
- java.lang.Object
-
- org.apache.iotdb.tsfile.encoding.bitpacking.LongPacker
-
public class LongPacker extends java.lang.ObjectThis class is used to encode(decode) Long in Java with specified bit-width. User need to guarantee that the length of every given Long in binary mode is less than or equal to the bit-width.e.g., if bit-width is 31, then Long '2147483648'(2^31) is not allowed but '2147483647'(2^31-1) is allowed.
-
-
Constructor Summary
Constructors Constructor Description LongPacker(int width)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidpack8Values(long[] values, int offset, byte[] buf)Encode 8 (NUM_OF_LONGS) Longs from the array 'values' with specified bit-width to bytes.voidsetWidth(int width)voidunpack8Values(byte[] buf, int offset, long[] values)decode values from byte array.voidunpackAllValues(byte[] buf, int length, long[] values)decode all values from 'buf' with specified offset and length decoded result will be saved in array named 'values'.
-
-
-
Method Detail
-
pack8Values
public void pack8Values(long[] values, int offset, byte[] buf)Encode 8 (NUM_OF_LONGS) Longs from the array 'values' with specified bit-width to bytes.- Parameters:
values- - array where '8 Longs' are inoffset- - the offset of first Long to be encodedbuf- - encoded bytes, buf size must be equal to (NUM_OF_LONGS} *IntPacker.width/ 8)
-
unpack8Values
public void unpack8Values(byte[] buf, int offset, long[] values)decode values from byte array.- Parameters:
buf- - array where bytes are in.offset- - offset of first byte to be decoded in bufvalues- - decoded result , the size of values should be 8
-
unpackAllValues
public void unpackAllValues(byte[] buf, int length, long[] values)decode all values from 'buf' with specified offset and length decoded result will be saved in array named 'values'.- Parameters:
buf- array where all bytes are in.length- length of bytes to be decoded in buf.values- decoded result
-
setWidth
public void setWidth(int width)
-
-