本文整理汇总了Java中org.apache.calcite.linq4j.tree.Primitive.ofBoxOr方法的典型用法代码示例。如果您正苦于以下问题:Java Primitive.ofBoxOr方法的具体用法?Java Primitive.ofBoxOr怎么用?Java Primitive.ofBoxOr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.linq4j.tree.Primitive
的用法示例。
在下文中一共展示了Primitive.ofBoxOr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateGet
import org.apache.calcite.linq4j.tree.Primitive; //导入方法依赖的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)))));
}
}
示例2: implementSpark
import org.apache.calcite.linq4j.tree.Primitive; //导入方法依赖的package包/类
public SparkRel.Result implementSpark(SparkRel.Implementor implementor) {
// Generate:
// ResultSetEnumerable.of(schema.getDataSource(), "select ...")
final BlockBuilder list = new BlockBuilder();
final JdbcRel child = (JdbcRel) getInput();
final PhysType physType =
PhysTypeImpl.of(
implementor.getTypeFactory(), getRowType(),
JavaRowFormat.CUSTOM);
final JdbcConvention jdbcConvention =
(JdbcConvention) child.getConvention();
String sql = generateSql(jdbcConvention.dialect);
if (CalcitePrepareImpl.DEBUG) {
System.out.println("[" + sql + "]");
}
final Expression sqlLiteral =
list.append("sql", Expressions.constant(sql));
final List<Primitive> primitives = new ArrayList<Primitive>();
for (int i = 0; i < getRowType().getFieldCount(); i++) {
final Primitive primitive = Primitive.ofBoxOr(physType.fieldClass(i));
primitives.add(primitive != null ? primitive : Primitive.OTHER);
}
final Expression primitivesLiteral =
list.append("primitives",
Expressions.constant(
primitives.toArray(new Primitive[primitives.size()])));
final Expression enumerable =
list.append(
"enumerable",
Expressions.call(
BuiltInMethod.RESULT_SET_ENUMERABLE_OF.method,
Expressions.call(
Expressions.convert_(
jdbcConvention.expression,
JdbcSchema.class),
BuiltInMethod.JDBC_SCHEMA_DATA_SOURCE.method),
sqlLiteral,
primitivesLiteral));
list.add(
Expressions.return_(null, enumerable));
return implementor.result(physType, list.toBlock());
}
示例3: generateGet
import org.apache.calcite.linq4j.tree.Primitive; //导入方法依赖的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)))));
}
}
示例4: implement
import org.apache.calcite.linq4j.tree.Primitive; //导入方法依赖的package包/类
public Expression implement(
RexToLixTranslator translator,
RexCall call,
List<Expression> expressions) {
// neither nullable:
// return x OP y
// x nullable
// null_returns_null
// return x == null ? null : x OP y
// ignore_null
// return x == null ? null : y
// x, y both nullable
// null_returns_null
// return x == null || y == null ? null : x OP y
// ignore_null
// return x == null ? y : y == null ? x : x OP y
if (backupMethodName != null) {
// If one or both operands have ANY type, use the late-binding backup
// method.
if (anyAnyOperands(call)) {
return callBackupMethodAnyType(translator, call, expressions);
}
final Type type0 = expressions.get(0).getType();
final Type type1 = expressions.get(1).getType();
final SqlBinaryOperator op = (SqlBinaryOperator) call.getOperator();
final Primitive primitive = Primitive.ofBoxOr(type0);
if (primitive == null
|| type1 == BigDecimal.class
|| COMPARISON_OPERATORS.contains(op)
&& !COMP_OP_TYPES.contains(primitive)) {
return Expressions.call(SqlFunctions.class, backupMethodName,
expressions);
}
}
final Type returnType =
translator.typeFactory.getJavaClass(call.getType());
return Types.castIfNecessary(returnType,
Expressions.makeBinary(expressionType, expressions.get(0),
expressions.get(1)));
}