ByteDataLayout
Stay organized with collections
Save and categorize content based on your preferences.
A DataLayout
that converts data stored in a buffer to bytes.
Public Methods
abstract
ByteDataBuffer
|
applyTo(S buffer)
Apply this layout to the provided buffer.
|
abstract
byte
|
readByte(S buffer, long index)
Reads n = scale() values from the buffer at the given index and return them as a byte.
|
abstract
Byte
|
readObject(S buffer, long index)
Reads n = scale() values from the buffer at the given index and return them as a single
value in the user type.
|
abstract
void
|
writeByte(S buffer, byte value, long index)
Writes a byte into the buffer at the given index after converting it to the buffer type.
|
abstract
void
|
|
Inherited Methods
From interface
org.tensorflow.ndarray.buffer.layout.DataLayout
abstract
DataBuffer<Byte>
|
applyTo(S buffer)
Apply this layout to the provided buffer.
|
abstract
Byte
|
readObject(S buffer, long index)
Reads n = scale() values from the buffer at the given index and return them as a single
value in the user type.
|
abstract
int
|
scale()
Indicates the number of buffer values are required to represent a single user value, default is 1.
|
abstract
void
|
writeObject(S buffer, Byte value, long index)
Writes a user value into the buffer at the given index after converting it to the buffer type.
|
Public Methods
public
abstract
ByteDataBuffer
applyTo
(S buffer)
Apply this layout to the provided buffer.
The returned DataBuffer
instance is simply a wrapper to the original buffer and does
not have a backing storage of his own.
Parameters
buffer |
the target buffer to apply this layout to |
Returns
- a buffer with this layout
public
abstract
byte
readByte
(S buffer, long index)
Reads n = scale()
values from the buffer at the given index and return them as a byte.
Parameters
buffer |
the buffer to read from |
index |
position of the buffer to read in the buffer |
public
abstract
Byte
readObject
(S buffer, long index)
Reads n = 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 long
to a BigInteger
,
@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,
index
indicates the
starting position of the sequence to be read from the buffer.
Parameters
buffer |
the buffer to read from |
index |
position of the buffer to read in the buffer |
public
abstract
void
writeByte
(S buffer, byte value, long index)
Writes a byte into the buffer at the given index after converting it to the buffer type.
Parameters
buffer |
the buffer to write to |
value |
the byte to convert and write |
index |
index in the buffer where the converted value should be written |
public
abstract
void
writeObject
(S buffer, Byte value, long index)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-11-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-11-29 UTC."],[],[],null,["# ByteDataLayout\n\npublic interface **ByteDataLayout** \nA [DataLayout](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout) that converts data stored in a buffer to bytes. \n\n##### See Also\n\n- [DataLayout](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout) \n\n### Public Methods\n\n|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [ByteDataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/ByteDataBuffer) | [applyTo](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ByteDataLayout#applyTo(S))(S buffer) Apply this layout to the provided buffer. |\n| abstract byte | [readByte](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ByteDataLayout#readByte(S, long))(S buffer, long index) Reads `n = scale()` values from the buffer at the given index and return them as a byte. |\n| abstract Byte | [readObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ByteDataLayout#readObject(S, long))(S buffer, long index) Reads `n = scale()` values from the buffer at the given index and return them as a single value in the user type. |\n| abstract void | [writeByte](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ByteDataLayout#writeByte(S, byte, long))(S buffer, byte value, long index) Writes a byte into the buffer at the given index after converting it to the buffer type. |\n| abstract void | [writeObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ByteDataLayout#writeObject(S, java.lang.Byte, long))(S buffer, Byte value, long index) |\n\n### Inherited Methods\n\nFrom interface [org.tensorflow.ndarray.buffer.layout.DataLayout](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout) \n\n|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [DataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/DataBuffer)\\\u003cByte\\\u003e | [applyTo](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#applyTo(S))(S buffer) Apply this layout to the provided buffer. |\n| abstract Byte | [readObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#readObject(S, long))(S buffer, long index) Reads `n = scale()` values from the buffer at the given index and return them as a single value in the user type. |\n| abstract int | [scale](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#scale())() Indicates the number of buffer values are required to represent a single user value, default is 1. |\n| abstract void | [writeObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout#writeObject(S, T, long))(S buffer, Byte value, long index) Writes a user value into the buffer at the given index after converting it to the buffer type. |\n\nPublic Methods\n--------------\n\n#### public abstract [ByteDataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/ByteDataBuffer)\n**applyTo**\n(S buffer)\n\nApply this layout to the provided buffer.\n\nThe returned [DataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/DataBuffer) instance is simply a wrapper to the original buffer and does\nnot have a backing storage of his own.\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| buffer | the target buffer to apply this layout to |\n|--------|-------------------------------------------|\n\n##### Returns\n\n- a buffer with this layout \n\n#### public abstract byte\n**readByte**\n(S buffer, long index)\n\nReads `n = scale()` values from the buffer at the given index and return them as a byte. \n\n##### Parameters\n\n| buffer | the buffer to read from |\n| index | position of the buffer to read in the buffer |\n|--------|----------------------------------------------|\n\n##### Returns\n\n- the byte value \n\n##### See Also\n\n- [readObject(DataBuffer, long)](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ByteDataLayout#readObject(S, long)) \n\n#### public abstract Byte\n**readObject**\n(S buffer, long index)\n\nReads `n = scale()` values from the buffer at the given index and return them as a single\nvalue in the user type.\n\nIt is the responsibility of the implementors of this interface to read the value to be\nconverted from the given buffer, using the most appropriate method. For example, for a layout\nthat converting a single `long` to a `BigInteger`, \n\n```\n @Override\n public BigInteger readObject(LongDataBuffer buffer, long index) {\n return BigInteger.valueOf(buffer.getLong(index));\n }\n \n```\nIf a single user value scales over more than one buffer values, `index` indicates the starting position of the sequence to be read from the buffer.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| buffer | the buffer to read from |\n| index | position of the buffer to read in the buffer |\n|--------|----------------------------------------------|\n\n##### Returns\n\n- the converted value \n\n#### public abstract void\n**writeByte**\n(S buffer, byte value, long index)\n\nWrites a byte into the buffer at the given index after converting it to the buffer type. \n\n##### Parameters\n\n| buffer | the buffer to write to |\n| value | the byte to convert and write |\n| index | index in the buffer where the converted value should be written |\n|--------|-----------------------------------------------------------------|\n\n##### See Also\n\n- [writeObject(DataBuffer, Byte, long)](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ByteDataLayout#writeObject(S, java.lang.Byte, long)) \n\n#### public abstract void\n**writeObject**\n(S buffer, Byte value, long index)\n\n\u003cbr /\u003e"]]