Package org.apache.iceberg.transforms
Interface Transform<S,T>
-
- Type Parameters:
S
- Java class of source valuesT
- Java class of transformed values
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
UnknownTransform
public interface Transform<S,T> extends java.io.Serializable
A transform function used for partitioning.Implementations of this interface can be used to transform values, check or types, and project
predicates
to predicates on partition values.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method 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 givenType
.Type
getResultType(Type sourceType)
Returns theType
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 apredicate
to an inclusive predicate on the partition values produced byapply(Object)
.UnboundPredicate<T>
projectStrict(java.lang.String name, BoundPredicate<S> predicate)
Transforms apredicate
to a strict predicate on the partition values produced byapply(Object)
.default java.lang.String
toHumanString(T value)
Returns a human-readable String representation of a transformed value.
-
-
-
Method Detail
-
apply
T apply(S value)
Transforms a value to its corresponding partition value.- Parameters:
value
- a source value- Returns:
- a transformed partition value
-
canTransform
boolean canTransform(Type type)
Checks whether this function can be applied to the givenType
.- Parameters:
type
- a type- Returns:
- true if this transform can be applied to the type, false otherwise
-
getResultType
Type getResultType(Type sourceType)
Returns theType
produced by this transform given a source type.- Parameters:
sourceType
- a type- Returns:
- the result type created by the apply method for the given type
-
project
UnboundPredicate<T> project(java.lang.String name, BoundPredicate<S> predicate)
Transforms apredicate
to an inclusive predicate on the partition values produced byapply(Object)
.This inclusive transform guarantees that if pred(v) is true, then projected(apply(v)) is true.
- Parameters:
name
- the field name for partition valuespredicate
- a predicate for source values- Returns:
- an inclusive predicate on partition values
-
projectStrict
UnboundPredicate<T> projectStrict(java.lang.String name, BoundPredicate<S> predicate)
Transforms apredicate
to a strict predicate on the partition values produced byapply(Object)
.This strict transform guarantees that if strict(apply(v)) is true, then pred(v) is also true.
- Parameters:
name
- the field name for partition valuespredicate
- a predicate for source values- Returns:
- an inclusive predicate on partition values
-
isIdentity
default boolean isIdentity()
Return whether this transform is the identity transform.- Returns:
- true if this is an identity transform, false otherwise
-
toHumanString
default java.lang.String toHumanString(T value)
Returns a human-readable String representation of a transformed value.null values will return "null"
- Parameters:
value
- a transformed value- Returns:
- a human-readable String representation of the value
-
-