Class IntPacker
- java.lang.Object
-
- org.apache.iotdb.tsfile.encoding.bitpacking.IntPacker
-
public class IntPacker extends java.lang.ObjectThis class is used to encode(decode) Integer in Java with specified bit-width. User need to guarantee that the length of every given Integer in binary mode is less than or equal to the bit-width.e.g., if bit-width is 4, then Integer '16'(10000)b is not allowed but '15'(1111)b is allowed.
-
-
Constructor Summary
Constructors Constructor Description IntPacker(int width)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidpack8Values(int[] values, int offset, byte[] buf)Encode 8 (NUM_OF_INTS) Integers from the array 'values' with specified bit-width to bytes.voidsetWidth(int width)voidunpack8Values(byte[] buf, int offset, int[] values)decode Integers from byte array.voidunpackAllValues(byte[] buf, int length, int[] values)decode all values from 'buf' with specified offset and length decoded result will be saved in the array named 'values'.
-
-
-
Method Detail
-
pack8Values
public void pack8Values(int[] values, int offset, byte[] buf)Encode 8 (NUM_OF_INTS) Integers from the array 'values' with specified bit-width to bytes.- Parameters:
values- - array where '8 Integers' are inoffset- - the offset of first Integer to be encodedbuf- - encoded bytes, buf size must be equal to (NUM_OF_INTS*width/ 8)
-
unpack8Values
public void unpack8Values(byte[] buf, int offset, int[] values)decode Integers from byte array.- Parameters:
buf- - array where bytes are in.offset- - offset of first byte to be decoded in bufvalues- - decoded result , the length of 'values' should be @{link IntPacker#NUM_OF_INTS}
-
unpackAllValues
public void unpackAllValues(byte[] buf, int length, int[] values)decode all values from 'buf' with specified offset and length decoded result will be saved in the 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)
-
-