public class BytesWritable extends ArrayWritable
Constructor and Description |
---|
BytesWritable(byte[] content)
Pass in the content for this writable
|
Modifier and Type | Method and Description |
---|---|
DataBuffer |
asNd4jBuffer(DataType type,
int elementSize)
Convert the underlying contents of this
Writable
to an nd4j DataBuffer . |
boolean |
equals(Object o) |
double |
getDouble(long i) |
float |
getFloat(long i) |
int |
getInt(long i) |
long |
getLong(long i) |
WritableType |
getType()
Get the type of the writable.
|
int |
hashCode() |
long |
length() |
void |
readFields(DataInput in)
Deserialize the fields of this object from
in . |
void |
write(DataOutput out)
Serialize the fields of this object to
out . |
void |
writeType(DataOutput out)
Write the type (a single short value) to the DataOutput.
|
toDouble, toFloat, toInt, toLong
public BytesWritable(byte[] content)
content
- the content for this writablepublic DataBuffer asNd4jBuffer(DataType type, int elementSize)
Writable
to an nd4j DataBuffer
. Note that this is a *copy*
of the underlying buffer.
Also note that ByteBuffer.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)type
- the type of the data bufferelementSize
- the size of each element in the bufferpublic long length()
length
in class ArrayWritable
public double getDouble(long i)
getDouble
in class ArrayWritable
public float getFloat(long i)
getFloat
in class ArrayWritable
public int getInt(long i)
getInt
in class ArrayWritable
public long getLong(long i)
getLong
in class ArrayWritable
public void write(DataOutput out) throws IOException
Writable
out
.out
- DataOuput
to serialize this object into.IOException
public void readFields(DataInput in) throws IOException
Writable
in
.
For efficiency, implementations should attempt to re-use storage in the existing object where possible.
in
- DataInput
to deseriablize this object from.IOException
public void writeType(DataOutput out) throws IOException
Writable
WritableFactory
for details.out
- DataOutput to write toIOException
- For errors during writingpublic WritableType getType()
Writable
Copyright © 2022. All rights reserved.