Search in sources :

Example 6 with DwrfSequenceEncoding

use of com.facebook.presto.orc.metadata.DwrfSequenceEncoding in project presto by prestodb.

the class MapFlatSelectiveStreamReader method startStripe.

@Override
public void startStripe(Stripe stripe) throws IOException {
    presentStreamSource = missingStreamSource(BooleanInputStream.class);
    inMapStreamSources.clear();
    valueStreamDescriptors.clear();
    valueStreamReaders.clear();
    ColumnEncoding encoding = stripe.getColumnEncodings().get(baseValueStreamDescriptor.getStreamId());
    SortedMap<Integer, DwrfSequenceEncoding> additionalSequenceEncodings = Collections.emptySortedMap();
    // encoding or encoding.getAdditionalSequenceEncodings() may not be present when every map is empty or null
    if (encoding != null && encoding.getAdditionalSequenceEncodings().isPresent()) {
        additionalSequenceEncodings = encoding.getAdditionalSequenceEncodings().get();
    }
    keyIndices = ensureCapacity(keyIndices, additionalSequenceEncodings.size());
    keyCount = 0;
    // The ColumnEncoding with sequence ID 0 doesn't have any data associated with it
    int keyIndex = 0;
    for (Map.Entry<Integer, DwrfSequenceEncoding> entry : additionalSequenceEncodings.entrySet()) {
        if (!isRequiredKey(entry.getValue())) {
            keyIndex++;
            continue;
        }
        keyIndices[keyCount] = keyIndex;
        keyCount++;
        keyIndex++;
        int sequence = entry.getKey();
        inMapStreamSources.add(missingStreamSource(BooleanInputStream.class));
        StreamDescriptor valueStreamDescriptor = copyStreamDescriptorWithSequence(baseValueStreamDescriptor, sequence);
        valueStreamDescriptors.add(valueStreamDescriptor);
        SelectiveStreamReader valueStreamReader = SelectiveStreamReaders.createStreamReader(valueStreamDescriptor, ImmutableBiMap.of(), Optional.ofNullable(outputType).map(MapType::getValueType), ImmutableList.of(), hiveStorageTimeZone, options, legacyMapSubscript, systemMemoryContext.newOrcAggregatedMemoryContext());
        valueStreamReader.startStripe(stripe);
        valueStreamReaders.add(valueStreamReader);
    }
    keyBlock = getKeysBlock(ImmutableList.copyOf(additionalSequenceEncodings.values()));
    readOffset = 0;
    presentStream = null;
    rowGroupOpen = false;
}
Also used : ColumnEncoding(com.facebook.presto.orc.metadata.ColumnEncoding) BooleanInputStream(com.facebook.presto.orc.stream.BooleanInputStream) Map(java.util.Map) SortedMap(java.util.SortedMap) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) StreamDescriptor(com.facebook.presto.orc.StreamDescriptor) DwrfSequenceEncoding(com.facebook.presto.orc.metadata.DwrfSequenceEncoding)

Aggregations

DwrfSequenceEncoding (com.facebook.presto.orc.metadata.DwrfSequenceEncoding)6 VariableWidthBlockBuilder (com.facebook.presto.common.block.VariableWidthBlockBuilder)3 ColumnEncoding (com.facebook.presto.orc.metadata.ColumnEncoding)3 Slice (io.airlift.slice.Slice)3 StreamDescriptor (com.facebook.presto.orc.StreamDescriptor)2 OrcType (com.facebook.presto.orc.metadata.OrcType)2 BooleanInputStream (com.facebook.presto.orc.stream.BooleanInputStream)2 Map (java.util.Map)2 SortedMap (java.util.SortedMap)2 RuntimeStats (com.facebook.presto.common.RuntimeStats)1 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 BigintType (com.facebook.presto.common.type.BigintType)1 IntegerType (com.facebook.presto.common.type.IntegerType)1 MapType (com.facebook.presto.common.type.MapType)1 SmallintType (com.facebook.presto.common.type.SmallintType)1 TinyintType (com.facebook.presto.common.type.TinyintType)1 Type (com.facebook.presto.common.type.Type)1 NOOP_ORC_LOCAL_MEMORY_CONTEXT (com.facebook.presto.orc.NoopOrcLocalMemoryContext.NOOP_ORC_LOCAL_MEMORY_CONTEXT)1 Checkpoints.getDictionaryStreamCheckpoint (com.facebook.presto.orc.checkpoint.Checkpoints.getDictionaryStreamCheckpoint)1 Checkpoints.getStreamCheckpoints (com.facebook.presto.orc.checkpoint.Checkpoints.getStreamCheckpoints)1