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());
}
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()));
}
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());
}
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);
}
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()));
}
Aggregations