public interface DataBuffer
extends java.io.Serializable, java.lang.AutoCloseable
Modifier and Type | Interface and Description |
---|---|
static class |
DataBuffer.AllocationMode
Mainly used for backward compatability.
|
static class |
DataBuffer.TypeEx |
Modifier and Type | Method and Description |
---|---|
void |
addReferencing(java.lang.String id)
Add a referencing element to this buffer
|
long |
address()
Returns the address of the pointer
|
org.bytedeco.javacpp.Pointer |
addressPointer()
Returns the address of the pointer wrapped in a Pointer
|
DataBuffer.AllocationMode |
allocationMode()
Allocation mode for buffers
|
java.lang.Object |
array()
Returns the backing array
of this buffer (if there is one)
|
byte[] |
asBytes()
Raw byte array storage
|
double[] |
asDouble()
Return the buffer as a double array
Relative to the datatype, this will either be a copy
or a reference.
|
float[] |
asFloat()
Return the buffer as a float array
Relative to the datatype, this will either be a copy
or a reference.
|
int[] |
asInt()
Return the buffer as an int array
Relative to the datatype, this will either be a copy
or a reference.
|
long[] |
asLong()
Return the buffer as an long array
Relative to the datatype, this will either be a copy
or a reference.
|
java.nio.ByteBuffer |
asNio()
Returns a view of this as an
nio byte buffer
|
java.nio.DoubleBuffer |
asNioDouble()
Returns a view of this as an
nio byte buffer
|
java.nio.FloatBuffer |
asNioFloat()
Returns a view of this as an
nio byte buffer
|
java.nio.IntBuffer |
asNioInt()
Returns a view of this as an
nio byte buffer
|
java.nio.LongBuffer |
asNioLong() |
void |
assign(DataBuffer... buffers)
Assign the given data buffers to this buffer
|
void |
assign(DataBuffer data)
Assign the contents of this buffer
to this buffer
|
void |
assign(long[] indices,
double[] data,
boolean contiguous)
Assign the given elements to the given indices
|
void |
assign(long[] indices,
double[] data,
boolean contiguous,
long inc)
Assign the given elements to the given indices
|
void |
assign(long[] indices,
float[] data,
boolean contiguous)
Assign the given elements to the given indices
|
void |
assign(long[] indices,
float[] data,
boolean contiguous,
long inc)
Assign the given elements to the given indices
|
void |
assign(long[] offsets,
long[] strides,
DataBuffer... buffers)
Assign the given buffers to this buffer
based on the given offsets and strides.
|
void |
assign(long[] offsets,
long[] strides,
long n,
DataBuffer... buffers)
Assign the given buffers to this buffer
based on the given offsets and strides.
|
void |
assign(java.lang.Number value)
Assign the given value to the buffer
|
void |
assign(java.lang.Number value,
long offset)
Assign the given value to the buffer
starting at offset
|
long |
capacity() |
void |
close()
This method releases exclusive off-heap resources uses by this DataBuffer instance.
|
boolean |
closeable()
This method checks, if this DataBuffer instalce can use close() method
|
void |
copyAtStride(DataBuffer buf,
long n,
long stride,
long yStride,
long offset,
long yOffset)
Copies from
the given buffer
at the specified stride
for up to n elements
|
DataType |
dataType()
The data opType of the buffer
|
void |
destroy()
release all resources for this buffer
|
boolean |
dirty()
Whether the buffer is dirty:
aka has been updated
|
DataBuffer |
dup()
Return a copy of this buffer
|
void |
flush()
Flush the data buffer
|
double |
getDouble(long i)
Get element i in the buffer as a double
|
double[] |
getDoublesAt(long offset,
int length)
Get the doubles at a particular offset
|
double[] |
getDoublesAt(long offset,
long inc,
int length)
Get the doubles at a particular offset
|
int |
getElementSize()
The number of bytes for each individual element
|
float |
getFloat(long i)
Get element i in the buffer as a double
|
float[] |
getFloatsAt(long offset,
int length)
Get the doubles at a particular offset
|
float[] |
getFloatsAt(long offset,
long inc,
int length)
Get the doubles at a particular offset
|
long |
getGenerationId() |
int |
getInt(long ix)
Get the int at the specified index
|
int[] |
getIntsAt(long offset,
int length)
Get the ints at a particular offset
|
int[] |
getIntsAt(long offset,
long inc,
int length)
Get the ints at a particular offset
|
long |
getLong(long i)
Get element i in the buffer as long value
|
long[] |
getLongsAt(long offset,
int length)
Get the longs at a particular offset
|
long[] |
getLongsAt(long offset,
long inc,
int length)
Get the long at a particular offset
|
java.lang.Number |
getNumber(long i)
Get element i in the buffer as a double
|
MemoryWorkspace |
getParentWorkspace()
This method returns Workspace this DataBuffer is attached to
|
java.lang.Long |
getTrackingPoint()
Returns tracking point for Allocator
PLEASE NOTE: Suitable & meaningful only for specific backends
|
org.bytedeco.javacpp.indexer.Indexer |
indexer()
Returns the indexer for the buffer
|
boolean |
isAttached()
This method returns True, if this DataBuffer is attached to some workspace.
|
boolean |
isConstant()
This method returns whether this DataBuffer is constant, or not.
|
boolean |
isInScope()
This method checks, if given attached INDArray is still in scope of its parent Workspace
PLEASE NOTE: if this INDArray isn't attached to any Workspace, this method will return true
|
boolean |
isPersist()
Whether the buffer should be persistent.
|
long |
length()
Returns the length of the buffer
|
long |
offset()
Returns the offset of the buffer
|
DataBuffer |
originalDataBuffer()
Original DataBuffer.
|
long |
originalOffset()
Returns the offset of the buffer relative to originalDataBuffer
|
void |
persist()
Mark this buffer as persistent
|
long |
platformAddress()
Returns the address of platform-specific pointer:
- for native backend that'll be host pointer
- for cuda backend that'll be device pointer
|
org.bytedeco.javacpp.Pointer |
pointer()
Returns an underlying pointer if one exists
|
void |
put(long i,
boolean element) |
void |
put(long i,
double element)
Assign an element in the buffer to the specified index
|
void |
put(long i,
float element)
Assign an element in the buffer to the specified index
|
void |
put(long i,
int element)
Assign an element in the buffer to the specified index
|
void |
put(long i,
long element) |
void |
read(java.io.DataInputStream s,
DataBuffer.AllocationMode allocationMode,
long length,
DataType dataType) |
void |
read(java.io.InputStream is,
DataBuffer.AllocationMode allocationMode,
long length,
DataType dataType)
Write this buffer to the input stream.
|
DataBuffer |
reallocate(long length)
Reallocate the native memory of the buffer
|
java.util.Collection<java.lang.String> |
references()
The referencers pointing to this buffer
|
void |
removeReferencing(java.lang.String id)
Remove the referenced id if it exists
|
boolean |
sameUnderlyingData(DataBuffer buffer)
Returns true if the underlying data source
is the same for both buffers (referential equals)
|
void |
setConstant(boolean reallyConstant)
This method allows you to mark databuffer as constant.
|
void |
setData(boolean[] data) |
void |
setData(byte[] data) |
void |
setData(double[] data)
Set the data for this buffer
|
void |
setData(float[] data)
Set the data for this buffer
|
void |
setData(int[] data)
Set the data for this buffer
|
void |
setData(long[] data)
Set the data for this buffer
|
void |
setData(short[] data) |
void |
setTrackingPoint(java.lang.Long trackingPoint)
Sets tracking point used by Allocator
PLEASE NOTE: Suitable & meaningful only for specific backends
|
DataBuffer |
underlyingDataBuffer()
Underlying buffer:
This is meant for a data buffer
to be a view of another data buffer
|
long |
underlyingLength()
Returns the length of the buffer
|
void |
unPersist()
Un persist the buffer
|
boolean |
wasClosed()
This method checks if array or its buffer was closed before
|
void |
write(java.io.DataOutputStream out) |
void |
write(java.io.OutputStream dos)
Write this buffer to the output stream
|
long getGenerationId()
org.bytedeco.javacpp.Pointer pointer()
org.bytedeco.javacpp.Pointer addressPointer()
org.bytedeco.javacpp.indexer.Indexer indexer()
long address()
long platformAddress()
boolean sameUnderlyingData(DataBuffer buffer)
buffer
- whether the buffer is the same underlying data or notvoid read(java.io.DataInputStream s, DataBuffer.AllocationMode allocationMode, long length, DataType dataType)
void write(java.io.DataOutputStream out) throws java.io.IOException
java.io.IOException
java.lang.Object array()
java.nio.IntBuffer asNioInt()
java.nio.LongBuffer asNioLong()
java.nio.DoubleBuffer asNioDouble()
java.nio.FloatBuffer asNioFloat()
java.nio.ByteBuffer asNio()
boolean dirty()
DataBuffer underlyingDataBuffer()
DataBuffer originalDataBuffer()
void copyAtStride(DataBuffer buf, long n, long stride, long yStride, long offset, long yOffset)
buf
- the data buffer to copy fromn
- the number of elements to copystride
- the stride to copy atyStride
- offset
- yOffset
- DataBuffer.AllocationMode allocationMode()
void persist()
boolean isPersist()
void unPersist()
int getElementSize()
void removeReferencing(java.lang.String id)
id
- the id to removejava.util.Collection<java.lang.String> references()
void addReferencing(java.lang.String id)
id
- the id to referencevoid assign(long[] indices, float[] data, boolean contiguous, long inc)
indices
- the indices to assigndata
- the data to assigncontiguous
- whether the indices are contiguous or notinc
- the number to increment by when assigningvoid assign(long[] indices, double[] data, boolean contiguous, long inc)
indices
- the indices to assigndata
- the data to assigncontiguous
- whether the data is contiguous or notinc
- the number to increment by when assigningvoid assign(long[] indices, float[] data, boolean contiguous)
indices
- the indices to assigndata
- the data to assigncontiguous
- whether the indices are contiguous or notvoid assign(long[] indices, double[] data, boolean contiguous)
indices
- the indices to assigndata
- the data to assigncontiguous
- whether the data is contiguous or notdouble[] getDoublesAt(long offset, int length)
offset
- the offset to startlength
- the length of the arrayfloat[] getFloatsAt(long offset, int length)
offset
- the offset to startlength
- the length of the arrayint[] getIntsAt(long offset, int length)
offset
- the offset to startlength
- the length of the arraylong[] getLongsAt(long offset, int length)
offset
- the offset to startlength
- the length of the arraydouble[] getDoublesAt(long offset, long inc, int length)
offset
- the offset to startinc
- the increment to uselength
- the length of the arrayfloat[] getFloatsAt(long offset, long inc, int length)
offset
- the offset to startinc
- the increment to uselength
- the length of the arrayint[] getIntsAt(long offset, long inc, int length)
offset
- the offset to startinc
- the increment to uselength
- the length of the arraylong[] getLongsAt(long offset, long inc, int length)
offset
- the offset to startinc
- the increment to uselength
- the length of the arrayvoid assign(java.lang.Number value)
value
- the value to assignvoid assign(java.lang.Number value, long offset)
value
- assign the value to setoffset
- the offset to start atvoid setData(int[] data)
data
- the data for this buffervoid setData(long[] data)
data
- the data for this buffervoid setData(float[] data)
data
- the data for this buffervoid setData(double[] data)
data
- the data for this buffervoid setData(short[] data)
void setData(byte[] data)
void setData(boolean[] data)
byte[] asBytes()
DataType dataType()
float[] asFloat()
double[] asDouble()
int[] asInt()
long[] asLong()
double getDouble(long i)
i
- the element to getFloatlong getLong(long i)
i
- float getFloat(long i)
i
- the element to getFloatjava.lang.Number getNumber(long i)
i
- the element to getFloatvoid put(long i, float element)
i
- the indexelement
- the element to assignvoid put(long i, double element)
i
- the indexelement
- the element to assignvoid put(long i, int element)
i
- the indexelement
- the element to assignvoid put(long i, long element)
void put(long i, boolean element)
long length()
long underlyingLength()
long offset()
long originalOffset()
int getInt(long ix)
ix
- the int at the specified indexDataBuffer dup()
void flush()
void assign(DataBuffer data)
data
- the data to assignvoid assign(long[] offsets, long[] strides, long n, DataBuffer... buffers)
offsets
- the offsets to usestrides
- the strides to usen
- the number of elements to operate onbuffers
- the buffers to assign data fromvoid assign(DataBuffer... buffers)
buffers
- the buffers to assignvoid assign(long[] offsets, long[] strides, DataBuffer... buffers)
offsets
- the offsets to usestrides
- the strides to usebuffers
- the buffers to assign data fromvoid destroy()
void write(java.io.OutputStream dos)
dos
- the output stream to writevoid read(java.io.InputStream is, DataBuffer.AllocationMode allocationMode, long length, DataType dataType)
is
- the inpus tream to write tojava.lang.Long getTrackingPoint()
void setTrackingPoint(java.lang.Long trackingPoint)
trackingPoint
- boolean isConstant()
void setConstant(boolean reallyConstant)
reallyConstant
- boolean isAttached()
boolean isInScope()
MemoryWorkspace getParentWorkspace()
DataBuffer reallocate(long length)
length
- the new length of the bufferlong capacity()
boolean closeable()
void close()
close
in interface java.lang.AutoCloseable
boolean wasClosed()
Copyright © 2019. All rights reserved.