Buffer for storing string tensor data.
The values are stored as an array of TF_TString
, internally wrapped with
tensorflow::tstring
, which is essentially a portable version of std::string
.
The data of the buffer must be initialized only once, by calling ERROR(/#init(NdArray, Function))
,
and the buffer must have been allocated with enough space (use ERROR(/#computeSize(NdArray, Function))
priory to know exactly how many bytes are required to store the data).
After its data has been initialized, the buffer is read-only as it is not possible to change safely a value without reinitializing the whole data.
Public Methods
static <T> long |
computeSize(ByteSequenceProvider<?> byteSequenceProvider)
Computes how many bytes are required to store the given data in a string buffer.
|
DataBuffer<byte[]> |
copyTo(DataBuffer<byte[]> dst, long size)
Write the references of the objects in the source array into this buffer.
|
byte[] |
getObject(long index)
|
<T> void | |
boolean | |
DataBuffer<byte[]> |
setObject(byte[] values, long index)
|
long |
size()
|
DataBuffer<byte[]> |
slice(long index, long size)
|
Inherited Methods
DataBuffer<byte[]> |
copyTo(DataBuffer<byte[]> dst, long size)
Write the references of the objects in the source array into this buffer.
|
boolean |
equals(Object obj)
|
int |
hashCode()
|
DataBuffer<byte[]> |
read(T[] dst, int offset, int length)
Read the references of the objects in this buffer into the destination array.
|
DataBuffer<byte[]> |
write(T[] src, int offset, int length)
Bulk put method, using int arrays.
|
boolean |
equals(Object arg0)
|
final Class<?> |
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String |
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
abstract <R> R | |
abstract DataBuffer<byte[]> |
copyTo(DataBuffer<byte[]> dst, long size)
Write the references of the objects in the source array into this buffer.
|
abstract boolean |
equals(Object obj)
Checks equality between data buffers.
|
abstract byte[] |
getObject(long index)
Reads the value at the given index.
|
abstract boolean |
isReadOnly()
Tells whether or not this buffer is backed by an accessible array.
|
abstract DataBuffer<byte[]> |
narrow(long size)
Creates a new buffer whose content is a shared subsequence of this buffer's content, whose
size is set to the given value.
|
abstract DataBuffer<byte[]> |
offset(long index)
Creates a new buffer whose content is a shared subsequence of this buffer's content, starting
at the given index.
|
abstract DataBuffer<byte[]> |
read(T[] dst)
Read the references of the objects in this buffer into the destination array.
|
abstract DataBuffer<byte[]> |
read(T[] dst, int offset, int length)
Read the references of the objects in this buffer into the destination array.
|
abstract DataBuffer<byte[]> |
setObject(byte[] value, long index)
Writes the given value into this buffer at the given index.
|
abstract long |
size()
Size of the buffer, in elements.
|
abstract DataBuffer<byte[]> |
slice(long index, long size)
Creates a new buffer whose content is a shared subsequence of this buffer's content, starting
at the given index and of the given size.
|
abstract DataBufferWindow<? extends DataBuffer<T>> |
window(long size)
Creates a
DataBufferWindow that provides a partial view of this buffer. |
abstract DataBuffer<byte[]> |
write(T[] src)
Write the references of the objects in the source array into this buffer.
|
abstract DataBuffer<byte[]> |
write(T[] src, int offset, int length)
Bulk put method, using int arrays.
|
Public Methods
public static long computeSize (ByteSequenceProvider<?> byteSequenceProvider)
Computes how many bytes are required to store the given data in a string buffer.
Parameters
byteSequenceProvider | produces sequences of bytes |
---|
Returns
- number of bytes required to store the data.
public DataBuffer<byte[]> copyTo (DataBuffer<byte[]> dst, long size)
Write the references of the objects in the source array into this buffer.
If there are more values to copy than the destination buffer size, i.e.
size > dst.size()
, then no values are transferred and a
BufferOverflowException is thrown. On the other hand, if there are more values to copy that
the source buffer size, i.e. > src.size()
, then a BufferUnderfloatException is thrown.
Otherwise, this method copies n = size
values from this buffer into
the destination buffer.
Parameters
dst | the destination buffer into which values are copied; must not be this buffer |
---|---|
size | number of values to copy to the destination buffer |
Returns
- this buffer
public byte[] getObject (long index)
public void init (ByteSequenceProvider<T> byteSequenceProvider)
Initialize the data of this buffer.
While it is not enforced programmatically, it is mandatory that this method is called only
once after the creation of the buffer. The buffer must have been allocated according to the
same set of data, calling ERROR(/#computeSize(NdArray, Function))
priory to make sure there is
enough space to store it.
Parameters
byteSequenceProvider | produces sequences of bytes to use as the tensor data |
---|