public class SimpleNIOBuffer extends BaseNIOBuffer
java.nio.ByteBuffer of one-byte items.PyBuffer.PointerstorageONE, ZEROANY_CONTIGUOUS, AS_ARRAY, C_CONTIGUOUS, CONTIG, CONTIG_RO, CONTIGUITY, F_CONTIGUOUS, FORMAT, FULL, FULL_RO, INDIRECT, IS_C_CONTIGUOUS, IS_F_CONTIGUOUS, MAX_NDIM, NAVIGATION, ND, RECORDS, RECORDS_RO, SIMPLE, STRIDED, STRIDED_RO, STRIDES, WRITABLE| Modifier | Constructor and Description |
|---|---|
protected |
SimpleNIOBuffer(BufferProtocol obj,
java.nio.ByteBuffer storage)
Provide an instance of
SimpleNIOBuffer, on the entirety of a ByteBuffer,
with navigation variables initialised, for sub-class use. |
protected |
SimpleNIOBuffer(BufferProtocol obj,
java.nio.ByteBuffer storage,
int index0,
int size)
Provide an instance of
SimpleNIOBuffer with navigation variables initialised,
for sub-class use. |
|
SimpleNIOBuffer(int flags,
BufferProtocol obj,
java.nio.ByteBuffer storage)
Provide an instance of
SimpleNIOBuffer, on the entirety of a ByteBuffer,
meeting the consumer's expectations as expressed in the flags argument, which is
checked against the capabilities of the buffer type. |
|
SimpleNIOBuffer(int flags,
BufferProtocol obj,
java.nio.ByteBuffer storage,
int index0,
int size)
Provide an instance of
SimpleNIOBuffer, on a slice of a ByteBuffer,
meeting the consumer's expectations as expressed in the flags argument, which is
checked against the capabilities of the buffer type. |
| Modifier and Type | Method and Description |
|---|---|
int |
byteIndex(int index)
Convert an item index (for a one-dimensional buffer) to an absolute byte index in the storage
shared by the exporter.
|
PyBuffer |
getBufferSlice(int flags,
int start,
int count)
Equivalent to
PyBuffer.getBufferSlice(int, int, int, int) with stride 1. |
PyBuffer |
getBufferSlice(int flags,
int start,
int count,
int stride)
Get a
PyBuffer that represents a slice of the current one described in terms of
a start index, number of items to include in the slice, and the stride in the current buffer. |
int |
getLen()
The total number of bytes represented by the view, which will be the product of the elements
of the
shape array, and the item size in bytes. |
byteAtImpl, byteIndex, copyFrom, copyFrom, copyTo, copyTo, copyTo, getBuf, getNIOByteBufferImpl, storeAtImplcalcGreatestIndex, calcLeastIndex, getSize, isContiguousaddFeatureFlags, bufferIsNot, bufferReleased, bufferRequires, byteAt, byteAt, checkHasArray, checkRequestFlags, checkWritable, close, copyFrom, copyTo, differentStructure, getBuffer, getBufferAgain, getFeatureFlags, getFormat, getItemsize, getNdim, getNIOByteBuffer, getObj, getPointer, getPointer, getRoot, getShape, getStrides, getSuboffsets, hasArray, intAt, intAt, isReadonly, isReleased, notWritable, release, releaseAction, removeFeatureFlags, setFeatureFlags, storeAt, storeAt, toStringprotected SimpleNIOBuffer(BufferProtocol obj, java.nio.ByteBuffer storage, int index0, int size) throws PyException, java.lang.ArrayIndexOutOfBoundsException
SimpleNIOBuffer with navigation variables initialised,
for sub-class use. The buffer (BaseNIOBuffer.storage, BaseBuffer.index0), and the BaseBuffer.shape
array will be initialised from the arguments (which are checked for range). The
BaseBuffer.strides is set for (one-byte) unit stride. Only the call to
BaseBuffer.checkRequestFlags(int), passing the consumer's request flags, really remains for the
sub-class constructor to do.
super(storage.duplicate(), index0, size); checkRequestFlags(flags); // Check request is compatible with type
obj - exporting object (or null)storage - the ByteBuffer wrapping the exported object state. NOTE: this
PyBuffer keeps a reference and may manipulate the position, mark and
limit hereafter. Use ByteBuffer.duplicate() to give it an isolated copy.index0 - offset where the data starts in that array (item[0])size - the number of bytes occupiedjava.lang.NullPointerException - if storage is nulljava.lang.ArrayIndexOutOfBoundsException - if index0 and size are
inconsistent with storage.capacity()PyExceptionpublic SimpleNIOBuffer(int flags,
BufferProtocol obj,
java.nio.ByteBuffer storage,
int index0,
int size)
throws PyException,
java.lang.ArrayIndexOutOfBoundsException,
java.lang.NullPointerException
SimpleNIOBuffer, on a slice of a ByteBuffer,
meeting the consumer's expectations as expressed in the flags argument, which is
checked against the capabilities of the buffer type. No reference will be kept to the
ByteBuffer passed in. (It is duplicated.)flags - consumer requirementsobj - exporting object (or null)storage - the ByteBuffer wrapping the exported object stateindex0 - offset where the data starts in that buffer (item[0])size - the number of bytes occupiedjava.lang.NullPointerException - if storage is nulljava.lang.ArrayIndexOutOfBoundsException - if index0 and size are
inconsistent with storage.lengthPyException - BufferError when expectations do not correspond with the typeprotected SimpleNIOBuffer(BufferProtocol obj, java.nio.ByteBuffer storage) throws java.lang.NullPointerException
SimpleNIOBuffer, on the entirety of a ByteBuffer,
with navigation variables initialised, for sub-class use. The buffer ( BaseNIOBuffer.storage,
BaseBuffer.index0), and the navigation (BaseBuffer.shape array) will be initialised from the
argument.obj - exporting object (or null)storage - the ByteBuffer wrapping the exported object state. NOTE: this
PyBuffer keeps a reference and may manipulate the position, mark and
limit hereafter. Use ByteBuffer.duplicate() to give it an isolated copy.java.lang.NullPointerException - if storage is nullpublic SimpleNIOBuffer(int flags,
BufferProtocol obj,
java.nio.ByteBuffer storage)
throws PyException,
java.lang.NullPointerException
SimpleNIOBuffer, on the entirety of a ByteBuffer,
meeting the consumer's expectations as expressed in the flags argument, which is
checked against the capabilities of the buffer type. No reference will be kept to the
ByteBuffer passed in. (It is duplicated.)flags - consumer requirementsobj - exporting object (or null)storage - the ByteBuffer wrapping the exported object statejava.lang.NullPointerException - if storage is nullPyException - BufferError when expectations do not correspond with the typepublic int getLen()
shape array, and the item size in bytes.
SimpleNIOBuffer provides an implementation optimised for contiguous bytes in
one-dimension.
getLen in interface PyBUFgetLen in class Base1DBufferpublic final int byteIndex(int index)
throws java.lang.IndexOutOfBoundsException
PyBufferPyBuffer is a linearly-indexed
sequence of bytes, although it may not actually be a heap-allocated Java byte[]
object. The purpose of this method is to allow the exporter to define the relationship
between the item index (as used in PyBuffer.byteAt(int)) and the byte-index (as used with the
ByteBuffer returned by PyBuffer.getNIOByteBuffer()). See
PyBuffer.byteIndex(int[]) for discussion of the multi-dimensional case.byteIndex in interface PyBufferbyteIndex in class BaseBufferindex - item-index from consumerjava.lang.IndexOutOfBoundsExceptionpublic PyBuffer getBufferSlice(int flags, int start, int count)
PyBufferPyBuffer.getBufferSlice(int, int, int, int) with stride 1.getBufferSlice in interface PyBuffergetBufferSlice in class BaseBufferflags - specifying features demanded and the navigational capabilities of the consumerstart - index in the current buffercount - number of items in the required slicepublic PyBuffer getBufferSlice(int flags, int start, int count, int stride)
PyBuffer that represents a slice of the current one described in terms of
a start index, number of items to include in the slice, and the stride in the current buffer.
A consumer that obtains a PyBuffer with getBufferSlice must release
it with PyBuffer.release() just as if it had been obtained with
PyBuffer.getBuffer(int)
Suppose that x(i) denotes the ith element of the current buffer, that is, the
byte retrieved by this.byteAt(i) or the unit indicated by
this.getPointer(i). A request for a slice where start = s,
count = N and stride = m, results in a buffer
y such that y(k) = x(s+km) where k=0..(N-1). In Python terms, this is
the slice x[s : s+(N-1)m+1 : m] (if m>0) or the slice x[s : s+(N-1)m-1 :
m] (if m<0). Implementations should check that this range is entirely within
the current buffer.
In a simple buffer backed by a contiguous byte array, the result is a strided PyBuffer on the
same storage but where the offset is adjusted by s and the stride is as supplied. If
the current buffer is already strided and/or has an item size larger than single bytes, the
new start index, count and stride will be translated
from the arguments given, through this buffer's stride and item size. The caller always
expresses start and strides in terms of the abstract view of this
buffer.
SimpleNIOBuffer provides an implementation for slicing contiguous bytes in one
dimension. In that case, x(i) = u(r+i) for i = 0..L-1 where u is the underlying
buffer, and r and L are the start and count with which x was created
from u. Thus y(k) = u(r+s+km), that is, the composite offset is r+s and
the stride is m.
flags - specifying features demanded and the navigational capabilities of the consumerstart - index in the current buffercount - number of items in the required slicestride - index-distance in the current buffer between consecutive items in the slice