Class UniversalTensor

java.lang.Object
com.linkedin.feathr.common.tensorbuilder.UniversalTensor
All Implemented Interfaces:
TensorData

public class UniversalTensor extends Object implements TensorData
Implements a tensor from pre-allocated arrays. The keys (int and long) and the values are stored in parallel arrays to float values. Multiple keys of a certain type can be associated to a value, in that case the key array size will be a multiple of the value array size.
  • Constructor Details

    • UniversalTensor

      @Deprecated public UniversalTensor(int intArity, int longArity, int floatArity, int[] intArray, long[] longArray, float[] floatArray, Representable[] columnTypes, int... columnIndex)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int intArity, int longArity, int floatArity, int[] intArray, long[] longArray, float[] floatArray, Representable[] columnTypes, int size, boolean sort, int... columnIndex)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int intArity, int longArity, int floatArity, int[] intArray, long[] longArray, float[] floatArray, Representable[] columnTypes, boolean sort, int... columnIndex)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int intArity, int longArity, int stringArity, int floatArity, int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, Representable[] columnTypes, int... columnIndex)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int intArity, int longArity, int stringArity, int floatArity, int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, Representable[] columnTypes, boolean sort, int... columnIndex)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int intArity, int longArity, int stringArity, int floatArity, int doubleArity, int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, double[] doubleArray, Representable[] columnTypes, boolean sort, int... columnIndex)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int[] intArray, long[] longArray, float[] floatArray, Representable[] columnTypes)
      Deprecated.
      Generate arities and columns from types, assuming sequential ordering within types.
    • UniversalTensor

      @Deprecated public UniversalTensor(int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, Representable[] columnTypes)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int[] intArray, long[] longArray, String[] stringArray, double[] doubleArray, Representable[] columnTypes)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, double[] doubleArray, Representable[] columnTypes)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, double[] doubleArray, ColumnUtils utils)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, double[] doubleArray, Object[] bytesArray, ColumnUtils utils)
      Deprecated.
    • UniversalTensor

      @Deprecated public UniversalTensor(int intArity, int longArity, int stringArity, int floatArity, int doubleArity, int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, double[] doubleArray, Representable[] columnTypes, int size, boolean sort, int... columnIndex)
      Deprecated.
    • UniversalTensor

      public UniversalTensor(int intArity, int longArity, int stringArity, int floatArity, int doubleArity, int booleanArity, int valueArity, int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, double[] doubleArray, boolean[] booleanArray, Representable[] columnTypes, int size, boolean sort, int... columnIndex)
      Universal Tensor constructors should ideally not be used to create a UniversalTensor. Universal Tensors should be created by using the UniversalTensorBuilder. The other constructors are deprecated as they only support FLOAT/DOUBLE values.
      Parameters:
      intArity - number of int columns in a tensor row (includes dimensions and values)
      longArity - number of long columns in a tensor row (includes dimensions and values)
      stringArity - number of string columns in a tensor row (includes dimensions and values)
      floatArity - number of float columns in a tensor row (includes dimensions and values)
      doubleArity - number of double columns in a tensor row (includes dimensions and values)
      booleanArity - number of boolean columns in a tensor row (includes dimensions and values)
      valueArity - number of value columns in a tensor row. This value is needed as it's possible for UniversalTensors to have more than one value dimension
      intArray - array corresponding to the int dimensions/values
      longArray - array corresponding to the long dimensions/values
      stringArray - array corresponding to the string dimensions
      floatArray - array corresponding to the float values. Floats can not be a dimension
      doubleArray - array corresponding to the double values. Doubles can not be a dimension
      booleanArray - array corresponding to the boolean dimensions/values
      columnTypes - columnTypes representing the tensor
      size - size of the tensor. (Number of rows).
      sort - sorts the tensor by the dimension if true
      columnIndex - columnIndices
    • UniversalTensor

      public UniversalTensor(int intArity, int longArity, int stringArity, int floatArity, int doubleArity, int booleanArity, int bytesArity, int valueArity, int[] intArray, long[] longArray, String[] stringArray, float[] floatArray, double[] doubleArray, boolean[] booleanArray, Object[] bytesArray, Representable[] columnTypes, int size, boolean sort, int... columnIndex)
      Universal Tensor constructors should ideally not be used to create a UniversalTensor. Universal Tensors should be created by using the UniversalTensorBuilder. The other constructors are deprecated as they only support FLOAT/DOUBLE values.
      Parameters:
      intArity - number of int columns in a tensor row (includes dimensions and values)
      longArity - number of long columns in a tensor row (includes dimensions and values)
      stringArity - number of string columns in a tensor row (includes dimensions and values)
      floatArity - number of float columns in a tensor row (includes dimensions and values)
      doubleArity - number of double columns in a tensor row (includes dimensions and values)
      booleanArity - number of boolean columns in a tensor row (includes dimensions and values)
      bytesArity - number of bytes columns in a tensor row (includes dimensions and values)
      valueArity - number of value columns in a tensor row. This value is needed as it's possible for UniversalTensors to have more than one value dimension
      intArray - array corresponding to the int dimensions/values
      longArray - array corresponding to the long dimensions/values
      stringArray - array corresponding to the string dimensions
      floatArray - array corresponding to the float values. Floats can not be a dimension
      doubleArray - array corresponding to the double values. Doubles can not be a dimension
      booleanArray - array corresponding to the boolean dimensions/values
      bytesArray - array corresponding to the bytes dimensions/values
      columnTypes - columnTypes representing the tensor
      size - size of the tensor. (Number of rows).
      sort - sorts the tensor by the dimension if true
      columnIndex - columnIndices
  • Method Details

    • getArity

      public int getArity()
      Specified by:
      getArity in interface TensorData
      Returns:
      the arity, which is the total number of columns. As columns are dimensions plus a value, arity is by one greater than dimensionality.
    • getTypes

      public Representable[] getTypes()
      Specified by:
      getTypes in interface TensorData
      Returns:
      the types of all dimensions and the value as a single array.
    • estimatedCardinality

      public int estimatedCardinality()
      Specified by:
      estimatedCardinality in interface TensorData
      Returns:
      conservative estimate of number of entries in the mapping from dimensions to values. Can be cheaper to evaluate than the exact one.
    • cardinality

      public int cardinality()
      Specified by:
      cardinality in interface TensorData
      Returns:
      exact number of entries in the mapping from dimensions to values.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface TensorData
    • iterator

      public TensorIterator iterator()
      Specified by:
      iterator in interface TensorData
      Returns:
      an iterator over entries in the mapping from dimensions to the value.
    • getIntArray

      public int[] getIntArray()
    • getIntArity

      public int getIntArity()
    • getLongArray

      public long[] getLongArray()
    • getLongArity

      public int getLongArity()
    • getStringArray

      public String[] getStringArray()
    • getStringArity

      public int getStringArity()
    • getFloatArray

      public float[] getFloatArray()
    • getFloatArity

      public int getFloatArity()
    • getDoubleArray

      public double[] getDoubleArray()
    • getDoubleArity

      public int getDoubleArity()
    • getBooleanArray

      public boolean[] getBooleanArray()
    • getBooleanArity

      public int getBooleanArity()
    • getBytesArray

      public Object[] getBytesArray()
    • getBytesArity

      public int getBytesArity()
    • getValueArity

      public int getValueArity()
    • getColumnIndex

      public int[] getColumnIndex()