Search in sources :

Example 1 with WriteChecksum

use of io.trino.orc.OrcWriteValidation.WriteChecksum in project trino by trinodb.

the class OrcRecordReader method close.

@Override
public void close() throws IOException {
    try (Closer closer = Closer.create()) {
        closer.register(orcDataSource);
        for (ColumnReader column : columnReaders) {
            if (column != null) {
                closer.register(column::close);
            }
        }
    }
    if (writeChecksumBuilder.isPresent()) {
        WriteChecksum actualChecksum = writeChecksumBuilder.get().build();
        validateWrite(validation -> validation.getChecksum().getTotalRowCount() == actualChecksum.getTotalRowCount(), "Invalid row count");
        List<Long> columnHashes = actualChecksum.getColumnHashes();
        for (int i = 0; i < columnHashes.size(); i++) {
            int columnIndex = i;
            validateWrite(validation -> validation.getChecksum().getColumnHashes().get(columnIndex).equals(columnHashes.get(columnIndex)), "Invalid checksum for column %s", columnIndex);
        }
        validateWrite(validation -> validation.getChecksum().getStripeHash() == actualChecksum.getStripeHash(), "Invalid stripes checksum");
    }
    if (fileStatisticsValidation.isPresent()) {
        Optional<ColumnMetadata<ColumnStatistics>> columnStatistics = fileStatisticsValidation.get().build();
        writeValidation.get().validateFileStatistics(orcDataSource.getId(), columnStatistics);
    }
}
Also used : Closer(com.google.common.io.Closer) ColumnMetadata(io.trino.orc.metadata.ColumnMetadata) Comparator.comparingLong(java.util.Comparator.comparingLong) ColumnReader(io.trino.orc.reader.ColumnReader) ColumnReaders.createColumnReader(io.trino.orc.reader.ColumnReaders.createColumnReader) WriteChecksum(io.trino.orc.OrcWriteValidation.WriteChecksum)

Aggregations

Closer (com.google.common.io.Closer)1 WriteChecksum (io.trino.orc.OrcWriteValidation.WriteChecksum)1 ColumnMetadata (io.trino.orc.metadata.ColumnMetadata)1 ColumnReader (io.trino.orc.reader.ColumnReader)1 ColumnReaders.createColumnReader (io.trino.orc.reader.ColumnReaders.createColumnReader)1 Comparator.comparingLong (java.util.Comparator.comparingLong)1