Package org.xerial.snappy
Class BitShuffle
- java.lang.Object
-
- org.xerial.snappy.BitShuffle
-
public class BitShuffle extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description BitShuffle()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 intshuffle(java.nio.ByteBuffer input, BitShuffleType type, java.nio.ByteBuffer shuffled)Apply a bit-shuffling filter into the content in the given input buffer.static intunshuffle(java.nio.ByteBuffer shuffled, BitShuffleType type, java.nio.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.
-
-
-
Method Detail
-
shuffle
public static int shuffle(java.nio.ByteBuffer input, BitShuffleType type, java.nio.ByteBuffer shuffled) throws java.io.IOExceptionApply 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 bufferjava.lang.IllegalArgumentException- when the input length is not a multiple of the given type sizejava.io.IOException
-
shuffle
public static byte[] shuffle(short[] input) throws java.io.IOExceptionApply a bit-shuffling filter into the input short array.- Parameters:
input-- Returns:
- bit-shuffled byte array
- Throws:
java.io.IOException
-
shuffle
public static byte[] shuffle(int[] input) throws java.io.IOExceptionApply a bit-shuffling filter into the input int array.- Parameters:
input-- Returns:
- bit-shuffled byte array
- Throws:
java.io.IOException
-
shuffle
public static byte[] shuffle(long[] input) throws java.io.IOExceptionApply a bit-shuffling filter into the input long array.- Parameters:
input-- Returns:
- bit-shuffled byte array
- Throws:
java.io.IOException
-
shuffle
public static byte[] shuffle(float[] input) throws java.io.IOExceptionApply a bit-shuffling filter into the input float array.- Parameters:
input-- Returns:
- bit-shuffled byte array
- Throws:
java.io.IOException
-
shuffle
public static byte[] shuffle(double[] input) throws java.io.IOExceptionApply a bit-shuffling filter into the input double array.- Parameters:
input-- Returns:
- bit-shuffled byte array
- Throws:
java.io.IOException
-
unshuffle
public static int unshuffle(java.nio.ByteBuffer shuffled, BitShuffleType type, java.nio.ByteBuffer output) throws java.io.IOExceptionConvert 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:
java.io.IOException- when failed to unshuffle the given inputSnappyError- when the input is not a direct bufferjava.lang.IllegalArgumentException- when the length of input shuffled data is not a multiple of the given type size
-
unshuffleShortArray
public static short[] unshuffleShortArray(byte[] input) throws java.io.IOExceptionConvert the input bit-shuffled byte array into an original short array.- Parameters:
input-- Returns:
- a short array
- Throws:
java.io.IOException
-
unshuffleIntArray
public static int[] unshuffleIntArray(byte[] input) throws java.io.IOExceptionConvert the input bit-shuffled byte array into an original int array.- Parameters:
input-- Returns:
- an int array
- Throws:
java.io.IOException
-
unshuffleLongArray
public static long[] unshuffleLongArray(byte[] input) throws java.io.IOExceptionConvert the input bit-shuffled byte array into an original long array.- Parameters:
input-- Returns:
- a long array
- Throws:
java.io.IOException
-
unshuffleFloatArray
public static float[] unshuffleFloatArray(byte[] input) throws java.io.IOExceptionConvert the input bit-shuffled byte array into an original float array.- Parameters:
input-- Returns:
- an float array
- Throws:
java.io.IOException
-
unshuffleDoubleArray
public static double[] unshuffleDoubleArray(byte[] input) throws java.io.IOExceptionConvert the input bit-shuffled byte array into an original double array.- Parameters:
input-- Returns:
- a double array
- Throws:
java.io.IOException
-
-