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:
Days
,Hours
,Months
,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 Deprecated Methods Modifier and Type Method Description default T
apply(S value)
Deprecated.usebind(Type)
instead; will be removed in 2.0.0default SerializableFunction<S,T>
bind(Type type)
Returns a function that applies this transform to values of the giventype
.boolean
canTransform(Type type)
Checks whether this function can be applied to the givenType
.default java.lang.String
dedupName()
Return the unique transform name to check if similar transforms for the same source field are added multiple times in partition spec builder.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.default boolean
isVoid()
Return whether this transform is the void transform.default boolean
preservesOrder()
Whether the transform preserves the order of values (is monotonic).UnboundPredicate<T>
project(java.lang.String name, BoundPredicate<S> predicate)
Transforms apredicate
to an inclusive predicate on the partition values produced by the transform.UnboundPredicate<T>
projectStrict(java.lang.String name, BoundPredicate<S> predicate)
Transforms apredicate
to a strict predicate on the partition values produced by the transform.default boolean
satisfiesOrderOf(Transform<?,?> other)
Whether ordering by this transform's result satisfies the ordering of another transform's result.default java.lang.String
toHumanString(Type type, T value)
default java.lang.String
toHumanString(T value)
Deprecated.usetoHumanString(Type, Object)
instead; will be removed in 2.0.0
-
-
-
Method Detail
-
apply
@Deprecated default T apply(S value)
Deprecated.usebind(Type)
instead; will be removed in 2.0.0Transforms a value to its corresponding partition value.- Parameters:
value
- a source value- Returns:
- a transformed partition value
-
bind
default SerializableFunction<S,T> bind(Type type)
Returns a function that applies this transform to values of the giventype
.- Parameters:
type
- an IcebergType
- Returns:
- a
Function
that applies this transform to values of the given type.
-
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
-
preservesOrder
default boolean preservesOrder()
Whether the transform preserves the order of values (is monotonic).A transform preserves order for values when for any given a and b, if a < b then apply(a) <= apply(b).
- Returns:
- true if the transform preserves the order of values
-
satisfiesOrderOf
default boolean satisfiesOrderOf(Transform<?,?> other)
Whether ordering by this transform's result satisfies the ordering of another transform's result.For example, sorting by day(ts) will produce an ordering that is also by month(ts) or year(ts). However, sorting by day(ts) will not satisfy the order of hour(ts) or identity(ts).
- Returns:
- true if ordering by this transform is equivalent to ordering by the other transform
-
project
UnboundPredicate<T> project(java.lang.String name, BoundPredicate<S> predicate)
Transforms apredicate
to an inclusive predicate on the partition values produced by the transform.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 by the transform.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
-
isVoid
default boolean isVoid()
Return whether this transform is the void transform.- Returns:
- true if this is a void transform, false otherwise
-
toHumanString
@Deprecated default java.lang.String toHumanString(T value)
Deprecated.usetoHumanString(Type, Object)
instead; will be removed in 2.0.0Returns 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
-
dedupName
default java.lang.String dedupName()
Return the unique transform name to check if similar transforms for the same source field are added multiple times in partition spec builder.- Returns:
- a name used for dedup
-
-