Search in sources :

Example 6 with LongStreamCheckpoint

use of io.trino.orc.checkpoint.LongStreamCheckpoint in project trino by trinodb.

the class SliceDictionaryColumnWriter method getIndexStreams.

@Override
public List<StreamDataOutput> getIndexStreams(CompressedMetadataWriter metadataWriter) throws IOException {
    checkState(closed);
    if (directEncoded) {
        return directColumnWriter.getIndexStreams(metadataWriter);
    }
    ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder();
    List<LongStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints();
    Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints();
    for (int i = 0; i < rowGroups.size(); i++) {
        int groupId = i;
        ColumnStatistics columnStatistics = rowGroups.get(groupId).getColumnStatistics();
        LongStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId);
        Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId));
        List<Integer> positions = createSliceColumnPositionList(compression != NONE, dataCheckpoint, presentCheckpoint);
        rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics));
    }
    Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build());
    Stream stream = new Stream(columnId, StreamKind.ROW_INDEX, slice.length(), false);
    return ImmutableList.of(new StreamDataOutput(slice, stream));
}
Also used : ColumnStatistics(io.trino.orc.metadata.statistics.ColumnStatistics) BooleanStreamCheckpoint(io.trino.orc.checkpoint.BooleanStreamCheckpoint) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) StreamDataOutput(io.trino.orc.stream.StreamDataOutput) LongStreamCheckpoint(io.trino.orc.checkpoint.LongStreamCheckpoint) BooleanStreamCheckpoint(io.trino.orc.checkpoint.BooleanStreamCheckpoint) LongStreamCheckpoint(io.trino.orc.checkpoint.LongStreamCheckpoint) RowGroupIndex(io.trino.orc.metadata.RowGroupIndex) Slice(io.airlift.slice.Slice) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) PresentOutputStream(io.trino.orc.stream.PresentOutputStream) Stream(io.trino.orc.metadata.Stream) LongOutputStream(io.trino.orc.stream.LongOutputStream) LongOutputStream.createLengthOutputStream(io.trino.orc.stream.LongOutputStream.createLengthOutputStream) ByteArrayOutputStream(io.trino.orc.stream.ByteArrayOutputStream)

Example 7 with LongStreamCheckpoint

use of io.trino.orc.checkpoint.LongStreamCheckpoint in project trino by trinodb.

the class TimestampColumnWriter method getIndexStreams.

@Override
public List<StreamDataOutput> getIndexStreams(CompressedMetadataWriter metadataWriter) throws IOException {
    checkState(closed);
    ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder();
    List<LongStreamCheckpoint> secondsCheckpoints = secondsStream.getCheckpoints();
    List<LongStreamCheckpoint> nanosCheckpoints = nanosStream.getCheckpoints();
    Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints();
    for (int i = 0; i < rowGroupColumnStatistics.size(); i++) {
        int groupId = i;
        ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId);
        LongStreamCheckpoint secondsCheckpoint = secondsCheckpoints.get(groupId);
        LongStreamCheckpoint nanosCheckpoint = nanosCheckpoints.get(groupId);
        Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId));
        List<Integer> positions = createTimestampColumnPositionList(compressed, secondsCheckpoint, nanosCheckpoint, presentCheckpoint);
        rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics));
    }
    Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build());
    Stream stream = new Stream(columnId, StreamKind.ROW_INDEX, slice.length(), false);
    return ImmutableList.of(new StreamDataOutput(slice, stream));
}
Also used : ColumnStatistics(io.trino.orc.metadata.statistics.ColumnStatistics) BooleanStreamCheckpoint(io.trino.orc.checkpoint.BooleanStreamCheckpoint) ImmutableList(com.google.common.collect.ImmutableList) StreamDataOutput(io.trino.orc.stream.StreamDataOutput) LongStreamCheckpoint(io.trino.orc.checkpoint.LongStreamCheckpoint) BooleanStreamCheckpoint(io.trino.orc.checkpoint.BooleanStreamCheckpoint) LongStreamCheckpoint(io.trino.orc.checkpoint.LongStreamCheckpoint) RowGroupIndex(io.trino.orc.metadata.RowGroupIndex) Slice(io.airlift.slice.Slice) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) Stream(io.trino.orc.metadata.Stream) LongOutputStream(io.trino.orc.stream.LongOutputStream) PresentOutputStream(io.trino.orc.stream.PresentOutputStream)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)7 Slice (io.airlift.slice.Slice)7 BooleanStreamCheckpoint (io.trino.orc.checkpoint.BooleanStreamCheckpoint)7 LongStreamCheckpoint (io.trino.orc.checkpoint.LongStreamCheckpoint)7 RowGroupIndex (io.trino.orc.metadata.RowGroupIndex)7 Stream (io.trino.orc.metadata.Stream)7 ColumnStatistics (io.trino.orc.metadata.statistics.ColumnStatistics)7 LongOutputStream (io.trino.orc.stream.LongOutputStream)7 PresentOutputStream (io.trino.orc.stream.PresentOutputStream)7 StreamDataOutput (io.trino.orc.stream.StreamDataOutput)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 LongOutputStream.createLengthOutputStream (io.trino.orc.stream.LongOutputStream.createLengthOutputStream)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 ByteArrayOutputStream (io.trino.orc.stream.ByteArrayOutputStream)2 ByteArrayStreamCheckpoint (io.trino.orc.checkpoint.ByteArrayStreamCheckpoint)1 DecimalStreamCheckpoint (io.trino.orc.checkpoint.DecimalStreamCheckpoint)1 DecimalOutputStream (io.trino.orc.stream.DecimalOutputStream)1 Collectors.toList (java.util.stream.Collectors.toList)1