Class BitShuffle

java.lang.Object
org.xerial.snappy.BitShuffle

public class BitShuffle extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static BitShuffleNative
    An instance of BitShuffleNative
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 data
      type - element type of the input data
      shuffled - output of the shuffled data. Uses range [pos()..].
      Returns:
      byte size of the shuffled data.
      Throws:
      SnappyError - when the input is not a direct buffer
      IllegalArgumentException - when the input length is not a multiple of the given type size
      IOException
    • shuffle

      public static byte[] shuffle(short[] input) throws IOException
      Apply a bit-shuffling filter into the input short array.
      Parameters:
      input -
      Returns:
      bit-shuffled byte array
      Throws:
      IOException
    • shuffle

      public static byte[] shuffle(int[] input) throws IOException
      Apply a bit-shuffling filter into the input int array.
      Parameters:
      input -
      Returns:
      bit-shuffled byte array
      Throws:
      IOException
    • shuffle

      public static byte[] shuffle(long[] input) throws IOException
      Apply a bit-shuffling filter into the input long array.
      Parameters:
      input -
      Returns:
      bit-shuffled byte array
      Throws:
      IOException
    • shuffle

      public static byte[] shuffle(float[] input) throws IOException
      Apply a bit-shuffling filter into the input float array.
      Parameters:
      input -
      Returns:
      bit-shuffled byte array
      Throws:
      IOException
    • shuffle

      public static byte[] shuffle(double[] input) throws IOException
      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 data
      type - element type of the input data
      output - 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 input
      SnappyError - when the input is not a direct buffer
      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 IOException
      Convert the input bit-shuffled byte array into an original short array.
      Parameters:
      input -
      Returns:
      a short array
      Throws:
      IOException
    • unshuffleIntArray

      public static int[] unshuffleIntArray(byte[] input) throws IOException
      Convert the input bit-shuffled byte array into an original int array.
      Parameters:
      input -
      Returns:
      an int array
      Throws:
      IOException
    • unshuffleLongArray

      public static long[] unshuffleLongArray(byte[] input) throws IOException
      Convert the input bit-shuffled byte array into an original long array.
      Parameters:
      input -
      Returns:
      a long array
      Throws:
      IOException
    • unshuffleFloatArray

      public static float[] unshuffleFloatArray(byte[] input) throws IOException
      Convert the input bit-shuffled byte array into an original float array.
      Parameters:
      input -
      Returns:
      an float array
      Throws:
      IOException
    • unshuffleDoubleArray

      public static double[] unshuffleDoubleArray(byte[] input) throws IOException
      Convert the input bit-shuffled byte array into an original double array.
      Parameters:
      input -
      Returns:
      a double array
      Throws:
      IOException