Package io.substrait.relation
Class CopyOnWriteUtils
java.lang.Object
io.substrait.relation.CopyOnWriteUtils
Provides common utilities for copy-on-write visitations
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCopyOnWriteUtils.TransformFunction<T,C extends VisitationContext, E extends Exception> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturnstrueif all provided optionals are empty.static <T> Optional<T>Returnsleftif present; otherwise returns the result ofright.get().static <I,C extends VisitationContext, E extends Exception>
Optional<List<I>>transformList(List<I> items, C context, CopyOnWriteUtils.TransformFunction<I, C, E> transform) Applies the given transformation function to each item in the list.
-
Constructor Details
-
CopyOnWriteUtils
public CopyOnWriteUtils()
-
-
Method Details
-
allEmpty
Returnstrueif all provided optionals are empty.- Parameters:
optionals- the optionals to inspect- Returns:
truewhen none are present;falseotherwise
-
or
Returnsleftif present; otherwise returns the result ofright.get().- Type Parameters:
T- the value type- Parameters:
left- the first optionalright- supplier of the fallback optional- Returns:
leftwhen present; otherwise the supplied optional
-
transformList
public static <I,C extends VisitationContext, Optional<List<I>> transformListE extends Exception> (List<I> items, C context, CopyOnWriteUtils.TransformFunction<I, C, throws EE> transform) Applies the given transformation function to each item in the list. If any of the list items are transformed, returns a new list in which each item is either- a transformed new item replacing an old item
- the original item in the position it was in
- Type Parameters:
I- the item typeC- the visitation context typeE- the exception type thrown by the transform- Parameters:
items- the list of items to transformcontext- the visitation contexttransform- the transformation function to apply to each item- Returns:
- An empty optional if none of the items have changed. An optional containing a new list otherwise.
- Throws:
E- if the transform function throws
-