当前位置: 首页>>代码示例>>Java>>正文


Java Expressions.convert_方法代码示例

本文整理汇总了Java中org.apache.calcite.linq4j.tree.Expressions.convert_方法的典型用法代码示例。如果您正苦于以下问题:Java Expressions.convert_方法的具体用法?Java Expressions.convert_怎么用?Java Expressions.convert_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.linq4j.tree.Expressions的用法示例。

在下文中一共展示了Expressions.convert_方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getTimeZoneExpression

import org.apache.calcite.linq4j.tree.Expressions; //导入方法依赖的package包/类
private UnaryExpression getTimeZoneExpression(
        EnumerableRelImplementor implementor) {
    return Expressions.convert_(
            Expressions.call(
                    implementor.getRootExpression(),
                    "get",
                    Expressions.constant("timeZone")),
            TimeZone.class);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:10,代码来源:JdbcToEnumerableConverter.java


示例2: getTimeZoneExpression

import org.apache.calcite.linq4j.tree.Expressions; //导入方法依赖的package包/类
private UnaryExpression getTimeZoneExpression(
    EnumerableRelImplementor implementor) {
  return Expressions.convert_(
      Expressions.call(
          implementor.getRootExpression(),
          "get",
          Expressions.constant("timeZone")),
      TimeZone.class);
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:JdbcToEnumerableConverter.java


示例3: getExpression

import org.apache.calcite.linq4j.tree.Expressions; //导入方法依赖的package包/类
private static Expression getExpression(RexNode offset) {
  if (offset instanceof RexDynamicParam) {
    final RexDynamicParam param = (RexDynamicParam) offset;
    return Expressions.convert_(
        Expressions.call(DataContext.ROOT,
            BuiltInMethod.DATA_CONTEXT_GET.method,
            Expressions.constant("?" + param.getIndex())),
        Integer.class);
  } else {
    return Expressions.constant(RexLiteral.intValue(offset));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:EnumerableLimit.java


示例4: fromInternal

import org.apache.calcite.linq4j.tree.Expressions; //导入方法依赖的package包/类
/** Converts from internal representation to JDBC representation used by
 * arguments of user-defined functions. For example, converts date values from
 * {@code int} to {@link java.sql.Date}. */
static Expression fromInternal(Expression e, Class<?> targetType) {
  if (e == ConstantUntypedNull.INSTANCE) {
    return e;
  }
  if (!(e.getType() instanceof Class)) {
    return e;
  }
  if (targetType.isAssignableFrom((Class) e.getType())) {
    return e;
  }
  if (targetType == java.sql.Date.class) {
    return Expressions.call(BuiltInMethod.INTERNAL_TO_DATE.method, e);
  }
  if (targetType == java.sql.Time.class) {
    return Expressions.call(BuiltInMethod.INTERNAL_TO_TIME.method, e);
  }
  if (targetType == java.sql.Timestamp.class) {
    return Expressions.call(BuiltInMethod.INTERNAL_TO_TIMESTAMP.method, e);
  }
  if (Primitive.is(e.type)
      && Primitive.isBox(targetType)) {
    // E.g. e is "int", target is "Long", generate "(long) e".
    return Expressions.convert_(e,
        Primitive.ofBox(targetType).primitiveClass);
  }
  return e;
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:EnumUtils.java


示例5: unwrap

import org.apache.calcite.linq4j.tree.Expressions; //导入方法依赖的package包/类
/** Converts a schema expression to a given type by calling the
 * {@link SchemaPlus#unwrap(Class)} method. */
public static Expression unwrap(Expression call, Class type) {
  return Expressions.convert_(
      Expressions.call(call, BuiltInMethod.SCHEMA_PLUS_UNWRAP.method,
          Expressions.constant(type)),
      type);
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:Schemas.java


示例6: generateGet

import org.apache.calcite.linq4j.tree.Expressions; //导入方法依赖的package包/类
private void generateGet(EnumerableRelImplementor implementor,
                         PhysType physType, BlockBuilder builder, ParameterExpression resultSet,
                         int i, Expression target, Expression calendar,
                         CalendarPolicy calendarPolicy) {
    final Primitive primitive = Primitive.ofBoxOr(physType.fieldClass(i));
    final RelDataType fieldType =
            physType.getRowType().getFieldList().get(i).getType();
    final List<Expression> dateTimeArgs = new ArrayList<Expression>();
    dateTimeArgs.add(Expressions.constant(i + 1));
    SqlTypeName sqlTypeName = fieldType.getSqlTypeName();
    boolean offset = false;
    switch (calendarPolicy) {
    case LOCAL:
        dateTimeArgs.add(calendar);
        break;
    case NULL:
        // We don't specify a calendar at all, so we don't add an argument and
        // instead use the version of the getXXX that doesn't take a Calendar
        break;
    case DIRECT:
        sqlTypeName = SqlTypeName.ANY;
        break;
    case SHIFT:
        switch (sqlTypeName) {
        case TIMESTAMP:
        case DATE:
            offset = true;
            break;
        default:
        }
        break;
    default:
    }
    final Expression source;
    switch (sqlTypeName) {
    case DATE:
    case TIME:
    case TIMESTAMP:
        source = Expressions.call(
                getMethod(sqlTypeName, fieldType.isNullable(), offset),
                Expressions.<Expression>list()
                        .append(
                                Expressions.call(resultSet,
                                        getMethod2(sqlTypeName), dateTimeArgs))
                        .appendIf(offset, getTimeZoneExpression(implementor)));
        break;
    case ARRAY:
        final Expression x = Expressions.convert_(
                Expressions.call(resultSet, jdbcGetMethod(primitive),
                        Expressions.constant(i + 1)),
                java.sql.Array.class);
        source = Expressions.call(BuiltInMethod.JDBC_ARRAY_TO_LIST.method, x);
        break;
    default:
        source = Expressions.call(
                resultSet, jdbcGetMethod(primitive), Expressions.constant(i + 1));
    }
    builder.add(
            Expressions.statement(
                    Expressions.assign(
                            target, source)));

    // [CALCITE-596] If primitive type columns contain null value, returns null
    // object
    if (primitive != null) {
        builder.add(
                Expressions.ifThen(
                        Expressions.call(resultSet, "wasNull"),
                        Expressions.statement(
                                Expressions.assign(target,
                                        Expressions.constant(null)))));
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:74,代码来源:JdbcToEnumerableConverter.java


示例7: generateGet

import org.apache.calcite.linq4j.tree.Expressions; //导入方法依赖的package包/类
private void generateGet(EnumerableRelImplementor implementor,
    PhysType physType, BlockBuilder builder, ParameterExpression resultSet_,
    int i, Expression target, Expression calendar_,
    SqlDialect.CalendarPolicy calendarPolicy) {
  final Primitive primitive = Primitive.ofBoxOr(physType.fieldClass(i));
  final RelDataType fieldType =
      physType.getRowType().getFieldList().get(i).getType();
  final List<Expression> dateTimeArgs = new ArrayList<Expression>();
  dateTimeArgs.add(Expressions.constant(i + 1));
  SqlTypeName sqlTypeName = fieldType.getSqlTypeName();
  boolean offset = false;
  switch (calendarPolicy) {
  case LOCAL:
    dateTimeArgs.add(calendar_);
    break;
  case NULL:
    // We don't specify a calendar at all, so we don't add an argument and
    // instead use the version of the getXXX that doesn't take a Calendar
    break;
  case DIRECT:
    sqlTypeName = SqlTypeName.ANY;
    break;
  case SHIFT:
    switch (sqlTypeName) {
    case TIMESTAMP:
    case DATE:
      offset = true;
    }
    break;
  }
  final Expression source;
  switch (sqlTypeName) {
  case DATE:
  case TIME:
  case TIMESTAMP:
    source = Expressions.call(
        getMethod(sqlTypeName, fieldType.isNullable(), offset),
        Expressions.<Expression>list()
            .append(
                Expressions.call(resultSet_,
                    getMethod2(sqlTypeName), dateTimeArgs))
        .appendIf(offset, getTimeZoneExpression(implementor)));
    break;
  case ARRAY:
    final Expression x = Expressions.convert_(
        Expressions.call(resultSet_, jdbcGetMethod(primitive),
            Expressions.constant(i + 1)),
        java.sql.Array.class);
    source = Expressions.call(BuiltInMethod.JDBC_ARRAY_TO_LIST.method, x);
    break;
  default:
    source = Expressions.call(
        resultSet_, jdbcGetMethod(primitive), Expressions.constant(i + 1));
  }
  builder.add(
      Expressions.statement(
          Expressions.assign(
              target, source)));

  // [CALCITE-596] If primitive type columns contain null value, returns null
  // object
  if (primitive != null) {
    builder.add(
        Expressions.ifThen(
            Expressions.call(resultSet_, "wasNull"),
            Expressions.statement(
                Expressions.assign(target,
                    Expressions.constant(null)))));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:71,代码来源:JdbcToEnumerableConverter.java



注:本文中的org.apache.calcite.linq4j.tree.Expressions.convert_方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。