- java.lang.Object
-
- org.tensorflow.ndarray.impl.buffer.layout.StringLayout
-
- All Implemented Interfaces:
DataLayout<DataBuffer<byte[]>,String>
public final class StringLayout extends Object implements DataLayout<DataBuffer<byte[]>,String>
Data layout that converts a String to/from a sequence of bytes applying a given charset.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringLayoutof(Charset charset)StringreadObject(DataBuffer<byte[]> buffer, long index)Readsn = scale()values from the buffer at the given index and return them as a single value in the user type.voidwriteObject(DataBuffer<byte[]> buffer, String value, long index)Writes a user value into the buffer at the given index after converting it to the buffer type.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.tensorflow.ndarray.buffer.layout.DataLayout
applyTo, scale
-
-
-
-
Method Detail
-
of
public static StringLayout of(Charset charset)
-
writeObject
public void writeObject(DataBuffer<byte[]> buffer, String value, long index)
Description copied from interface:DataLayoutWrites a user value into the buffer at the given index after converting it to the buffer type.It is the responsibility of the implementors of this interface to write the converted value to the given buffer before this call returns, using the most appropriate method. For example, for a layout converting a
BigIntegerto a singlelong,@Override public void writeObject(LongDataBuffer buffer, BigInteger value, long index) { buffer.setLong(value.longValue(), index); }If a single user value scales over more than one buffer values,indexindicates the starting position of the sequence to be written to the buffer.- Specified by:
writeObjectin interfaceDataLayout<DataBuffer<byte[]>,String>- Parameters:
buffer- the buffer to write tovalue- the value in the user type to convert and writeindex- index in the buffer where the converted value should be written
-
readObject
public String readObject(DataBuffer<byte[]> buffer, long index)
Description copied from interface:DataLayoutReadsn = scale()values from the buffer at the given index and return them as a single value in the user type.It is the responsibility of the implementors of this interface to read the value to be converted from the given buffer, using the most appropriate method. For example, for a layout that converting a single
longto aBigInteger,@Override public BigInteger readObject(LongDataBuffer buffer, long index) { return BigInteger.valueOf(buffer.getLong(index)); }If a single user value scales over more than one buffer values,indexindicates the starting position of the sequence to be read from the buffer.- Specified by:
readObjectin interfaceDataLayout<DataBuffer<byte[]>,String>- Parameters:
buffer- the buffer to read fromindex- position of the buffer to read in the buffer- Returns:
- the converted value
-
-