private static RecordField getRecordField(String fieldName, RecordType type) { for (RecordField field : type.getRecordFields()) { if (field.getName().equals(fieldName)) { return field; } } throw new RuntimeException( "Unknown field '" + fieldName + "' in type " + type); }
classDeclaration.memberDeclarations.add( Expressions.fieldDecl( field.getModifiers(), Expressions.parameter( field.getType(), field.getName()), null)); for (Types.RecordField field : type.getRecordFields()) { conditions.add( Primitive.is(field.getType()) ? Expressions.equal( Expressions.field(thisParameter, field.getName()), Expressions.field(thatParameter, field.getName())) : Expressions.call(BuiltInMethod.OBJECTS_EQUAL.method, Expressions.field(thisParameter, field.getName()), Expressions.field(thatParameter, field.getName()))); MethodCallExpression compareCall; try { final Method method = (field.nullable() ? BuiltInMethod.COMPARE_NULLS_LAST : BuiltInMethod.COMPARE).method; if (expression5 == null) { expression5 = Expressions.constant("{" + field.getName() + "="); } else { expression5 = Expressions.add(
classDeclaration.memberDeclarations.add( Expressions.fieldDecl( field.getModifiers(), Expressions.parameter( field.getType(), field.getName()), null)); for (Types.RecordField field : type.getRecordFields()) { conditions.add( Primitive.is(field.getType()) ? Expressions.equal( Expressions.field(thisParameter, field.getName()), Expressions.field(thatParameter, field.getName())) : Expressions.call(BuiltInMethod.OBJECTS_EQUAL.method, Expressions.field(thisParameter, field.getName()), Expressions.field(thatParameter, field.getName()))); MethodCallExpression compareCall; try { final Method method = (field.nullable() ? BuiltInMethod.COMPARE_NULLS_LAST : BuiltInMethod.COMPARE).method; if (expression5 == null) { expression5 = Expressions.constant("{" + field.getName() + "="); } else { expression5 = Expressions.add(
static PhysType of( final JavaTypeFactory typeFactory, Type javaRowClass) { final RelDataTypeFactory.Builder builder = typeFactory.builder(); if (javaRowClass instanceof Types.RecordType) { final Types.RecordType recordType = (Types.RecordType) javaRowClass; for (Types.RecordField field : recordType.getRecordFields()) { builder.add(field.getName(), typeFactory.createType(field.getType())); } } RelDataType rowType = builder.build(); // Do not optimize if there are 0 or 1 fields. return new PhysTypeImpl(typeFactory, rowType, javaRowClass, JavaRowFormat.CUSTOM); }
static PhysType of( final JavaTypeFactory typeFactory, Type javaRowClass) { final RelDataTypeFactory.Builder builder = typeFactory.builder(); if (javaRowClass instanceof Types.RecordType) { final Types.RecordType recordType = (Types.RecordType) javaRowClass; for (Types.RecordField field : recordType.getRecordFields()) { builder.add(field.getName(), typeFactory.createType(field.getType())); } } RelDataType rowType = builder.build(); // Do not optimize if there are 0 or 1 fields. return new PhysTypeImpl(typeFactory, rowType, javaRowClass, JavaRowFormat.CUSTOM); }
public MemberExpression field(Expression expression, int field, Type fromType, Type fieldType) { final Type type = expression.getType(); if (type instanceof Types.RecordType) { Types.RecordType recordType = (Types.RecordType) type; Types.RecordField recordField = recordType.getRecordFields().get(field); return Expressions.field(expression, recordField.getDeclaringClass(), recordField.getName()); } else { return Expressions.field(expression, Types.nthField(field, type)); } } },
public MemberExpression field(Expression expression, int field, Type fromType, Type fieldType) { final Type type = expression.getType(); if (type instanceof Types.RecordType) { Types.RecordType recordType = (Types.RecordType) type; Types.RecordField recordField = recordType.getRecordFields().get(field); return Expressions.field(expression, recordField.getDeclaringClass(), recordField.getName()); } else { return Expressions.field(expression, Types.nthField(field, type)); } } },