Class DimensionType
java.lang.Object
com.linkedin.feathr.common.tensor.DimensionType
- All Implemented Interfaces:
Representable,Serializable
- Direct Known Subclasses:
PrimitiveDimensionType
Base type for all the dimension types.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringdummy name for dimensionTypes that have not define namestatic final StringThe reported string value for values out of the mapping for the dimension.static final intThe reported shape when there is no explicit knowledge other than the underlying primitive type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDimensionValue(ReadableTuple tuple, int column) getName()Get the name of the DimensionTypeintgetShape()Get the shape.indexToString(long index) Deprecated.voidsetDimensionValue(WriteableTuple target, int column, Object dimensionValue) Sets a dimension in a particular column of a target tuple.longstringToIndex(String string) Deprecated.UsesetDimensionValue(WriteableTuple, int, Object)insteadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.feathr.common.tensor.Representable
getRepresentation
-
Field Details
-
UNKNOWN_SHAPE
public static final int UNKNOWN_SHAPEThe reported shape when there is no explicit knowledge other than the underlying primitive type.- See Also:
-
DUMMY_NAME
dummy name for dimensionTypes that have not define name- See Also:
-
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
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 acom.linkedin.feathr.common.TensorBuildercolumn- the column number of the target tuple to be setdimensionValue- the value of the dimension- Throws:
RuntimeException- will be thrown if value is not valid for this dimension
-
getDimensionValue
The inverse ofsetDimensionValue(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 aTensorIteratorcolumn- 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
Get the name of the DimensionType- Returns:
- the name
-
indexToString
Deprecated.UsegetDimensionValue(ReadableTuple, int)insteadConvert 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.UsesetDimensionValue(WriteableTuple, int, Object)insteadConvert 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.
-
getDimensionValue(ReadableTuple, int)instead