Class EnumUtils
java.lang.Object
org.apache.calcite.adapter.enumerable.EnumUtils
Utilities for generating programs in the Enumerable (functional)
style.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic MethodCallExpression
call
(@Nullable Expression targetExpression, Class clazz, String methodName, List<? extends Expression> arguments) A more powerful version ofExpressions.call(Type, String, Iterable)
.static Expression
convert
(Expression operand, Type toType) Convertoperand
to target typetoType
.static Expression
convert
(Expression operand, Type fromType, Type toType) Convertoperand
to target typetoType
.static <T> @Nullable T
Converts a value to a given class.static @Nullable Expression
generateCollatorExpression
(@Nullable SqlCollation collation) static Enumerable<@Nullable Object[]>
hopping
(Enumerator<@Nullable Object[]> inputEnumerator, int indexOfWatermarkedColumn, long emitFrequency, long windowSize, long offset) Create enumerable implementation that applies hopping on each element from the input enumerator and produces at least one element for each input element.static MethodDeclaration
overridingMethodDecl
(Method method, Iterable<ParameterExpression> parameters, BlockStatement body) Declares a method that overrides another method.static Enumerable<@Nullable Object[]>
sessionize
(Enumerator<@Nullable Object[]> inputEnumerator, int indexOfWatermarkedColumn, int indexOfKeyColumn, long gap) Creates enumerable implementation that applies sessionization to elements from the input enumerator based on a specified key.toExternal
(List<RelDataType> types, TimeZone timeZone) Returns a function that converts an array of internal values to a list of external values.toExternal
(RelDataType type, TimeZone timeZone) Returns a function that converts an internal value to an external value.static <TSource,
TResult>
Enumerable<TResult>tumbling
(Enumerable<TSource> inputEnumerable, Function1<TSource, TResult> outSelector) Apply tumbling per row from the enumerable input.
-
Field Details
-
LEFT_RIGHT
-
-
Method Details
-
overridingMethodDecl
public static MethodDeclaration overridingMethodDecl(Method method, Iterable<ParameterExpression> parameters, BlockStatement body) Declares a method that overrides another method. -
convert
Convertoperand
to target typetoType
.- Parameters:
operand
- The expression to converttoType
- Target type- Returns:
- A new expression with type
toType
or original if there is no need to convert
-
convert
Convertoperand
to target typetoType
.- Parameters:
operand
- The expression to convertfromType
- Field typetoType
- Target type- Returns:
- A new expression with type
toType
or original if there is no need to convert
-
evaluate
Converts a value to a given class. -
call
public static MethodCallExpression call(@Nullable Expression targetExpression, Class clazz, String methodName, List<? extends Expression> arguments) A more powerful version ofExpressions.call(Type, String, Iterable)
. Tries best effort to convert the accepted arguments to match parameter type.- Parameters:
targetExpression
- Target expression, or null if method is staticclazz
- Class against which method is invokedmethodName
- Name of methodarguments
- Argument expressions- Returns:
- MethodCallExpression that call the given name method
- Throws:
RuntimeException
- if no suitable method found
-
sessionize
public static Enumerable<@Nullable Object[]> sessionize(Enumerator<@Nullable Object[]> inputEnumerator, int indexOfWatermarkedColumn, int indexOfKeyColumn, long gap) Creates enumerable implementation that applies sessionization to elements from the input enumerator based on a specified key. Elements are windowed into sessions separated by periods with no input for at least the duration specified by gap parameter. -
hopping
public static Enumerable<@Nullable Object[]> hopping(Enumerator<@Nullable Object[]> inputEnumerator, int indexOfWatermarkedColumn, long emitFrequency, long windowSize, long offset) Create enumerable implementation that applies hopping on each element from the input enumerator and produces at least one element for each input element. -
tumbling
public static <TSource,TResult> Enumerable<TResult> tumbling(Enumerable<TSource> inputEnumerable, Function1<TSource, TResult> outSelector) Apply tumbling per row from the enumerable input. -
generateCollatorExpression
-
toExternal
Returns a function that converts an internal value to an external value.Datetime values' internal representations have no time zone, and their external values are moments (relative to UTC epoch), so the
timeZone
parameter supplies the implicit time zone of the internal representation. If you specify the local time zone of the JVM, thenTimestamp.toString()
,Date.toString()
, andTime.toString()
on the external values will give a value consistent with the internal values. -
toExternal
public static Function<@Nullable Object[],List<@Nullable Object>> toExternal(List<RelDataType> types, TimeZone timeZone) Returns a function that converts an array of internal values to a list of external values.
-