ShortDataLayout
Stay organized with collections
Save and categorize content based on your preferences.
A DataLayout
that converts data stored in a buffer to shorts.
Public Methods
abstract
ShortDataBuffer
|
applyTo(S buffer)
Apply this layout to the provided buffer.
|
abstract
Short
|
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
short
|
readShort(S buffer, long index)
Reads n = scale() buffer values at the given index and return them as a short.
|
abstract
void
|
|
abstract
void
|
writeShort(S buffer, short value, long index)
Writes a short into the buffer at the given index after converting it to the buffer type.
|
Inherited Methods
From interface
org.tensorflow.ndarray.buffer.layout.DataLayout
abstract
DataBuffer<Short>
|
applyTo(S buffer)
Apply this layout to the provided buffer.
|
abstract
Short
|
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, Short 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
ShortDataBuffer
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
Short
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
short
readShort
(S buffer, long index)
Reads n = scale()
buffer values at the given index and return them as a short.
Parameters
buffer |
the buffer to read from |
index |
position of the value to read in the buffer |
public
abstract
void
writeObject
(S buffer, Short value, long index)
public
abstract
void
writeShort
(S buffer, short value, long index)
Writes a short into the buffer at the given index after converting it to the buffer type.
Parameters
buffer |
the buffer to write to |
value |
the short to convert and write |
index |
index in the buffer where the converted value should be written |
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,["# ShortDataLayout\n\npublic interface **ShortDataLayout** \nA [DataLayout](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/DataLayout) that converts data stored in a buffer to shorts. \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 [ShortDataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/ShortDataBuffer) | [applyTo](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ShortDataLayout#applyTo(S))(S buffer) Apply this layout to the provided buffer. |\n| abstract Short | [readObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ShortDataLayout#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 short | [readShort](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ShortDataLayout#readShort(S, long))(S buffer, long index) Reads `n = scale()` buffer values at the given index and return them as a short. |\n| abstract void | [writeObject](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ShortDataLayout#writeObject(S, java.lang.Short, long))(S buffer, Short value, long index) |\n| abstract void | [writeShort](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ShortDataLayout#writeShort(S, short, long))(S buffer, short value, long index) Writes a short into the buffer at the given index after converting it to the buffer type. |\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)\\\u003cShort\\\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 Short | [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, Short 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 [ShortDataBuffer](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/ShortDataBuffer)\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 Short\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 short\n**readShort**\n(S buffer, long index)\n\nReads `n = scale()` buffer values at the given index and return them as a short. \n\n##### Parameters\n\n| buffer | the buffer to read from |\n| index | position of the value to read in the buffer |\n|--------|---------------------------------------------|\n\n##### Returns\n\n- the short value \n\n##### See Also\n\n- [readObject(DataBuffer, long)](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ShortDataLayout#readObject(S, long)) \n\n#### public abstract void\n**writeObject**\n(S buffer, Short value, long index)\n\n\u003cbr /\u003e\n\n#### public abstract void\n**writeShort**\n(S buffer, short value, long index)\n\nWrites a short 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 short 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, Short, long)](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/layout/ShortDataLayout#writeObject(S, java.lang.Short, long))"]]