Package org.xerial.snappy
Class BitShuffle
java.lang.Object
org.xerial.snappy.BitShuffle
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
shuffle
(double[] input) Apply a bit-shuffling filter into the input double array.static byte[]
shuffle
(float[] input) Apply a bit-shuffling filter into the input float array.static byte[]
shuffle
(int[] input) Apply a bit-shuffling filter into the input int array.static byte[]
shuffle
(long[] input) Apply a bit-shuffling filter into the input long array.static byte[]
shuffle
(short[] input) Apply a bit-shuffling filter into the input short array.static int
shuffle
(ByteBuffer input, BitShuffleType type, ByteBuffer shuffled) Apply a bit-shuffling filter into the content in the given input buffer.static int
unshuffle
(ByteBuffer shuffled, BitShuffleType type, ByteBuffer output) Convert the input bit-shuffled byte array into an original array.static double[]
unshuffleDoubleArray
(byte[] input) Convert the input bit-shuffled byte array into an original double array.static float[]
unshuffleFloatArray
(byte[] input) Convert the input bit-shuffled byte array into an original float array.static int[]
unshuffleIntArray
(byte[] input) Convert the input bit-shuffled byte array into an original int array.static long[]
unshuffleLongArray
(byte[] input) Convert the input bit-shuffled byte array into an original long array.static short[]
unshuffleShortArray
(byte[] input) Convert the input bit-shuffled byte array into an original short array.
-
Field Details
-
impl
An instance of BitShuffleNative
-
-
Constructor Details
-
BitShuffle
public BitShuffle()
-
-
Method Details
-
shuffle
public static int shuffle(ByteBuffer input, BitShuffleType type, ByteBuffer shuffled) throws IOException Apply a bit-shuffling filter into the content in the given input buffer. After bit-shuffling, you can retrieve the shuffled data from the output buffer [pos() ...limit()) (shuffled data size = limit() - pos() = remaining()).- Parameters:
input
- buffer[pos() ... limit()) containing the input datatype
- element type of the input datashuffled
- output of the shuffled data. Uses range [pos()..].- Returns:
- byte size of the shuffled data.
- Throws:
SnappyError
- when the input is not a direct bufferIllegalArgumentException
- when the input length is not a multiple of the given type sizeIOException
-
shuffle
Apply a bit-shuffling filter into the input short array.- Parameters:
input
-- Returns:
- bit-shuffled byte array
- Throws:
IOException
-
shuffle
Apply a bit-shuffling filter into the input int array.- Parameters:
input
-- Returns:
- bit-shuffled byte array
- Throws:
IOException
-
shuffle
Apply a bit-shuffling filter into the input long array.- Parameters:
input
-- Returns:
- bit-shuffled byte array
- Throws:
IOException
-
shuffle
Apply a bit-shuffling filter into the input float array.- Parameters:
input
-- Returns:
- bit-shuffled byte array
- Throws:
IOException
-
shuffle
Apply a bit-shuffling filter into the input double array.- Parameters:
input
-- Returns:
- bit-shuffled byte array
- Throws:
IOException
-
unshuffle
public static int unshuffle(ByteBuffer shuffled, BitShuffleType type, ByteBuffer output) throws IOException Convert the input bit-shuffled byte array into an original array. The result is dumped to the specified output buffer.- Parameters:
shuffled
- buffer[pos() ... limit()) containing the input shuffled datatype
- element type of the input dataoutput
- output of the the original data. It uses buffer[pos()..]- Returns:
- byte size of the unshuffled data.
- Throws:
IOException
- when failed to unshuffle the given inputSnappyError
- when the input is not a direct bufferIllegalArgumentException
- when the length of input shuffled data is not a multiple of the given type size
-
unshuffleShortArray
Convert the input bit-shuffled byte array into an original short array.- Parameters:
input
-- Returns:
- a short array
- Throws:
IOException
-
unshuffleIntArray
Convert the input bit-shuffled byte array into an original int array.- Parameters:
input
-- Returns:
- an int array
- Throws:
IOException
-
unshuffleLongArray
Convert the input bit-shuffled byte array into an original long array.- Parameters:
input
-- Returns:
- a long array
- Throws:
IOException
-
unshuffleFloatArray
Convert the input bit-shuffled byte array into an original float array.- Parameters:
input
-- Returns:
- an float array
- Throws:
IOException
-
unshuffleDoubleArray
Convert the input bit-shuffled byte array into an original double array.- Parameters:
input
-- Returns:
- a double array
- Throws:
IOException
-