mpjbuf
Class NIOBuffer

java.lang.Object
  extended by mpjbuf.NIOBuffer
All Implemented Interfaces:
RawBuffer
Direct Known Subclasses:
Buddy1Buffer, Buddy2Buffer

public class NIOBuffer
extends java.lang.Object
implements RawBuffer

Native methods implementation of `RawBuffer'. Apart from array bounds checking in `gather' and `scatter', none of these methods check validity of arguments. Passing invalid arguments will generally crash the JVM. So direct use of this class is very unsafe. This class is designed specifically for use from `mpjbuf.Buffer', which provides all the necessary guarantees.


Constructor Summary
NIOBuffer(int capacity, java.nio.ByteBuffer slicedBuffer)
           
 
Method Summary
 void clear()
           
 void copy(java.nio.ByteBuffer srcBuffer, int srcOffset, int srcLength, int dstOffset)
           
 void free()
           
 int gather(boolean[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 int gather(byte[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 int gather(char[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 int gather(double[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 int gather(float[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 int gather(int[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 int gather(long[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 int gather(short[] source, int numEls, int offs, int[] indexes, int bufOff)
           
 java.nio.ByteBuffer getBuffer()
           
 int getByte(int bufOff)
           
 int getCapacity()
           
 int getInt(int bufOff, boolean revBytes)
           
 void putByte(int value, int bufOff)
           
 void putInt(int value, int bufOff)
           
 void read(boolean[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 void read(byte[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 void read(char[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 void read(double[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 void read(float[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 void read(int[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 void read(long[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 void read(short[] dest, int dstOff, int numEls, int bufOff, boolean revBytes)
           
 int scatter(boolean[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 int scatter(byte[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 int scatter(char[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 int scatter(double[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 int scatter(float[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 int scatter(int[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 int scatter(long[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 int scatter(short[] dest, int numEls, int offs, int[] indexes, int bufOff, boolean revBytes)
           
 void setBuffer(java.nio.ByteBuffer buf)
           
 void setEncoding(java.nio.ByteOrder order)
           
 void strGather(boolean[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strGather(byte[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strGather(char[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strGather(double[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strGather(float[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strGather(int[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strGather(long[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strGather(short[] source, int srcOff, int rank, int exts, int strs, int[] shape, int bufOff)
           
 void strScatter(boolean[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void strScatter(byte[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void strScatter(char[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void strScatter(double[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void strScatter(float[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void strScatter(int[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void strScatter(long[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void strScatter(short[] dest, int dstOff, int rank, int exts, int strs, int[] shape, int bufOff, boolean revBytes)
           
 void write(boolean[] source, int srcOff, int numEls, int bufOff)
          BOOLEAN
 void write(byte[] source, int srcOff, int numEls, int bufOff)
          BYTE
 void write(char[] source, int srcOff, int numEls, int bufOff)
          CHAR
 void write(double[] source, int srcOff, int numEls, int bufOff)
          DOUBLE
 void write(float[] source, int srcOff, int numEls, int bufOff)
          FLOAT
 void write(int[] source, int srcOff, int numEls, int bufOff)
          INT
 void write(long[] source, int srcOff, int numEls, int bufOff)
          LONG
 void write(short[] source, int srcOff, int numEls, int bufOff)
          SHORT
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NIOBuffer

public NIOBuffer(int capacity,
                 java.nio.ByteBuffer slicedBuffer)
Method Detail

copy

public void copy(java.nio.ByteBuffer srcBuffer,
                 int srcOffset,
                 int srcLength,
                 int dstOffset)
Specified by:
copy in interface RawBuffer

getCapacity

public int getCapacity()
Specified by:
getCapacity in interface RawBuffer

setBuffer

public void setBuffer(java.nio.ByteBuffer buf)

getBuffer

public java.nio.ByteBuffer getBuffer()

setEncoding

public void setEncoding(java.nio.ByteOrder order)

free

public void free()
Specified by:
free in interface RawBuffer

clear

public void clear()

putByte

public void putByte(int value,
                    int bufOff)
Specified by:
putByte in interface RawBuffer

getByte

public int getByte(int bufOff)
Specified by:
getByte in interface RawBuffer

putInt

public void putInt(int value,
                   int bufOff)
Specified by:
putInt in interface RawBuffer

getInt

public int getInt(int bufOff,
                  boolean revBytes)
Specified by:
getInt in interface RawBuffer

write

public void write(byte[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
BYTE

Specified by:
write in interface RawBuffer

gather

public int gather(byte[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(byte[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(byte[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(byte[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(byte[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer

write

public void write(short[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
SHORT

Specified by:
write in interface RawBuffer

gather

public int gather(short[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(short[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(short[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(short[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(short[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer

write

public void write(int[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
INT

Specified by:
write in interface RawBuffer

gather

public int gather(int[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(int[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(int[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(int[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(int[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer

write

public void write(long[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
LONG

Specified by:
write in interface RawBuffer

gather

public int gather(long[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(long[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(long[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(long[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(long[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer

write

public void write(char[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
CHAR

Specified by:
write in interface RawBuffer

gather

public int gather(char[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(char[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(char[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(char[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(char[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer

write

public void write(float[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
FLOAT

Specified by:
write in interface RawBuffer

gather

public int gather(float[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(float[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(float[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(float[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(float[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer

write

public void write(double[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
DOUBLE

Specified by:
write in interface RawBuffer

gather

public int gather(double[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(double[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(double[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(double[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(double[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer

write

public void write(boolean[] source,
                  int srcOff,
                  int numEls,
                  int bufOff)
BOOLEAN

Specified by:
write in interface RawBuffer

gather

public int gather(boolean[] source,
                  int numEls,
                  int offs,
                  int[] indexes,
                  int bufOff)
Specified by:
gather in interface RawBuffer

strGather

public void strGather(boolean[] source,
                      int srcOff,
                      int rank,
                      int exts,
                      int strs,
                      int[] shape,
                      int bufOff)
Specified by:
strGather in interface RawBuffer

read

public void read(boolean[] dest,
                 int dstOff,
                 int numEls,
                 int bufOff,
                 boolean revBytes)
Specified by:
read in interface RawBuffer

scatter

public int scatter(boolean[] dest,
                   int numEls,
                   int offs,
                   int[] indexes,
                   int bufOff,
                   boolean revBytes)
Specified by:
scatter in interface RawBuffer

strScatter

public void strScatter(boolean[] dest,
                       int dstOff,
                       int rank,
                       int exts,
                       int strs,
                       int[] shape,
                       int bufOff,
                       boolean revBytes)
Specified by:
strScatter in interface RawBuffer