use of org.apache.drill.exec.store.pojo.Writers.NIntWriter in project drill by apache.
the class PojoRecordReader method setup.
@Override
public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException {
operatorContext = context;
try {
Field[] fields = pojoClass.getDeclaredFields();
List<PojoWriter> writers = Lists.newArrayList();
for (int i = 0; i < fields.length; i++) {
Field f = fields[i];
if (Modifier.isStatic(f.getModifiers())) {
continue;
}
Class<?> type = f.getType();
PojoWriter w = null;
if (type == int.class) {
w = new IntWriter(f);
} else if (type == Integer.class) {
w = new NIntWriter(f);
} else if (type == Long.class) {
w = new NBigIntWriter(f);
} else if (type == Boolean.class) {
w = new NBooleanWriter(f);
} else if (type == double.class) {
w = new DoubleWriter(f);
} else if (type == Double.class) {
w = new NDoubleWriter(f);
} else if (type.isEnum()) {
w = new EnumWriter(f, output.getManagedBuffer());
} else if (type == boolean.class) {
w = new BitWriter(f);
} else if (type == long.class) {
w = new LongWriter(f);
} else if (type == String.class) {
w = new StringWriter(f, output.getManagedBuffer());
} else if (type == Timestamp.class) {
w = new NTimeStampWriter(f);
} else {
throw new ExecutionSetupException(String.format("PojoRecord reader doesn't yet support conversions from type [%s].", type));
}
writers.add(w);
w.init(output);
}
this.writers = writers.toArray(new PojoWriter[writers.size()]);
} catch (SchemaChangeException e) {
throw new ExecutionSetupException("Failure while setting up schema for PojoRecordReader.", e);
}
currentIterator = pojoObjects.iterator();
}
Aggregations