Class DenseTensorBuilder
java.lang.Object
com.linkedin.feathr.common.tensorbuilder.DenseTensorBuilder
- All Implemented Interfaces:
WriteableTuple,BulkTensorBuilder,TensorBuilder,TypedOperator
Build a dense tensor based on input column types and shape,
All columns except the last one, must have
Primitive.INT representation.
The last column type is considered to be value type and determines-
Constructor Summary
ConstructorsConstructorDescriptionDenseTensorBuilder(Representable[] columnTypes, long[] shape) DenseTensorBuilder(TensorType tensorType) -
Method Summary
Modifier and TypeMethodDescriptionappend()Tells this TensorBuilder that the current row is complete.build(boolean sort) Build the tensorbuild(boolean[] booleans) build(double[] doubles) build(float[] floats) build(int[] ints) build(long[] longs) build(ByteBuffer values) intThe full count of the tensor values, ignoring a possible unknown dimension.getTypes()booleanIf the actual cardinality can be a multiple of the static cardinality, as opposed to exactly equal.setBoolean(int column, boolean value) Sets the specified column to a given `boolean`setBytes(int column, byte[] value) Sets the specified column to a given `byte array`setDouble(int column, double value) Sets the specified column to a given `double`setFloat(int column, float value) Sets the specified column to a given `float`setInt(int column, int value) DenseTensorBuilder's setInt should be used seldomly.setLong(int column, 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 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
-
DenseTensorBuilder
-
DenseTensorBuilder
-
-
Method Details
-
getStaticCardinality
public int getStaticCardinality()Description copied from interface:BulkTensorBuilderThe full count of the tensor values, ignoring a possible unknown dimension.- Specified by:
getStaticCardinalityin interfaceBulkTensorBuilder
-
hasVariableCardinality
public boolean hasVariableCardinality()Description copied from interface:BulkTensorBuilderIf the actual cardinality can be a multiple of the static cardinality, as opposed to exactly equal.- Specified by:
hasVariableCardinalityin interfaceBulkTensorBuilder
-
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- Returns:
- a reference to this TensorBuilder (`this`)
-
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- 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`)
-
getOutputTypes
- Specified by:
getOutputTypesin interfaceTypedOperator
-
getTypes
- Specified by:
getTypesin interfaceWriteableTuple- Returns:
- the types of all dimensions and the value as a single array.
-
setInt
DenseTensorBuilder's setInt should be used seldomly. The proper usage to construct DenseTensors is by using the build() method and passing in the associated arrays. By calling setInt for non value columns, the currentIndex is changed to point to the associated location in the value array. It assumes the usage is correct (append one row at a time and not overriding a given column, aka calling setInt on the same column multiple times). Ex of incorrect usage: shape is [2,2] setInt(0, 0), setInt(0, 1) -> Here the currentIndex is set for column 0 with value 0 and then changed to column 0 with value 1. Ex of correct usage: setInt(0,0), setInt(1,0) -> Here the currentIndex is set for column 0 with value 0 and column 1 with value 0. Setting the value here will be associated with the correct currentIndex and the correct row.- Specified by:
setIntin interfaceWriteableTuple- Parameters:
column- 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- Parameters:
column- The column in the tuple to write tovalue- The long 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- Parameters:
column- 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- Specified by:
setDoublein interfaceWriteableTuple- Parameters:
column- 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- Specified by:
setBooleanin interfaceWriteableTuple- Parameters:
column- The column in the tuple to write tovalue- The double 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- Specified by:
setStringin interfaceWriteableTuple- Parameters:
column- The column in the tuple to write tovalue- The String 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- Parameters:
column- The column in the tuple to write tovalue- The byte array value to be written- Returns:
- A reference to this object (`this`)
-
build
- Specified by:
buildin interfaceBulkTensorBuilder
-
build
- Specified by:
buildin interfaceBulkTensorBuilder
-
build
- Specified by:
buildin interfaceBulkTensorBuilder
-
build
- Specified by:
buildin interfaceBulkTensorBuilder
-
build
- Specified by:
buildin interfaceBulkTensorBuilder
-
build
- Specified by:
buildin interfaceBulkTensorBuilder
-
build
- Specified by:
buildin interfaceBulkTensorBuilder
-
build
Description copied from interface:TensorBuilderBuild the tensor- Specified by:
buildin interfaceTensorBuilder- Parameters:
sort- if set to true, the built tensor's rows will be sorted lexicographically- Returns:
- the built tensor
-