S
- Java class of source valuesT
- Java class of transformed valuespublic interface Transform<S,T>
extends java.io.Serializable
Implementations of this interface can be used to transform values, check or types, and project
predicates
to predicates on partition values.
Modifier and Type | Method and Description |
---|---|
T |
apply(S value)
Transforms a value to its corresponding partition value.
|
boolean |
canTransform(Type type)
Checks whether this function can be applied to the given
Type . |
Type |
getResultType(Type sourceType)
Returns the
Type produced by this transform given a source type. |
default boolean |
isIdentity()
Return whether this transform is the identity transform.
|
UnboundPredicate<T> |
project(java.lang.String name,
BoundPredicate<S> predicate)
Transforms a
predicate to an inclusive predicate on the partition
values produced by apply(Object) . |
UnboundPredicate<T> |
projectStrict(java.lang.String name,
BoundPredicate<S> predicate)
Transforms a
predicate to a strict predicate on the partition values
produced by apply(Object) . |
default java.lang.String |
toHumanString(T value)
Returns a human-readable String representation of a transformed value.
|
T apply(S value)
value
- a source valueboolean canTransform(Type type)
Type
.type
- a typeType getResultType(Type sourceType)
Type
produced by this transform given a source type.sourceType
- a typeUnboundPredicate<T> project(java.lang.String name, BoundPredicate<S> predicate)
predicate
to an inclusive predicate on the partition
values produced by apply(Object)
.
This inclusive transform guarantees that if pred(v) is true, then projected(apply(v)) is true.
name
- the field name for partition valuespredicate
- a predicate for source valuesUnboundPredicate<T> projectStrict(java.lang.String name, BoundPredicate<S> predicate)
predicate
to a strict predicate on the partition values
produced by apply(Object)
.
This strict transform guarantees that if strict(apply(v)) is true, then pred(v) is also true.
name
- the field name for partition valuespredicate
- a predicate for source valuesdefault boolean isIdentity()
default java.lang.String toHumanString(T value)
null values will return "null"
value
- a transformed value