Class UnsafeMemoryOld


  • public class UnsafeMemoryOld
    extends Object
    Wrapper around sun.misc.Unsafe to speedup some memory manipulation
    • Constructor Summary

      Constructors 
      Constructor Description
      UnsafeMemoryOld​(byte[] buffer)
      Wrap byte array
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getAllocated()
      Get total base array size
      boolean getBoolean()
      Read boolean from current position
      byte getByte()
      Read byte from current position
      byte[] getByteArray()
      Read byte[] from current position.
      byte[] getByteArray​(int arraySize)
      Read byte[] from current position.
      double[] getDoubleArray()
      Read double[] from current position.
      int getInt()
      Read integer from current position
      int[] getIntArray()
      Read int array from current position.
      int[] getIntArray​(int arraySize)
      Read int array from current position.
      long getLong()
      Read long from current position
      long[] getLongArray()
      Read long[] from current postion.
      long[] getLongArray​(int arraySize)
      Read long array from current position.
      int getPos()
      Get current position on base array
      void putBoolean​(boolean value)
      Write boolean to current position
      void putByte​(byte value)
      Write byte to current position
      void putByteArray​(byte[] values)
      Write byte[] to current position.
      void putByteArrayRaw​(byte[] values)
      Write byte[] to current position without array length data;
      void putDoubleArray​(double[] values)
      Write double[] to current array.
      void putInt​(int value)
      Write integer to current position
      void putIntArray​(int[] values)
      Write int[] to current position.
      void putIntArrayRaw​(int[] values)
      Write int array to current position without array length data.
      void putLong​(long value)
      Write long to current position
      void putLongArray​(long[] values)
      Write long array to current position.
      void putLongArrayRaw​(long[] values)
      Write long[] to current position without array length data.
      void reset()
      Set position to 0
    • Constructor Detail

      • UnsafeMemoryOld

        public UnsafeMemoryOld​(byte[] buffer)
        Wrap byte array
        Parameters:
        buffer -
    • Method Detail

      • reset

        public void reset()
        Set position to 0
      • putBoolean

        public void putBoolean​(boolean value)
        Write boolean to current position
        Parameters:
        value - boolean to write
      • getBoolean

        public boolean getBoolean()
        Read boolean from current position
        Returns:
        boolean from base array
      • putInt

        public void putInt​(int value)
        Write integer to current position
        Parameters:
        value - integer to write
      • getInt

        public int getInt()
        Read integer from current position
        Returns:
        integer from base array
      • putLong

        public void putLong​(long value)
        Write long to current position
        Parameters:
        value - long to write
      • getLong

        public long getLong()
        Read long from current position
        Returns:
        long from base array
      • putLongArray

        public void putLongArray​(long[] values)
        Write long array to current position. Write array length too;
        Parameters:
        values - long array to write
      • putByte

        public void putByte​(byte value)
        Write byte to current position
        Parameters:
        value - byte to write
      • getByte

        public byte getByte()
        Read byte from current position
        Returns:
        byte from base array
      • putLongArrayRaw

        public void putLongArrayRaw​(long[] values)
        Write long[] to current position without array length data.
        Parameters:
        values - long[] to write
      • getLongArray

        public long[] getLongArray()
        Read long[] from current postion. Array length should be there (by putLongArray method).
        Returns:
        long[] from base array
      • getLongArray

        public long[] getLongArray​(int arraySize)
        Read long array from current position. Array length from parameter
        Parameters:
        arraySize - count of long to read
        Returns:
        long[] from base array
      • getIntArray

        public int[] getIntArray()
        Read int array from current position. Array length should be there (by putIntArray method).
        Returns:
        int[] from base array
      • getIntArray

        public int[] getIntArray​(int arraySize)
        Read int array from current position. Array length from parameter
        Parameters:
        arraySize - count of int to read
        Returns:
        int[] from base array
      • putIntArray

        public void putIntArray​(int[] values)
        Write int[] to current position. Write int array length too.
        Parameters:
        values - int[] to write
      • putIntArrayRaw

        public void putIntArrayRaw​(int[] values)
        Write int array to current position without array length data.
        Parameters:
        values - int[] to write
      • getByteArray

        public byte[] getByteArray()
        Read byte[] from current position. Array length should be there (by putByteArray method)
        Returns:
        byte[] from base array
      • getByteArray

        public byte[] getByteArray​(int arraySize)
        Read byte[] from current position. Array length from parameter.
        Parameters:
        arraySize - count of int to read
        Returns:
        int[] from base array
      • putByteArray

        public void putByteArray​(byte[] values)
        Write byte[] to current position. Write valuer array length data.
        Parameters:
        values - byte[] to write
      • putByteArrayRaw

        public void putByteArrayRaw​(byte[] values)
        Write byte[] to current position without array length data;
        Parameters:
        values - byte[] to write
      • putDoubleArray

        public void putDoubleArray​(double[] values)
        Write double[] to current array. Write values array length data
        Parameters:
        values - double[] to write
      • getDoubleArray

        public double[] getDoubleArray()
        Read double[] from current position. Array length should be there (by putDoubleArray method)
        Returns:
        double[] form base array
      • getPos

        public int getPos()
        Get current position on base array
        Returns:
        current position
      • getAllocated

        public int getAllocated()
        Get total base array size
        Returns:
        base array (allocated) size