Search in sources :

Example 1 with ThriftMetaData

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);
}
Also used : ThriftMetaData(org.apache.parquet.thrift.ThriftMetaData)

Example 2 with ThriftMetaData

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);
}
Also used : ThriftMetaData(org.apache.parquet.thrift.ThriftMetaData) PigMetaData(org.apache.parquet.pig.PigMetaData) TBase(org.apache.thrift.TBase) ThriftToPig(com.twitter.elephantbird.pig.util.ThriftToPig)

Aggregations

ThriftMetaData (org.apache.parquet.thrift.ThriftMetaData)2 ThriftToPig (com.twitter.elephantbird.pig.util.ThriftToPig)1 PigMetaData (org.apache.parquet.pig.PigMetaData)1 TBase (org.apache.thrift.TBase)1