Search in sources :

Example 1 with DecimalStreamCheckpoint

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

the class DecimalColumnWriter method getIndexStreams.

@Override
public List<StreamDataOutput> getIndexStreams(CompressedMetadataWriter metadataWriter) throws IOException {
    checkState(closed);
    ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder();
    List<DecimalStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints();
    List<LongStreamCheckpoint> scaleCheckpoints = scaleStream.getCheckpoints();
    Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints();
    for (int i = 0; i < rowGroupColumnStatistics.size(); i++) {
        int groupId = i;
        ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId);
        DecimalStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId);
        LongStreamCheckpoint scaleCheckpoint = scaleCheckpoints.get(groupId);
        Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId));
        List<Integer> positions = createDecimalColumnPositionList(compressed, dataCheckpoint, scaleCheckpoint, 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) DecimalStreamCheckpoint(io.trino.orc.checkpoint.DecimalStreamCheckpoint) BooleanStreamCheckpoint(io.trino.orc.checkpoint.BooleanStreamCheckpoint) LongStreamCheckpoint(io.trino.orc.checkpoint.LongStreamCheckpoint) DecimalStreamCheckpoint(io.trino.orc.checkpoint.DecimalStreamCheckpoint) RowGroupIndex(io.trino.orc.metadata.RowGroupIndex) Slice(io.airlift.slice.Slice) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PresentOutputStream(io.trino.orc.stream.PresentOutputStream) DecimalOutputStream(io.trino.orc.stream.DecimalOutputStream) Stream(io.trino.orc.metadata.Stream) LongOutputStream(io.trino.orc.stream.LongOutputStream)

Example 2 with DecimalStreamCheckpoint

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

the class DecimalInputStream method seekToCheckpoint.

@Override
public void seekToCheckpoint(DecimalStreamCheckpoint checkpoint) throws IOException {
    long newCheckpoint = checkpoint.getInputStreamCheckpoint();
    // buffer, so last checkpoint is no longer valid)
    if (block.length() > 0 && decodeCompressedBlockOffset(newCheckpoint) == decodeCompressedBlockOffset(lastCheckpoint)) {
        // and decompressed position is within our block, reposition in the block directly
        int blockOffset = decodeDecompressedOffset(newCheckpoint) - decodeDecompressedOffset(lastCheckpoint);
        if (blockOffset >= 0 && blockOffset < block.length()) {
            this.blockOffset = blockOffset;
            // do not change last checkpoint because we have not moved positions
            return;
        }
    }
    chunkLoader.seekToCheckpoint(newCheckpoint);
    lastCheckpoint = newCheckpoint;
    block = Slices.EMPTY_SLICE;
    blockOffset = 0;
}
Also used : DecimalStreamCheckpoint(io.trino.orc.checkpoint.DecimalStreamCheckpoint)

Example 3 with DecimalStreamCheckpoint

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

the class DecimalOutputStream method recordCheckpoint.

@Override
public void recordCheckpoint() {
    checkState(!closed);
    checkpoints.add(new DecimalStreamCheckpoint(buffer.getCheckpoint()));
}
Also used : DecimalStreamCheckpoint(io.trino.orc.checkpoint.DecimalStreamCheckpoint)

Aggregations

DecimalStreamCheckpoint (io.trino.orc.checkpoint.DecimalStreamCheckpoint)3 ImmutableList (com.google.common.collect.ImmutableList)1 Slice (io.airlift.slice.Slice)1 BooleanStreamCheckpoint (io.trino.orc.checkpoint.BooleanStreamCheckpoint)1 LongStreamCheckpoint (io.trino.orc.checkpoint.LongStreamCheckpoint)1 RowGroupIndex (io.trino.orc.metadata.RowGroupIndex)1 Stream (io.trino.orc.metadata.Stream)1 ColumnStatistics (io.trino.orc.metadata.statistics.ColumnStatistics)1 DecimalOutputStream (io.trino.orc.stream.DecimalOutputStream)1 LongOutputStream (io.trino.orc.stream.LongOutputStream)1 PresentOutputStream (io.trino.orc.stream.PresentOutputStream)1 StreamDataOutput (io.trino.orc.stream.StreamDataOutput)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1