Class BytesWritable

    • Constructor Detail

      • BytesWritable

        public BytesWritable​(byte[] content)
        Pass in the content for this writable
        Parameters:
        content - the content for this writable
    • Method Detail

      • asNd4jBuffer

        public DataBuffer asNd4jBuffer​(DataType type,
                                       int elementSize)
        Convert the underlying contents of this 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)
        Parameters:
        type - the type of the data buffer
        elementSize - the size of each element in the buffer
        Returns:
        the equivalent nd4j data buffer
      • write

        public void write​(DataOutput out)
                   throws IOException
        Description copied from interface: Writable
        Serialize the fields of this object to out.
        Parameters:
        out - DataOuput to serialize this object into.
        Throws:
        IOException
      • readFields

        public void readFields​(DataInput in)
                        throws IOException
        Description copied from interface: Writable
        Deserialize the fields of this object from in.

        For efficiency, implementations should attempt to re-use storage in the existing object where possible.

        Parameters:
        in - DataInput to deseriablize this object from.
        Throws:
        IOException
      • writeType

        public void writeType​(DataOutput out)
                       throws IOException
        Description copied from interface: Writable
        Write the type (a single short value) to the DataOutput. See WritableFactory for details.
        Parameters:
        out - DataOutput to write to
        Throws:
        IOException - For errors during writing
      • getType

        public WritableType getType()
        Description copied from interface: Writable
        Get the type of the writable.
        Returns:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object