public Expression convertTo(Expression exp, PhysType targetPhysType) { final JavaRowFormat targetFormat = targetPhysType.getFormat(); if (format == targetFormat) { return exp; } final ParameterExpression o_ = Expressions.parameter(javaRowClass, "o"); final int fieldCount = rowType.getFieldCount(); return Expressions.call(exp, BuiltInMethod.SELECT.method, generateSelector(o_, Util.range(fieldCount), targetFormat)); }
public Expression convertTo(Expression exp, PhysType targetPhysType) { final JavaRowFormat targetFormat = targetPhysType.getFormat(); if (format == targetFormat) { return exp; } final ParameterExpression o_ = Expressions.parameter(javaRowClass, "o"); final int fieldCount = rowType.getFieldCount(); return Expressions.call(exp, BuiltInMethod.SELECT.method, generateSelector(o_, Util.range(fieldCount), targetFormat)); }
public Expression generateSelector( ParameterExpression parameter, List<Integer> fields, JavaRowFormat targetFormat) { // Optimize target format switch (fields.size()) { case 0: targetFormat = JavaRowFormat.LIST; break; case 1: targetFormat = JavaRowFormat.SCALAR; break; } final PhysType targetPhysType = project(fields, targetFormat); switch (format) { case SCALAR: return Expressions.call(BuiltInMethod.IDENTITY_SELECTOR.method); default: return Expressions.lambda(Function1.class, targetPhysType.record(fieldReferences(parameter, fields)), parameter); } }
public Expression generateSelector( ParameterExpression parameter, List<Integer> fields, JavaRowFormat targetFormat) { // Optimize target format switch (fields.size()) { case 0: targetFormat = JavaRowFormat.LIST; break; case 1: targetFormat = JavaRowFormat.SCALAR; break; } final PhysType targetPhysType = project(fields, targetFormat); switch (format) { case SCALAR: return Expressions.call(BuiltInMethod.IDENTITY_SELECTOR.method); default: return Expressions.lambda(Function1.class, targetPhysType.record(fieldReferences(parameter, fields)), parameter); } }