Class UniversalTensorBuilder
java.lang.Object
com.linkedin.feathr.common.ColumnUtils
com.linkedin.feathr.common.tensorbuilder.UniversalTensorBuilder
- All Implemented Interfaces:
WriteableTuple<UniversalTensorBuilder>,TensorBuilder<UniversalTensorBuilder>,TypedOperator
public final class UniversalTensorBuilder
extends ColumnUtils
implements TensorBuilder<UniversalTensorBuilder>
Builds tensors with columns being a requested permutation of int, long, and float.
Am instance of UniversalTensorBuilder can be reused by calling start method.
-
Field Summary
Fields inherited from class com.linkedin.feathr.common.ColumnUtils
_booleanArity, _bytesArity, _columnIndex, _columnTypes, _doubleArity, _floatArity, _intArity, _longArity, _stringArity -
Constructor Summary
ConstructorsConstructorDescriptionUniversalTensorBuilder(int valueArity, Representable... columnTypes) UniversalTensorBuilder(Representable... columnTypes) -
Method Summary
Modifier and TypeMethodDescriptionappend()Tells this TensorBuilder that the current row is complete.build(boolean sort) Build the tensorgetTypes()setBoolean(int index, boolean value) Sets the specified column to a given `boolean`setBytes(int index, byte[] value) Sets the specified column to a given `byte array`setDouble(int index, double value) Sets the specified column to a given `double`setFloat(int index, float value) Sets the specified column to a given `float`setInt(int index, int value) Sets the specified column to a given `int`setLong(int index, long value) Sets the specified column to a given `long`Sets the specified column to a given `String`start(int estimatedRows) Initializes this TensorBuilder.Methods inherited from class com.linkedin.feathr.common.ColumnUtils
getBooleanArity, getBytesArity, getColumnIndex, getColumnTypes, getDimArity, getDoubleArity, getFloatArity, getIntArity, getLongArity, getStringArityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.feathr.common.tensorbuilder.TensorBuilder
build, copyColumn, copyColumns, copyColumns, copyColumns, copyLeftColumns, startMethods inherited from interface com.linkedin.feathr.common.tensor.WriteableTuple
setValue
-
Constructor Details
-
UniversalTensorBuilder
-
UniversalTensorBuilder
-
-
Method Details
-
start
Description copied from interface:TensorBuilderInitializes this TensorBuilder. This method (or overloadedTensorBuilder.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.- Specified by:
startin interfaceTensorBuilder<UniversalTensorBuilder>- Parameters:
estimatedRows- The estimated number of rows in this tensor. Implementations can use this to allocate internal array sizes, for example.- Returns:
- a reference to this TensorBuilder (`this`)
-
setInt
Description copied from interface:WriteableTupleSets the specified column to a given `int`- Specified by:
setIntin interfaceWriteableTuple<UniversalTensorBuilder>- Parameters:
index- The column in the tuple to write tovalue- The int value to be written- Returns:
- A reference to this object (`this`)
-
setLong
Description copied from interface:WriteableTupleSets the specified column to a given `long`- Specified by:
setLongin interfaceWriteableTuple<UniversalTensorBuilder>- Parameters:
index- The column in the tuple to write tovalue- The long value to be written- Returns:
- A reference to this object (`this`)
-
setString
Description copied from interface:WriteableTupleSets the specified column to a given `String`- Specified by:
setStringin interfaceTensorBuilder<UniversalTensorBuilder>- Specified by:
setStringin interfaceWriteableTuple<UniversalTensorBuilder>- Parameters:
index- The column in the tuple to write tovalue- The String value to be written- Returns:
- A reference to this object (`this`)
-
setFloat
Description copied from interface:WriteableTupleSets the specified column to a given `float`- Specified by:
setFloatin interfaceWriteableTuple<UniversalTensorBuilder>- Parameters:
index- The column in the tuple to write tovalue- The float value to be written- Returns:
- A reference to this object (`this`)
-
setDouble
Description copied from interface:WriteableTupleSets the specified column to a given `double`- Specified by:
setDoublein interfaceTensorBuilder<UniversalTensorBuilder>- Specified by:
setDoublein interfaceWriteableTuple<UniversalTensorBuilder>- Parameters:
index- The column in the tuple to write tovalue- The double value to be written- Returns:
- A reference to this object (`this`)
-
setBoolean
Description copied from interface:WriteableTupleSets the specified column to a given `boolean`- Specified by:
setBooleanin interfaceTensorBuilder<UniversalTensorBuilder>- Specified by:
setBooleanin interfaceWriteableTuple<UniversalTensorBuilder>- Parameters:
index- The column in the tuple to write tovalue- The double value to be written- Returns:
- A reference to this object (`this`)
-
setBytes
Description copied from interface:WriteableTupleSets the specified column to a given `byte array`- Specified by:
setBytesin interfaceWriteableTuple<UniversalTensorBuilder>- Parameters:
index- The column in the tuple to write tovalue- The byte array value to be written- Returns:
- A reference to this object (`this`)
-
append
Description copied from interface:TensorBuilderTells this TensorBuilder that the current row is complete. This method MUST be called after usingWriteableTuple.setInt(int, int),WriteableTuple.setFloat(int, float), etc. to set all the columns of the current row.- Specified by:
appendin interfaceTensorBuilder<UniversalTensorBuilder>- Returns:
- a reference to this TensorBuilder (`this`)
-
getTypes
- Specified by:
getTypesin interfaceWriteableTuple<UniversalTensorBuilder>- Returns:
- the types of all dimensions and the value as a single array.
-
build
Description copied from interface:TensorBuilderBuild the tensor- Specified by:
buildin interfaceTensorBuilder<UniversalTensorBuilder>- Parameters:
sort- if set to true, the built tensor's rows will be sorted lexicographically- Returns:
- the built tensor
-
getOutputTypes
- Specified by:
getOutputTypesin interfaceTypedOperator
-