Search in sources :

Example 1 with FileOrcDataSource

use of io.trino.orc.FileOrcDataSource in project trino by trinodb.

the class RaptorStorageManager method computeShardStats.

private List<ColumnStats> computeShardStats(File file) {
    try (OrcDataSource dataSource = fileOrcDataSource(orcReaderOptions, file)) {
        OrcReader reader = OrcReader.createOrcReader(dataSource, orcReaderOptions).orElseThrow(() -> new TrinoException(RAPTOR_ERROR, "Data file is empty: " + file));
        ImmutableList.Builder<ColumnStats> list = ImmutableList.builder();
        for (ColumnInfo info : getColumnInfo(reader)) {
            computeColumnStats(reader, info.getColumnId(), info.getType(), typeManager).ifPresent(list::add);
        }
        return list.build();
    } catch (IOException e) {
        throw new TrinoException(RAPTOR_ERROR, "Failed to read file: " + file, e);
    }
}
Also used : FileOrcDataSource(io.trino.orc.FileOrcDataSource) OrcDataSource(io.trino.orc.OrcDataSource) OrcReader(io.trino.orc.OrcReader) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) ShardStats.computeColumnStats(io.trino.plugin.raptor.legacy.storage.ShardStats.computeColumnStats) ColumnStats(io.trino.plugin.raptor.legacy.metadata.ColumnStats) TrinoException(io.trino.spi.TrinoException) ColumnInfo(io.trino.plugin.raptor.legacy.metadata.ColumnInfo) IOException(java.io.IOException)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 FileOrcDataSource (io.trino.orc.FileOrcDataSource)1 OrcDataSource (io.trino.orc.OrcDataSource)1 OrcReader (io.trino.orc.OrcReader)1 ColumnInfo (io.trino.plugin.raptor.legacy.metadata.ColumnInfo)1 ColumnStats (io.trino.plugin.raptor.legacy.metadata.ColumnStats)1 ShardStats.computeColumnStats (io.trino.plugin.raptor.legacy.storage.ShardStats.computeColumnStats)1 TrinoException (io.trino.spi.TrinoException)1 IOException (java.io.IOException)1