Package org.datavec.api.writable
Class BytesWritable
- java.lang.Object
-
- org.datavec.api.writable.ArrayWritable
-
- org.datavec.api.writable.BytesWritable
-
- All Implemented Interfaces:
Serializable,Writable
public class BytesWritable extends ArrayWritable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BytesWritable(byte[] content)Pass in the content for this writable
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataBufferasNd4jBuffer(DataType type, int elementSize)Convert the underlying contents of thisWritableto an nd4jDataBuffer.booleanequals(Object o)doublegetDouble(long i)floatgetFloat(long i)intgetInt(long i)longgetLong(long i)WritableTypegetType()Get the type of the writable.inthashCode()longlength()voidreadFields(DataInput in)Deserialize the fields of this object fromin.voidwrite(DataOutput out)Serialize the fields of this object toout.voidwriteType(DataOutput out)Write the type (a single short value) to the DataOutput.-
Methods inherited from class org.datavec.api.writable.ArrayWritable
toDouble, toFloat, toInt, toLong
-
-
-
-
Method Detail
-
asNd4jBuffer
public DataBuffer asNd4jBuffer(DataType type, int elementSize)
Convert the underlying contents of thisWritableto an nd4jDataBuffer. Note that this is a *copy* of the underlying buffer. Also note thatByteBuffer.allocateDirect(int)is used for allocation. This should be considered an expensive operation. This buffer should be cached when used. Once used, this can be used in standard Nd4j operations. Beyond that, the reason we have to use allocateDirect is due to nd4j data buffers being stored off heap (whether on cpu or gpu)- Parameters:
type- the type of the data bufferelementSize- the size of each element in the buffer- Returns:
- the equivalent nd4j data buffer
-
length
public long length()
- Specified by:
lengthin classArrayWritable
-
getDouble
public double getDouble(long i)
- Specified by:
getDoublein classArrayWritable
-
getFloat
public float getFloat(long i)
- Specified by:
getFloatin classArrayWritable
-
getInt
public int getInt(long i)
- Specified by:
getIntin classArrayWritable
-
getLong
public long getLong(long i)
- Specified by:
getLongin classArrayWritable
-
write
public void write(DataOutput out) throws IOException
Description copied from interface:WritableSerialize the fields of this object toout.- Parameters:
out-DataOuputto serialize this object into.- Throws:
IOException
-
readFields
public void readFields(DataInput in) throws IOException
Description copied from interface:WritableDeserialize the fields of this object fromin.For efficiency, implementations should attempt to re-use storage in the existing object where possible.
- Parameters:
in-DataInputto deseriablize this object from.- Throws:
IOException
-
writeType
public void writeType(DataOutput out) throws IOException
Description copied from interface:WritableWrite the type (a single short value) to the DataOutput. SeeWritableFactoryfor details.- Parameters:
out- DataOutput to write to- Throws:
IOException- For errors during writing
-
getType
public WritableType getType()
Description copied from interface:WritableGet the type of the writable.- Returns:
-
-