public interface TensorBuilder<T extends TensorBuilder<T>> extends TypedOperator, WriteableTuple<T>
start(int)
2. Set values for each column in the first row, using WriteableTuple.setInt(int, int), WriteableTuple.setFloat(int, float), etc.
3. Call append() to finish the row.
4. Repeat steps 2 and 3 for any remaining rows.
5. Call build() to build the TensorData object.
Instances of TensorBuilder can be safely reused by calling start(int) to "reset" the builder.
Except for any subclass implementation that explicitly states otherwise, instances of TensorBuilder MUST NOT be
used in a concurrent fashion.| Modifier and Type | Method and Description |
|---|---|
T |
append()
Tells this TensorBuilder that the current row is complete.
|
default TensorData |
build()
Build the tensor
Does NOT reset the internal state, so if you plan to reuse this instance, call
start() or start(int) before reusing. |
TensorData |
build(boolean sort)
Build the tensor
|
default T |
copyColumn(TensorIterator source,
int sourceColumn,
int destinationColumn)
Copy a single column from source to this builder.
|
default T |
copyColumns(TensorIterator source,
int[] sourceColumns)
Copy multiple columns from source to this builder.
|
default T |
copyColumns(TensorIterator left,
TensorIterator right,
int[] sourceColumns) |
default T |
copyColumns(TensorIterator left,
TensorIterator right,
int[] sourceColumns,
int leftArity) |
default T |
copyLeftColumns(TensorIterator source,
int count)
Copy some left-most columns from source to this builder (slightly more efficient than using an array of columns).
|
default T |
setBoolean(int index,
boolean value)
Sets the specified column to a given `boolean`
|
default T |
setDouble(int index,
double value)
Sets the specified column to a given `double`
|
default T |
setString(int index,
java.lang.String value)
Sets the specified column to a given `String`
|
default T |
start()
Initializes this TensorBuilder.
|
T |
start(int estimatedRows)
Initializes this TensorBuilder.
|
getOutputTypesdefault TensorData build()
start() or start(int) before reusing.TensorData build(boolean sort)
sort - if set to true, the built tensor's rows will be sorted lexicographicallydefault T setDouble(int index, double value)
WriteableTuplesetDouble in interface WriteableTuple<T extends TensorBuilder<T>>index - The column in the tuple to write tovalue - The double value to be writtendefault T setString(int index, java.lang.String value)
WriteableTuplesetString in interface WriteableTuple<T extends TensorBuilder<T>>index - The column in the tuple to write tovalue - The String value to be writtendefault T setBoolean(int index, boolean value)
WriteableTuplesetBoolean in interface WriteableTuple<T extends TensorBuilder<T>>index - The column in the tuple to write tovalue - The double value to be writtenT append()
WriteableTuple.setInt(int, int), WriteableTuple.setFloat(int, float), etc. to set all the columns of the current row.T start(int estimatedRows)
start() MUST be called before setting values
to this TensorBuilder. This method may also be used to "reset" the builder, enabling it to be reused.estimatedRows - The estimated number of rows in this tensor. Implementations can use this to allocate internal
array sizes, for example.default T start()
start(int) MUST be called before setting values
to this TensorBuilder. This method may also be used to "reset" the builder, enabling it to be reused.default T copyColumn(TensorIterator source, int sourceColumn, int destinationColumn)
source - the source from which to copysourceColumn - the index number of the column to be copied from the sourcedestinationColumn - the index number of the column to be written to in this TensorBuilderdefault T copyColumns(TensorIterator source, int[] sourceColumns)
source - the source from which to copysourceColumns - array of indices of the columns to be copied from the source and written to this
TensorBuilder. Note that the columns are copied from the source into the same position in this
builder; values read from column `i` are written to column `i`, etc.default T copyColumns(TensorIterator left, TensorIterator right, int[] sourceColumns)
default T copyColumns(TensorIterator left, TensorIterator right, int[] sourceColumns, int leftArity)
default T copyLeftColumns(TensorIterator source, int count)
source - the source from which to copycount - the number of columns to copy, starting from the leftmost column (index 0)