Class BitShuffle


  • public class BitShuffle
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static BitShuffleNative impl
      An instance of BitShuffleNative
    • 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 int shuffle​(java.nio.ByteBuffer input, BitShuffleType type, java.nio.ByteBuffer shuffled)
      Apply a bit-shuffling filter into the content in the given input buffer.
      static int unshuffle​(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BitShuffle

        public BitShuffle()
    • Method Detail

      • shuffle

        public static int shuffle​(java.nio.ByteBuffer input,
                                  BitShuffleType type,
                                  java.nio.ByteBuffer shuffled)
                           throws java.io.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
        java.lang.IllegalArgumentException - when the input length is not a multiple of the given type size
        java.io.IOException
      • shuffle

        public static byte[] shuffle​(short[] input)
                              throws java.io.IOException
        Apply 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.IOException
        Apply 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.IOException
        Apply 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.IOException
        Apply 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.IOException
        Apply 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.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:
        java.io.IOException - when failed to unshuffle the given input
        SnappyError - when the input is not a direct buffer
        java.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.IOException
        Convert 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.IOException
        Convert 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.IOException
        Convert 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.IOException
        Convert 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.IOException
        Convert the input bit-shuffled byte array into an original double array.
        Parameters:
        input -
        Returns:
        a double array
        Throws:
        java.io.IOException