use of org.apache.parquet.thrift.ThriftMetaData in project parquet-mr by apache.
the class ThriftReadSupport method prepareForRead.
@Override
public RecordMaterializer<T> prepareForRead(Configuration configuration, Map<String, String> keyValueMetaData, MessageType fileSchema, org.apache.parquet.hadoop.api.ReadSupport.ReadContext readContext) {
ThriftMetaData thriftMetaData = ThriftMetaData.fromExtraMetaData(keyValueMetaData);
try {
initThriftClass(thriftMetaData, configuration);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Cannot find Thrift object class for metadata: " + thriftMetaData, e);
}
// if there was not metadata in the file, get it from requested class
if (thriftMetaData == null) {
thriftMetaData = ThriftMetaData.fromThriftClass(thriftClass);
}
String converterClassName = configuration.get(RECORD_CONVERTER_CLASS_KEY, RECORD_CONVERTER_DEFAULT);
return getRecordConverterInstance(converterClassName, thriftClass, readContext.getRequestedSchema(), thriftMetaData.getDescriptor(), configuration);
}
use of org.apache.parquet.thrift.ThriftMetaData in project parquet-mr by apache.
the class AbstractThriftWriteSupport method init.
protected void init(Class<T> thriftClass) {
this.thriftClass = thriftClass;
this.thriftStruct = getThriftStruct();
this.schema = ThriftSchemaConverter.convertWithoutProjection(thriftStruct);
final Map<String, String> extraMetaData = new ThriftMetaData(thriftClass.getName(), thriftStruct).toExtraMetaData();
// TODO: make this work for non-tbase types
if (isPigLoaded() && TBase.class.isAssignableFrom(thriftClass)) {
new PigMetaData(new ThriftToPig((Class<? extends TBase<?, ?>>) thriftClass).toSchema()).addToMetaData(extraMetaData);
}
this.writeContext = new WriteContext(schema, extraMetaData);
}
Aggregations