Search in sources :

Example 1 with StreamCheckpoint

use of com.facebook.presto.orc.checkpoint.StreamCheckpoint in project presto by prestodb.

the class StripeReader method createDictionaryStreamSources.

public StreamSources createDictionaryStreamSources(Map<StreamId, Stream> streams, Map<StreamId, ValueStream<?>> valueStreams, List<ColumnEncoding> columnEncodings) {
    ImmutableMap.Builder<StreamId, StreamSource<?>> dictionaryStreamBuilder = ImmutableMap.builder();
    for (Entry<StreamId, Stream> entry : streams.entrySet()) {
        StreamId streamId = entry.getKey();
        Stream stream = entry.getValue();
        int column = stream.getColumn();
        // only process dictionary streams
        ColumnEncodingKind columnEncoding = columnEncodings.get(column).getColumnEncodingKind();
        if (!isDictionary(stream, columnEncoding)) {
            continue;
        }
        // skip streams without data
        ValueStream<?> valueStream = valueStreams.get(streamId);
        if (valueStream == null) {
            continue;
        }
        OrcTypeKind columnType = types.get(stream.getColumn()).getOrcTypeKind();
        StreamCheckpoint streamCheckpoint = getDictionaryStreamCheckpoint(streamId, columnType, columnEncoding);
        StreamSource<?> streamSource = createCheckpointStreamSource(valueStream, streamCheckpoint);
        dictionaryStreamBuilder.put(streamId, streamSource);
    }
    return new StreamSources(dictionaryStreamBuilder.build());
}
Also used : StreamSource(com.facebook.presto.orc.stream.StreamSource) CheckpointStreamSource.createCheckpointStreamSource(com.facebook.presto.orc.stream.CheckpointStreamSource.createCheckpointStreamSource) ValueStreamSource(com.facebook.presto.orc.stream.ValueStreamSource) OrcTypeKind(com.facebook.presto.orc.metadata.OrcType.OrcTypeKind) ImmutableMap(com.google.common.collect.ImmutableMap) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint) StreamSources(com.facebook.presto.orc.stream.StreamSources) ValueStream(com.facebook.presto.orc.stream.ValueStream) OrcInputStream(com.facebook.presto.orc.stream.OrcInputStream) Stream(com.facebook.presto.orc.metadata.Stream) InputStream(java.io.InputStream) ColumnEncodingKind(com.facebook.presto.orc.metadata.ColumnEncoding.ColumnEncodingKind) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint)

Example 2 with StreamCheckpoint

use of com.facebook.presto.orc.checkpoint.StreamCheckpoint in project presto by prestodb.

the class StripeReader method createRowGroups.

private List<RowGroup> createRowGroups(int rowsInStripe, Map<StreamId, Stream> streams, Map<StreamId, ValueStream<?>> valueStreams, Map<Integer, List<RowGroupIndex>> columnIndexes, Set<Integer> selectedRowGroups, List<ColumnEncoding> encodings) throws InvalidCheckpointException {
    ImmutableList.Builder<RowGroup> rowGroupBuilder = ImmutableList.builder();
    for (int rowGroupId : selectedRowGroups) {
        Map<StreamId, StreamCheckpoint> checkpoints = getStreamCheckpoints(includedOrcColumns, types, compressionKind, rowGroupId, encodings, streams, columnIndexes);
        int rowOffset = rowGroupId * rowsInRowGroup;
        int rowsInGroup = Math.min(rowsInStripe - rowOffset, rowsInRowGroup);
        rowGroupBuilder.add(createRowGroup(rowGroupId, rowOffset, rowsInGroup, valueStreams, checkpoints));
    }
    return rowGroupBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint)

Example 3 with StreamCheckpoint

use of com.facebook.presto.orc.checkpoint.StreamCheckpoint in project presto by prestodb.

the class TestLongDictionaryProvider method createLongDictionaryStreamSources.

private InputStreamSources createLongDictionaryStreamSources(Map<NodeId, long[]> streams, OrcAggregatedMemoryContext aggregatedMemoryContext) {
    SharedBuffer decompressionBuffer = new SharedBuffer(aggregatedMemoryContext.newOrcLocalMemoryContext("sharedDecompressionBuffer"));
    ImmutableMap.Builder<StreamId, InputStreamSource<?>> dictionaryStreamsBuilder = ImmutableMap.builder();
    for (Map.Entry<NodeId, long[]> entry : streams.entrySet()) {
        StreamId streamId = entry.getKey().toDictionaryDataStreamId();
        DynamicSliceOutput sliceOutput = createSliceOutput(streamId, entry.getValue());
        ValueInputStream<?> valueStream = createValueStream(sliceOutput.slice(), aggregatedMemoryContext, decompressionBuffer);
        StreamCheckpoint streamCheckpoint = getDictionaryStreamCheckpoint(streamId, LONG, ColumnEncoding.ColumnEncodingKind.DICTIONARY);
        InputStreamSource<?> streamSource = createCheckpointStreamSource(valueStream, streamCheckpoint);
        dictionaryStreamsBuilder.put(streamId, streamSource);
    }
    return new InputStreamSources(dictionaryStreamsBuilder.build());
}
Also used : ImmutableMap(com.google.common.collect.ImmutableMap) SharedBuffer(com.facebook.presto.orc.stream.SharedBuffer) InputStreamSource(com.facebook.presto.orc.stream.InputStreamSource) InputStreamSources(com.facebook.presto.orc.stream.InputStreamSources) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint)

Example 4 with StreamCheckpoint

use of com.facebook.presto.orc.checkpoint.StreamCheckpoint in project presto by prestodb.

the class StripeReader method createRowGroups.

private List<RowGroup> createRowGroups(long rowsInStripe, Map<StreamId, Stream> streams, Map<StreamId, ValueInputStream<?>> valueStreams, Map<StreamId, List<RowGroupIndex>> columnIndexes, Set<Integer> selectedRowGroups, Map<Integer, ColumnEncoding> encodings) throws InvalidCheckpointException {
    ImmutableList.Builder<RowGroup> rowGroupBuilder = ImmutableList.builder();
    for (int rowGroupId : selectedRowGroups) {
        Map<StreamId, StreamCheckpoint> checkpoints = getStreamCheckpoints(includedOrcColumns, types, decompressor.isPresent(), rowGroupId, encodings, streams, columnIndexes);
        rowGroupBuilder.add(createRowGroup(rowGroupId, rowsInStripe, rowsInRowGroup, columnIndexes, valueStreams, checkpoints));
    }
    return rowGroupBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint)

Example 5 with StreamCheckpoint

use of com.facebook.presto.orc.checkpoint.StreamCheckpoint in project presto by prestodb.

the class StripeReader method createRowGroup.

public static RowGroup createRowGroup(int groupId, int rowOffset, int rowCount, Map<StreamId, ValueStream<?>> valueStreams, Map<StreamId, StreamCheckpoint> checkpoints) {
    ImmutableMap.Builder<StreamId, StreamSource<?>> builder = ImmutableMap.builder();
    for (Entry<StreamId, StreamCheckpoint> entry : checkpoints.entrySet()) {
        StreamId streamId = entry.getKey();
        StreamCheckpoint checkpoint = entry.getValue();
        // skip streams without data
        ValueStream<?> valueStream = valueStreams.get(streamId);
        if (valueStream == null) {
            continue;
        }
        builder.put(streamId, createCheckpointStreamSource(valueStream, checkpoint));
    }
    StreamSources rowGroupStreams = new StreamSources(builder.build());
    return new RowGroup(groupId, rowOffset, rowCount, rowGroupStreams);
}
Also used : StreamSources(com.facebook.presto.orc.stream.StreamSources) StreamSource(com.facebook.presto.orc.stream.StreamSource) CheckpointStreamSource.createCheckpointStreamSource(com.facebook.presto.orc.stream.CheckpointStreamSource.createCheckpointStreamSource) ValueStreamSource(com.facebook.presto.orc.stream.ValueStreamSource) ImmutableMap(com.google.common.collect.ImmutableMap) Checkpoints.getDictionaryStreamCheckpoint(com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint) StreamCheckpoint(com.facebook.presto.orc.checkpoint.StreamCheckpoint)

Aggregations

Checkpoints.getDictionaryStreamCheckpoint (com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint)7 StreamCheckpoint (com.facebook.presto.orc.checkpoint.StreamCheckpoint)7 ImmutableMap (com.google.common.collect.ImmutableMap)5 ColumnEncodingKind (com.facebook.presto.orc.metadata.ColumnEncoding.ColumnEncodingKind)3 OrcTypeKind (com.facebook.presto.orc.metadata.OrcType.OrcTypeKind)3 Stream (com.facebook.presto.orc.metadata.Stream)3 InputStreamSource (com.facebook.presto.orc.stream.InputStreamSource)3 InputStreamSources (com.facebook.presto.orc.stream.InputStreamSources)3 OrcInputStream (com.facebook.presto.orc.stream.OrcInputStream)3 InputStream (java.io.InputStream)3 CheckpointStreamSource.createCheckpointStreamSource (com.facebook.presto.orc.stream.CheckpointStreamSource.createCheckpointStreamSource)2 ValueInputStream (com.facebook.presto.orc.stream.ValueInputStream)2 ValueInputStreamSource (com.facebook.presto.orc.stream.ValueInputStreamSource)2 ImmutableList (com.google.common.collect.ImmutableList)2 RuntimeStats (com.facebook.presto.common.RuntimeStats)1 NOOP_ORC_LOCAL_MEMORY_CONTEXT (com.facebook.presto.orc.NoopOrcLocalMemoryContext.NOOP_ORC_LOCAL_MEMORY_CONTEXT)1 Checkpoints.getStreamCheckpoints (com.facebook.presto.orc.checkpoint.Checkpoints.getStreamCheckpoints)1 InvalidCheckpointException (com.facebook.presto.orc.checkpoint.InvalidCheckpointException)1 ColumnEncoding (com.facebook.presto.orc.metadata.ColumnEncoding)1 DICTIONARY (com.facebook.presto.orc.metadata.ColumnEncoding.ColumnEncodingKind.DICTIONARY)1