Search in sources :

Example 16 with CodedInputStream

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

the class OrcMetadataReader method readPostScript.

@Override
public PostScript readPostScript(byte[] data, int offset, int length) throws IOException {
    long cpuStart = THREAD_MX_BEAN.getCurrentThreadCpuTime();
    CodedInputStream input = CodedInputStream.newInstance(data, offset, length);
    OrcProto.PostScript postScript = OrcProto.PostScript.parseFrom(input);
    runtimeStats.addMetricValue("OrcReadPostScriptTimeNanos", THREAD_MX_BEAN.getCurrentThreadCpuTime() - cpuStart);
    return new PostScript(postScript.getVersionList(), postScript.getFooterLength(), postScript.getMetadataLength(), toCompression(postScript.getCompression()), postScript.getCompressionBlockSize(), toHiveWriterVersion(postScript.getWriterVersion()), OptionalInt.empty(), Optional.empty());
}
Also used : CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) OrcProto(com.facebook.presto.orc.proto.OrcProto)

Example 17 with CodedInputStream

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

the class OrcMetadataReader method readMetadata.

@Override
public Metadata readMetadata(HiveWriterVersion hiveWriterVersion, InputStream inputStream) throws IOException {
    long cpuStart = THREAD_MX_BEAN.getCurrentThreadCpuTime();
    CodedInputStream input = CodedInputStream.newInstance(inputStream);
    input.setSizeLimit(PROTOBUF_MESSAGE_MAX_LIMIT);
    OrcProto.Metadata metadata = OrcProto.Metadata.parseFrom(input);
    runtimeStats.addMetricValue("OrcReadMetadataTimeNanos", THREAD_MX_BEAN.getCurrentThreadCpuTime() - cpuStart);
    return new Metadata(toStripeStatistics(hiveWriterVersion, metadata.getStripeStatsList()));
}
Also used : CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) OrcProto(com.facebook.presto.orc.proto.OrcProto)

Example 18 with CodedInputStream

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

the class OrcMetadataReader 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);
    OrcProto.RowIndex rowIndex = OrcProto.RowIndex.parseFrom(input);
    runtimeStats.addMetricValue("OrcReadRowIndexesTimeNanos", 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) BigDecimal(java.math.BigDecimal) Slices(io.airlift.slice.Slices) Map(java.util.Map) SliceUtf8.tryGetCodePointAt(io.airlift.slice.SliceUtf8.tryGetCodePointAt) RuntimeStats(com.facebook.presto.common.RuntimeStats) OrcDataSource(com.facebook.presto.orc.OrcDataSource) StreamKind(com.facebook.presto.orc.metadata.Stream.StreamKind) ImmutableMap(com.google.common.collect.ImmutableMap) NONE(com.facebook.presto.orc.metadata.CompressionKind.NONE) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) RowIndexEntry(com.facebook.presto.orc.proto.OrcProto.RowIndexEntry) ColumnStatistics.createColumnStatistics(com.facebook.presto.orc.metadata.statistics.ColumnStatistics.createColumnStatistics) ColumnStatistics(com.facebook.presto.orc.metadata.statistics.ColumnStatistics) Preconditions.checkState(com.google.common.base.Preconditions.checkState) DataSize(io.airlift.units.DataSize) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) SHORT_DECIMAL_VALUE_BYTES(com.facebook.presto.orc.metadata.statistics.ShortDecimalStatisticsBuilder.SHORT_DECIMAL_VALUE_BYTES) BooleanStatistics(com.facebook.presto.orc.metadata.statistics.BooleanStatistics) CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) DecimalStatistics(com.facebook.presto.orc.metadata.statistics.DecimalStatistics) Optional(java.util.Optional) MIN_SUPPLEMENTARY_CODE_POINT(java.lang.Character.MIN_SUPPLEMENTARY_CODE_POINT) IntStream(java.util.stream.IntStream) Slice(io.airlift.slice.Slice) DwrfKeyProvider(com.facebook.presto.orc.DwrfKeyProvider) StringStatistics(com.facebook.presto.orc.metadata.statistics.StringStatistics) OptionalInt(java.util.OptionalInt) DateStatistics(com.facebook.presto.orc.metadata.statistics.DateStatistics) OptionalLong(java.util.OptionalLong) ZLIB(com.facebook.presto.orc.metadata.CompressionKind.ZLIB) GIGABYTE(io.airlift.units.DataSize.Unit.GIGABYTE) 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) ManagementFactory(java.lang.management.ManagementFactory) Math.toIntExact(java.lang.Math.toIntExact) DwrfEncryptionProvider(com.facebook.presto.orc.DwrfEncryptionProvider) OrcDataSourceId(com.facebook.presto.orc.OrcDataSourceId) OrcDecompressor(com.facebook.presto.orc.OrcDecompressor) SliceUtf8.lengthOfCodePoint(io.airlift.slice.SliceUtf8.lengthOfCodePoint) ORC_HIVE_8732(com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion.ORC_HIVE_8732) ColumnEncodingKind(com.facebook.presto.orc.metadata.ColumnEncoding.ColumnEncodingKind) StripeStatistics(com.facebook.presto.orc.metadata.statistics.StripeStatistics) SNAPPY(com.facebook.presto.orc.metadata.CompressionKind.SNAPPY) IOException(java.io.IOException) OrcProto(com.facebook.presto.orc.proto.OrcProto) IntegerStatistics(com.facebook.presto.orc.metadata.statistics.IntegerStatistics) LZ4(com.facebook.presto.orc.metadata.CompressionKind.LZ4) ByteString(com.facebook.presto.orc.protobuf.ByteString) 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) OrcProto(com.facebook.presto.orc.proto.OrcProto)

Example 19 with CodedInputStream

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

the class DwrfMetadataReader method readPostScript.

@Override
public PostScript readPostScript(byte[] data, int offset, int length) throws IOException {
    long cpuStart = THREAD_MX_BEAN.getCurrentThreadCpuTime();
    CodedInputStream input = CodedInputStream.newInstance(data, offset, length);
    DwrfProto.PostScript postScript = DwrfProto.PostScript.parseFrom(input);
    HiveWriterVersion writerVersion = postScript.hasWriterVersion() && postScript.getWriterVersion() > 0 ? ORC_HIVE_8732 : ORIGINAL;
    OptionalInt stripeCacheLength = OptionalInt.empty();
    Optional<DwrfStripeCacheMode> stripeCacheMode = Optional.empty();
    if (postScript.hasCacheSize() && postScript.hasCacheMode()) {
        stripeCacheLength = OptionalInt.of(postScript.getCacheSize());
        stripeCacheMode = Optional.of(toStripeCacheMode(postScript.getCacheMode()));
    }
    runtimeStats.addMetricValue("DwrfReadPostScriptTimeNanos", THREAD_MX_BEAN.getCurrentThreadCpuTime() - cpuStart);
    return new PostScript(ImmutableList.of(), postScript.getFooterLength(), 0, toCompression(postScript.getCompression()), postScript.getCompressionBlockSize(), writerVersion, stripeCacheLength, stripeCacheMode);
}
Also used : CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) DwrfProto(com.facebook.presto.orc.proto.DwrfProto) OptionalInt(java.util.OptionalInt) HiveWriterVersion(com.facebook.presto.orc.metadata.PostScript.HiveWriterVersion)

Example 20 with CodedInputStream

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

the class DwrfMetadataReader method toStripeEncryptionGroup.

public static StripeEncryptionGroup toStripeEncryptionGroup(OrcDataSourceId orcDataSourceId, InputStream inputStream, List<OrcType> types) throws IOException {
    CodedInputStream codedInputStream = CodedInputStream.newInstance(inputStream);
    DwrfProto.StripeEncryptionGroup stripeEncryptionGroup = DwrfProto.StripeEncryptionGroup.parseFrom(codedInputStream);
    List<Stream> encryptedStreams = toStream(orcDataSourceId, stripeEncryptionGroup.getStreamsList());
    return new StripeEncryptionGroup(encryptedStreams, toColumnEncoding(types, stripeEncryptionGroup.getEncodingList()));
}
Also used : CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) CodedInputStream(com.facebook.presto.orc.protobuf.CodedInputStream) OrcInputStream(com.facebook.presto.orc.stream.OrcInputStream) IntStream(java.util.stream.IntStream) InputStream(java.io.InputStream) 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