Search in sources :

Example 1 with CodedInputStream

use of com.facebook.presto.orc.protobuf.CodedInputStream in project presto by prestodb.

the class DwrfMetadataReader method readRowIndexes.

@Override
public List<RowGroupIndex> readRowIndexes(HiveWriterVersion hiveWriterVersion, InputStream inputStream) throws IOException {
    CodedInputStream input = CodedInputStream.newInstance(inputStream);
    DwrfProto.RowIndex rowIndex = DwrfProto.RowIndex.parseFrom(input);
    return ImmutableList.copyOf(Iterables.transform(rowIndex.getEntryList(), rowIndexEntry -> toRowGroupIndex(hiveWriterVersion, rowIndexEntry)));
}
Also used : ORIGINAL(com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion.ORIGINAL) Iterables(com.google.common.collect.Iterables) Slice(io.airlift.slice.Slice) OrcTypeKind(com.facebook.presto.orc.metadata.OrcType.OrcTypeKind) ZLIB(com.facebook.presto.orc.metadata.CompressionKind.ZLIB) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ImmutableList(com.google.common.collect.ImmutableList) HiveWriterVersion(com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion) Slices(io.airlift.slice.Slices) Map(java.util.Map) Math.toIntExact(java.lang.Math.toIntExact) StreamKind(com.facebook.presto.orc.metadata.Stream.StreamKind) OrcMetadataReader.getMinSlice(com.facebook.presto.orc.metadata.OrcMetadataReader.getMinSlice) UNCOMPRESSED(com.facebook.presto.orc.metadata.CompressionKind.UNCOMPRESSED) ImmutableMap(com.google.common.collect.ImmutableMap) ColumnEncodingKind(com.facebook.presto.orc.metadata.ColumnEncoding.ColumnEncodingKind) SNAPPY(com.facebook.presto.orc.metadata.CompressionKind.SNAPPY) IOException(java.io.IOException) OrcMetadataReader.getMaxSlice(com.facebook.presto.orc.metadata.OrcMetadataReader.getMaxSlice) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) Optional(java.util.Optional) DwrfProto(com.facebook.presto.orc.proto.DwrfProto) InputStream(java.io.InputStream) CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) DwrfProto(com.facebook.presto.orc.proto.DwrfProto)

Example 2 with CodedInputStream

use of com.facebook.presto.orc.protobuf.CodedInputStream in project presto by prestodb.

the class OrcMetadataReader method readFooter.

@Override
public Footer readFooter(HiveWriterVersion hiveWriterVersion, InputStream inputStream) throws IOException {
    CodedInputStream input = CodedInputStream.newInstance(inputStream);
    input.setSizeLimit(PROTOBUF_MESSAGE_MAX_LIMIT);
    OrcProto.Footer footer = OrcProto.Footer.parseFrom(input);
    return new Footer(footer.getNumberOfRows(), footer.getRowIndexStride(), toStripeInformation(footer.getStripesList()), toType(footer.getTypesList()), toColumnStatistics(hiveWriterVersion, footer.getStatisticsList(), false), toUserMetadata(footer.getMetadataList()));
}
Also used : CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) OrcProto(com.facebook.presto.orc.proto.OrcProto)

Example 3 with CodedInputStream

use of com.facebook.presto.orc.protobuf.CodedInputStream in project presto by prestodb.

the class OrcMetadataReader method readBloomFilterIndexes.

@Override
public List<HiveBloomFilter> readBloomFilterIndexes(InputStream inputStream) throws IOException {
    CodedInputStream input = CodedInputStream.newInstance(inputStream);
    OrcProto.BloomFilterIndex bloomFilter = OrcProto.BloomFilterIndex.parseFrom(input);
    List<OrcProto.BloomFilter> bloomFilterList = bloomFilter.getBloomFilterList();
    ImmutableList.Builder<HiveBloomFilter> builder = ImmutableList.builder();
    for (OrcProto.BloomFilter orcBloomFilter : bloomFilterList) {
        builder.add(new HiveBloomFilter(orcBloomFilter.getBitsetList(), orcBloomFilter.getBitsetCount() * 64, orcBloomFilter.getNumHashFunctions()));
    }
    return builder.build();
}
Also used : HiveBloomFilter(com.facebook.presto.orc.metadata.statistics.HiveBloomFilter) CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) OrcProto(com.facebook.presto.orc.proto.OrcProto) HiveBloomFilter(com.facebook.presto.orc.metadata.statistics.HiveBloomFilter)

Example 4 with CodedInputStream

use of com.facebook.presto.orc.protobuf.CodedInputStream in project presto by prestodb.

the class OrcMetadataReader method readFooter.

@Override
public Footer readFooter(HiveWriterVersion hiveWriterVersion, InputStream inputStream, DwrfEncryptionProvider dwrfEncryptionProvider, DwrfKeyProvider dwrfKeyProvider, OrcDataSource orcDataSource, Optional<OrcDecompressor> decompressor) throws IOException {
    long cpuStart = THREAD_MX_BEAN.getCurrentThreadCpuTime();
    CodedInputStream input = CodedInputStream.newInstance(inputStream);
    input.setSizeLimit(PROTOBUF_MESSAGE_MAX_LIMIT);
    OrcProto.Footer footer = OrcProto.Footer.parseFrom(input);
    runtimeStats.addMetricValue("OrcReadFooterTimeNanos", THREAD_MX_BEAN.getCurrentThreadCpuTime() - cpuStart);
    return new Footer(footer.getNumberOfRows(), footer.getRowIndexStride(), OptionalLong.empty(), toStripeInformation(footer.getStripesList()), toType(footer.getTypesList()), toColumnStatistics(hiveWriterVersion, footer.getStatisticsList(), false), toUserMetadata(footer.getMetadataList()), Optional.empty(), Optional.empty());
}
Also used : CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) OrcProto(com.facebook.presto.orc.proto.OrcProto)

Example 5 with CodedInputStream

use of com.facebook.presto.orc.protobuf.CodedInputStream in project presto by prestodb.

the class DwrfMetadataReader method readRowIndexes.

@Override
public List<RowGroupIndex> readRowIndexes(HiveWriterVersion hiveWriterVersion, InputStream inputStream, List<HiveBloomFilter> bloomFilters) throws IOException {
    long cpuStart = THREAD_MX_BEAN.getCurrentThreadCpuTime();
    CodedInputStream input = CodedInputStream.newInstance(inputStream);
    DwrfProto.RowIndex rowIndex = DwrfProto.RowIndex.parseFrom(input);
    runtimeStats.addMetricValue("DwrfReadRowIndexesTimeNanos", THREAD_MX_BEAN.getCurrentThreadCpuTime() - cpuStart);
    return IntStream.range(0, rowIndex.getEntryCount()).mapToObj(i -> toRowGroupIndex(hiveWriterVersion, rowIndex.getEntry(i), bloomFilters == null || bloomFilters.isEmpty() ? null : bloomFilters.get(i))).collect(toImmutableList());
}
Also used : ORIGINAL(com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion.ORIGINAL) ThreadMXBean(com.sun.management.ThreadMXBean) DoubleStatistics(com.facebook.presto.orc.metadata.statistics.DoubleStatistics) OrcTypeKind(com.facebook.presto.orc.metadata.OrcType.OrcTypeKind) BinaryStatistics(com.facebook.presto.orc.metadata.statistics.BinaryStatistics) EncryptionLibrary(com.facebook.presto.orc.EncryptionLibrary) Map(java.util.Map) RuntimeStats(com.facebook.presto.common.RuntimeStats) OrcDataSource(com.facebook.presto.orc.OrcDataSource) StreamKind(com.facebook.presto.orc.metadata.Stream.StreamKind) OrcMetadataReader.byteStringToSlice(com.facebook.presto.orc.metadata.OrcMetadataReader.byteStringToSlice) STATIC_METADATA(com.facebook.presto.orc.metadata.DwrfMetadataWriter.STATIC_METADATA) ImmutableMap(com.google.common.collect.ImmutableMap) NONE(com.facebook.presto.orc.metadata.CompressionKind.NONE) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ColumnStatistics.createColumnStatistics(com.facebook.presto.orc.metadata.statistics.ColumnStatistics.createColumnStatistics) NOOP_ORC_AGGREGATED_MEMORY_CONTEXT(com.facebook.presto.orc.NoopOrcAggregatedMemoryContext.NOOP_ORC_AGGREGATED_MEMORY_CONTEXT) ColumnStatistics(com.facebook.presto.orc.metadata.statistics.ColumnStatistics) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) BooleanStatistics(com.facebook.presto.orc.metadata.statistics.BooleanStatistics) CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) Optional(java.util.Optional) OrcInputStream(com.facebook.presto.orc.stream.OrcInputStream) SortedMap(java.util.SortedMap) IntStream(java.util.stream.IntStream) DwrfDataEncryptor(com.facebook.presto.orc.DwrfDataEncryptor) Iterables(com.google.common.collect.Iterables) Slice(io.airlift.slice.Slice) DwrfKeyProvider(com.facebook.presto.orc.DwrfKeyProvider) HashMap(java.util.HashMap) StringStatistics(com.facebook.presto.orc.metadata.statistics.StringStatistics) OptionalInt(java.util.OptionalInt) ArrayList(java.util.ArrayList) OptionalLong(java.util.OptionalLong) ZLIB(com.facebook.presto.orc.metadata.CompressionKind.ZLIB) ImmutableList(com.google.common.collect.ImmutableList) HiveBloomFilter(com.facebook.presto.orc.metadata.statistics.HiveBloomFilter) HiveWriterVersion(com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion) Objects.requireNonNull(java.util.Objects.requireNonNull) OrcMetadataReader.minStringTruncateToValidRange(com.facebook.presto.orc.metadata.OrcMetadataReader.minStringTruncateToValidRange) ManagementFactory(java.lang.management.ManagementFactory) Math.toIntExact(java.lang.Math.toIntExact) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) DwrfEncryptionProvider(com.facebook.presto.orc.DwrfEncryptionProvider) OrcDataSourceId(com.facebook.presto.orc.OrcDataSourceId) OrcDecompressor(com.facebook.presto.orc.OrcDecompressor) NOOP_ORC_LOCAL_MEMORY_CONTEXT(com.facebook.presto.orc.NoopOrcLocalMemoryContext.NOOP_ORC_LOCAL_MEMORY_CONTEXT) ORC_HIVE_8732(com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion.ORC_HIVE_8732) SharedBuffer(com.facebook.presto.orc.stream.SharedBuffer) ColumnEncodingKind(com.facebook.presto.orc.metadata.ColumnEncoding.ColumnEncodingKind) OrcCorruptionException(com.facebook.presto.orc.OrcCorruptionException) SNAPPY(com.facebook.presto.orc.metadata.CompressionKind.SNAPPY) OrcMetadataReader.maxStringTruncateToValidRange(com.facebook.presto.orc.metadata.OrcMetadataReader.maxStringTruncateToValidRange) IOException(java.io.IOException) BasicSliceInput(io.airlift.slice.BasicSliceInput) IntegerStatistics(com.facebook.presto.orc.metadata.statistics.IntegerStatistics) LZ4(com.facebook.presto.orc.metadata.CompressionKind.LZ4) ByteString(com.facebook.presto.orc.protobuf.ByteString) DwrfProto(com.facebook.presto.orc.proto.DwrfProto) VisibleForTesting(com.google.common.annotations.VisibleForTesting) InputStream(java.io.InputStream) ZSTD(com.facebook.presto.orc.metadata.CompressionKind.ZSTD) CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) DwrfProto(com.facebook.presto.orc.proto.DwrfProto)

Aggregations

CodedInputStream (com.facebook.presto.orc.protobuf.CodedInputStream)20 DwrfProto (com.facebook.presto.orc.proto.DwrfProto)10 OrcProto (com.facebook.presto.orc.proto.OrcProto)10 InputStream (java.io.InputStream)7 ImmutableList (com.google.common.collect.ImmutableList)6 Slice (io.airlift.slice.Slice)6 IOException (java.io.IOException)6 HiveWriterVersion (com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion)5 List (java.util.List)5 ColumnEncodingKind (com.facebook.presto.orc.metadata.ColumnEncoding.ColumnEncodingKind)4 SNAPPY (com.facebook.presto.orc.metadata.CompressionKind.SNAPPY)4 ZLIB (com.facebook.presto.orc.metadata.CompressionKind.ZLIB)4 OrcTypeKind (com.facebook.presto.orc.metadata.OrcType.OrcTypeKind)4 ORIGINAL (com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion.ORIGINAL)4 StreamKind (com.facebook.presto.orc.metadata.Stream.StreamKind)4 HiveBloomFilter (com.facebook.presto.orc.metadata.statistics.HiveBloomFilter)4 OrcInputStream (com.facebook.presto.orc.stream.OrcInputStream)4 Preconditions.checkState (com.google.common.base.Preconditions.checkState)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 Math.toIntExact (java.lang.Math.toIntExact)4