Enum Class Primitive
- All Implemented Interfaces:
Representable,Serializable,Comparable<Primitive>,Constable
Supported primitive types.
They serve as basis for scalars - dimensions and values.
Note: String types should only be used when the dimension is an actual text snippet.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanabstract booleanThis method is called to check if the column Type of the value can be of the specified Primitive.abstract intcompare(ReadableTuple leftTuple, int leftColumn, ReadableTuple rightTuple, int rightColumn) Compares data at leftTuple[leftColumn] with data at rightTuple[rightColumn] Note: The representation of both leftColumn and rightColumn is assumed to be the same asthisNo validation on representation is performedabstract voidcopy(ReadableTuple fromTuple, int fromColumn, WriteableTuple toTuple, int toColumn) Copies data from fromTuple[fromColumn] to toTuple[toColumn] Note: The representation of both fromColumn and toColumn is assumed to be the same asthisNo validation on representation is performedabstract booleanequals(ReadableTuple leftTuple, int leftColumn, ReadableTuple rightTuple, int rightColumn) Matches data at leftTuple[leftColumn] with data at rightTuple[rightColumn] Note: The representation of both leftColumn and rightColumn is assumed to be the same asthisNo validation on representation is performedabstract voidfrom(boolean value, WriteableTuple tuple, int column) abstract voidfrom(byte[] value, WriteableTuple tuple, int column) Stores value from its byte[] serialization in the input tuple.abstract voidfrom(double value, WriteableTuple tuple, int column) abstract voidfrom(float value, WriteableTuple tuple, int column) abstract voidfrom(int value, WriteableTuple tuple, int column) abstract voidfrom(long value, WriteableTuple tuple, int column) abstract voidfrom(Number value, WriteableTuple tuple, int column) voidfrom(Object value, WriteableTuple tuple, int column) abstract voidfrom(String value, WriteableTuple tuple, int column) abstract booleanisInstance(Object obj) check whether the input object is of the primitive type without coercion.abstract booleantoBoolean(ReadableTuple tuple, int column) abstract byte[]toBytes(ReadableTuple tuple, int column) Returns value serialized into a byte[].abstract doubletoDouble(ReadableTuple tuple, int column) abstract floattoFloat(ReadableTuple tuple, int column) abstract inttoInt(ReadableTuple tuple, int column) abstract longtoLong(ReadableTuple tuple, int column) abstract ObjecttoObject(ReadableTuple tuple, int column) abstract StringtoString(ReadableTuple tuple, int column) static PrimitiveReturns the enum constant of this class with the specified name.static Primitive[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INT
-
LONG
-
FLOAT
-
DOUBLE
-
BOOLEAN
-
STRING
-
BYTES
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getRepresentation
- Specified by:
getRepresentationin interfaceRepresentable
-
toInt
-
toLong
-
toFloat
-
toDouble
-
toBoolean
-
toString
-
toBytes
Returns value serialized into a byte[]. For numeric types (int, long, float, double), BIG_ENDIAN byte order is preserved. For string type, a UTF-8 charset is used to get bytes. For booleans, a single byte is returned in the array.- Parameters:
tuple- Input tuplecolumn- Column index- Returns:
- Value in byte[]
-
toObject
-
from
-
from
-
from
-
from
-
from
-
from
-
from
-
from
-
from
Stores value from its byte[] serialization in the input tuple. For numeric types (int, long, float, double), BIG_ENDIAN byte order is expected. For string type, a UTF-8 charset is used to construct the string. For booleans, only the leading byte of the array is checked.- Parameters:
value- Input valuetuple- Input tuple to store the valuecolumn- Column index
-
copy
public abstract void copy(ReadableTuple fromTuple, int fromColumn, WriteableTuple toTuple, int toColumn) Copies data from fromTuple[fromColumn] to toTuple[toColumn] Note: The representation of both fromColumn and toColumn is assumed to be the same asthisNo validation on representation is performed- Parameters:
fromTuple-ReadableTuplefrom which to copyfromColumn- column in fromTuple to copytoTuple-WriteableTuplewhere the data would be copiedtoColumn- column in toTuple where the data would be copied
-
equals
public abstract boolean equals(ReadableTuple leftTuple, int leftColumn, ReadableTuple rightTuple, int rightColumn) Matches data at leftTuple[leftColumn] with data at rightTuple[rightColumn] Note: The representation of both leftColumn and rightColumn is assumed to be the same asthisNo validation on representation is performed- Parameters:
leftTuple- left tuple from which a column will be matchedleftColumn- column in leftTuple that will be matchedrightTuple- right tuple from which a column will be matchedrightColumn- column in right tuple that will be matched- Returns:
- true if data is equal, false otherwise
-
compare
public abstract int compare(ReadableTuple leftTuple, int leftColumn, ReadableTuple rightTuple, int rightColumn) Compares data at leftTuple[leftColumn] with data at rightTuple[rightColumn] Note: The representation of both leftColumn and rightColumn is assumed to be the same asthisNo validation on representation is performed- Parameters:
leftTuple- left tuple from which a column will be comparedleftColumn- column in leftTuple that will be comparedrightTuple- right tuple from which a column will be comparedrightColumn- column in right tuple that will be compared- Returns:
- -1 if lefttuple[leftColumn] < rightTuple[rightColumn], 0 if lefttuple[leftColumn] == rightTuple[rightColumn], 1 if lefttuple[leftColumn] > rightTuple[rightColumn]
-
canBeDenseDimension
public abstract boolean canBeDenseDimension()- Returns:
- if this primitive type can be used as a dimension in dense tensors.
In other words, is this type integral.
If true, the type MUST support
toInt(com.linkedin.feathr.common.tensor.ReadableTuple, int),toLong(com.linkedin.feathr.common.tensor.ReadableTuple, int), andfrom(java.lang.Object, com.linkedin.feathr.common.tensor.WriteableTuple, int)with both int and long value.
-
canBeValue
public abstract boolean canBeValue()This method is called to check if the column Type of the value can be of the specified Primitive.- Returns:
- the Primitive of the column type
-
isInstance
check whether the input object is of the primitive type without coercion.
-