-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Labels
Description
Revise implementation to support multiple field projection, by names
and indexes.
package org.apache.wayang.basic.function;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.wayang.basic.data.Record;
import org.apache.wayang.basic.types.RecordType;
import org.apache.wayang.core.function.FunctionDescriptor;
import org.apache.wayang.core.function.TransformationDescriptor;
import org.apache.wayang.core.types.BasicDataUnitType;
/**
* This descriptor pertains to projections. It takes field names of the input
* type to describe the projection.
*/
public class ProjectionDescriptor<Input, Output> extends TransformationDescriptor<Input, Output> {
/**
* Java implementation of a projection on POJOs via reflection.
*/
// TODO: Revise implementation to support multiple field projection, by names
// and indexes.
private static class PojoImplementation<Input, Output>
implements FunctionDescriptor.SerializableFunction<Input, Output> {
private final String fieldName;
private Field field;
private PojoImplementation(final String fieldName) {
this.fieldName = fieldName;
}
@Override
@SuppressWarnings("unchecked")
public Output apply(final Input input) {
// Initialization code.
if (this.field == null) {
40e1e0f9785d58f9ab9731824c00aef5b0a84db7