use of com.facebook.presto.hive.parquet.RichColumnDescriptor in project presto by prestodb.
the class ParquetReader method initializeColumnReaders.
private void initializeColumnReaders() {
for (PrimitiveColumnIO columnIO : getColumns(fileSchema, requestedSchema)) {
ColumnDescriptor descriptor = columnIO.getColumnDescriptor();
RichColumnDescriptor column = new RichColumnDescriptor(descriptor.getPath(), columnIO.getType().asPrimitiveType(), descriptor.getMaxRepetitionLevel(), descriptor.getMaxDefinitionLevel());
columnReadersMap.put(column, ParquetColumnReader.createReader(column));
}
}
use of com.facebook.presto.hive.parquet.RichColumnDescriptor in project presto by prestodb.
the class ParquetReader method readBlock.
private Block readBlock(String name, Type type, List<String> path, IntList offsets) throws IOException {
path.add(name);
Optional<RichColumnDescriptor> descriptor = getDescriptor(fileSchema, requestedSchema, path);
if (!descriptor.isPresent()) {
path.remove(name);
return RunLengthEncodedBlock.create(type, null, batchSize);
}
Block block;
if (ROW.equals(type.getTypeSignature().getBase())) {
block = readStruct(type, path, offsets);
} else if (MAP.equals(type.getTypeSignature().getBase())) {
block = readMap(type, path, offsets);
} else if (ARRAY.equals(type.getTypeSignature().getBase())) {
block = readArray(type, path, offsets);
} else {
block = readPrimitive(descriptor.get(), type, offsets);
}
path.remove(name);
return block;
}
use of com.facebook.presto.hive.parquet.RichColumnDescriptor in project presto by prestodb.
the class ParquetReader method nextBatch.
public int nextBatch() {
if (nextRowInGroup >= currentGroupRowCount && !advanceToNextRowGroup()) {
return -1;
}
batchSize = toIntExact(min(MAX_VECTOR_LENGTH, currentGroupRowCount - nextRowInGroup));
nextRowInGroup += batchSize;
currentPosition += batchSize;
for (PrimitiveColumnIO columnIO : getColumns(fileSchema, requestedSchema)) {
ColumnDescriptor descriptor = columnIO.getColumnDescriptor();
RichColumnDescriptor column = new RichColumnDescriptor(descriptor.getPath(), columnIO.getType().asPrimitiveType(), descriptor.getMaxRepetitionLevel(), descriptor.getMaxDefinitionLevel());
ParquetColumnReader columnReader = columnReadersMap.get(column);
columnReader.prepareNextRead(batchSize);
}
return batchSize;
}
Aggregations