Class DimensionType

java.lang.Object
com.linkedin.feathr.common.tensor.DimensionType
All Implemented Interfaces:
Representable, Serializable
Direct Known Subclasses:
PrimitiveDimensionType

public abstract class DimensionType extends Object implements Serializable, Representable
Base type for all the dimension types.
See Also:
  • Field Details

    • UNKNOWN_SHAPE

      public static final int UNKNOWN_SHAPE
      The reported shape when there is no explicit knowledge other than the underlying primitive type.
      See Also:
    • DUMMY_NAME

      public static final String DUMMY_NAME
      dummy name for dimensionTypes that have not define name
      See Also:
    • OUT_OF_VOCAB

      public static final String OUT_OF_VOCAB
      The reported string value for values out of the mapping for the dimension.
      See Also:
  • Constructor Details

    • DimensionType

      public DimensionType()
  • Method Details

    • setDimensionValue

      public void setDimensionValue(WriteableTuple target, int column, Object dimensionValue)
      Sets a dimension in a particular column of a target tuple. For primitive dimensions, implementations will just copy the value over. (This is the default behavior.) For high-level semantic dimensions that maintain a different set of "outward-facing" and "internal" representations of the dimension values, implementations will apply any necessary translation on the input dimensionValue before inserting into the tuple.
      Parameters:
      target - the destination where the dimension value should be set. Hint: This will often be a com.linkedin.feathr.common.TensorBuilder
      column - the column number of the target tuple to be set
      dimensionValue - the value of the dimension
      Throws:
      RuntimeException - will be thrown if value is not valid for this dimension
    • getDimensionValue

      public Object getDimensionValue(ReadableTuple tuple, int column)
      The inverse of setDimensionValue(com.linkedin.feathr.common.tensor.WriteableTuple, int, java.lang.Object). Reads a dimension from a particular column of a tuple.
      Parameters:
      tuple - the tuple from which to read. Hint: This will often be a TensorIterator
      column - the column to read from the tuple
      Returns:
      the value of the dimension
    • getShape

      public int getShape()
      Get the shape.
      Returns:
      the shape - the number of maximum possible unique values in this dimension. Can be UNKNOWN_SHAPE.
    • getName

      public String getName()
      Get the name of the DimensionType
      Returns:
      the name
    • indexToString

      @Deprecated public String indexToString(long index)
      Deprecated.
      Convert a numeric index to a string representation.
      Parameters:
      index - the numeric index. 0 is reserved for out-of-vocab.
      Returns:
      the string representation
    • stringToIndex

      @Deprecated public long stringToIndex(String string)
      Convert a string representation to a numeric index.
      Parameters:
      string - the string representation
      Returns:
      the numeric index. Categoricals return 0 if out-of-vocab, others will throw unchecked exceptions.