Search in sources :

Example 1 with ParquetDecodingException

use of parquet.io.ParquetDecodingException in project presto by prestodb.

the class ParquetColumnReader method setPageReader.

public void setPageReader(ParquetPageReader pageReader) {
    this.pageReader = requireNonNull(pageReader, "pageReader");
    ParquetDictionaryPage dictionaryPage = pageReader.readDictionaryPage();
    if (dictionaryPage != null) {
        try {
            dictionary = dictionaryPage.getEncoding().initDictionary(columnDescriptor, dictionaryPage);
        } catch (IOException e) {
            throw new ParquetDecodingException("could not decode the dictionary for " + columnDescriptor, e);
        }
    } else {
        dictionary = null;
    }
    checkArgument(pageReader.getTotalValueCount() > 0, "page is empty");
    totalValueCount = pageReader.getTotalValueCount();
}
Also used : ParquetDecodingException(parquet.io.ParquetDecodingException) ParquetDictionaryPage(com.facebook.presto.hive.parquet.ParquetDictionaryPage) IOException(java.io.IOException)

Example 2 with ParquetDecodingException

use of parquet.io.ParquetDecodingException in project presto by prestodb.

the class ParquetColumnReader method readPageV1.

private ValuesReader readPageV1(ParquetDataPageV1 page) {
    ValuesReader rlReader = page.getRepetitionLevelEncoding().getValuesReader(columnDescriptor, REPETITION_LEVEL);
    ValuesReader dlReader = page.getDefinitionLevelEncoding().getValuesReader(columnDescriptor, DEFINITION_LEVEL);
    repetitionReader = new ParquetLevelValuesReader(rlReader);
    definitionReader = new ParquetLevelValuesReader(dlReader);
    try {
        byte[] bytes = page.getSlice().getBytes();
        rlReader.initFromPage(page.getValueCount(), bytes, 0);
        int offset = rlReader.getNextOffset();
        dlReader.initFromPage(page.getValueCount(), bytes, offset);
        offset = dlReader.getNextOffset();
        return initDataReader(page.getValueEncoding(), bytes, offset, page.getValueCount());
    } catch (IOException e) {
        throw new ParquetDecodingException("Error reading parquet page " + page + " in column " + columnDescriptor, e);
    }
}
Also used : ValuesReader(parquet.column.values.ValuesReader) ParquetDecodingException(parquet.io.ParquetDecodingException) IOException(java.io.IOException)

Example 3 with ParquetDecodingException

use of parquet.io.ParquetDecodingException in project shifu by ShifuML.

the class GuaguaParquetMapReduceClient method getPigSchemaFromMultipleFiles.

/**
 * @param fileSchema
 *            the parquet schema from the file
 * @param keyValueMetaData
 *            the extra meta data from the files
 * @return the pig schema according to the file
 */
static Schema getPigSchemaFromMultipleFiles(MessageType fileSchema, Map<String, Set<String>> keyValueMetaData) {
    Set<String> pigSchemas = PigMetaData.getPigSchemas(keyValueMetaData);
    if (pigSchemas == null) {
        return pigSchemaConverter.convert(fileSchema);
    }
    Schema mergedPigSchema = null;
    for (String pigSchemaString : pigSchemas) {
        try {
            mergedPigSchema = union(mergedPigSchema, parsePigSchema(pigSchemaString));
        } catch (FrontendException e) {
            throw new ParquetDecodingException("can not merge " + pigSchemaString + " into " + mergedPigSchema, e);
        }
    }
    return mergedPigSchema;
}
Also used : ParquetDecodingException(parquet.io.ParquetDecodingException) Schema(org.apache.pig.impl.logicalLayer.schema.Schema) FieldSchema(org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema) FrontendException(org.apache.pig.impl.logicalLayer.FrontendException)

Aggregations

ParquetDecodingException (parquet.io.ParquetDecodingException)3 IOException (java.io.IOException)2 ParquetDictionaryPage (com.facebook.presto.hive.parquet.ParquetDictionaryPage)1 FrontendException (org.apache.pig.impl.logicalLayer.FrontendException)1 Schema (org.apache.pig.impl.logicalLayer.schema.Schema)1 FieldSchema (org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema)1 ValuesReader (parquet.column.values.ValuesReader)1