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
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 |
---|