use of org.apache.hadoop.hive.serde2.objectinspector.SettableStructObjectInspector in project presto by prestodb.
the class RcFileTester method writeRcFileColumnOld.
private static DataSize writeRcFileColumnOld(File outputFile, Format format, Compression compression, Type type, Iterator<?> values) throws Exception {
ObjectInspector columnObjectInspector = getJavaObjectInspector(type);
RecordWriter recordWriter = createRcFileWriterOld(outputFile, compression, columnObjectInspector);
SettableStructObjectInspector objectInspector = createSettableStructObjectInspector("test", columnObjectInspector);
Object row = objectInspector.create();
List<StructField> fields = ImmutableList.copyOf(objectInspector.getAllStructFieldRefs());
Serializer serializer = format.createSerializer();
Properties tableProperties = new Properties();
tableProperties.setProperty("columns", "test");
tableProperties.setProperty("columns.types", objectInspector.getTypeName());
serializer.initialize(new JobConf(false), tableProperties);
while (values.hasNext()) {
Object value = values.next();
value = preprocessWriteValueOld(type, value);
objectInspector.setStructFieldData(row, fields.get(0), value);
Writable record = serializer.serialize(row, objectInspector);
recordWriter.write(record);
}
recordWriter.close(false);
return new DataSize(outputFile.length(), BYTE).convertToMostSuccinctDataSize();
}
Aggregations