Class EnumUtils

java.lang.Object
org.apache.calcite.adapter.enumerable.EnumUtils

public class EnumUtils extends Object
Utilities for generating programs in the Enumerable (functional) style.
  • Field Details

    • LEFT_RIGHT

      public static final List<String> LEFT_RIGHT
  • Method Details

    • overridingMethodDecl

      public static MethodDeclaration overridingMethodDecl(Method method, Iterable<ParameterExpression> parameters, BlockStatement body)
      Declares a method that overrides another method.
    • convert

      public static Expression convert(Expression operand, Type toType)
      Convert operand to target type toType.
      Parameters:
      operand - The expression to convert
      toType - Target type
      Returns:
      A new expression with type toType or original if there is no need to convert
    • convert

      public static Expression convert(Expression operand, Type fromType, Type toType)
      Convert operand to target type toType.
      Parameters:
      operand - The expression to convert
      fromType - Field type
      toType - Target type
      Returns:
      A new expression with type toType or original if there is no need to convert
    • evaluate

      public static <T> @Nullable T evaluate(Object o, Class<T> clazz)
      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 of Expressions.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 static
      clazz - Class against which method is invoked
      methodName - Name of method
      arguments - 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

      public static @Nullable Expression generateCollatorExpression(@Nullable SqlCollation collation)
    • toExternal

      public static Function<Object,Object> toExternal(RelDataType type, TimeZone timeZone)
      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, then Timestamp.toString(), Date.toString(), and Time.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.