You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2026/07/05 09:27:55 UTC

(orc) branch branch-2.3 updated: Revert "ORC-2187: Set protobuf message size limit in C++ reader"

This is an automated email from the ASF dual-hosted git repository.

dongjoon-hyun pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-2.3 by this push:
     new a0d9cdf71 Revert "ORC-2187: Set protobuf message size limit in C++ reader"
a0d9cdf71 is described below

commit a0d9cdf71c0878ecd95d733d70fbcf6edb822926
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Sun Jul 5 02:27:45 2026 -0700

    Revert "ORC-2187: Set protobuf message size limit in C++ reader"
    
    This reverts commit c170dead3c19f213d90c87cc3891018a131ec14d.
---
 c++/src/Reader.cc                   | 16 ++++++++--------
 c++/src/StripeStream.cc             |  2 +-
 c++/src/wrap/coded-stream-wrapper.h | 17 -----------------
 3 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
index 91a6716a7..26de69d15 100644
--- a/c++/src/Reader.cc
+++ b/c++/src/Reader.cc
@@ -531,13 +531,13 @@ namespace orc {
 
         if (pbStream.kind() == proto::Stream_Kind_ROW_INDEX) {
           proto::RowIndex rowIndex;
-          if (!parseProtobufFromStream(&rowIndex, inStream.get())) {
+          if (!rowIndex.ParseFromZeroCopyStream(inStream.get())) {
             throw ParseError("Failed to parse the row index");
           }
           rowIndexes_[colId] = rowIndex;
         } else if (!skipBloomFilters_) {  // Stream_Kind_BLOOM_FILTER_UTF8
           proto::BloomFilterIndex pbBFIndex;
-          if (!parseProtobufFromStream(&pbBFIndex, inStream.get())) {
+          if (!pbBFIndex.ParseFromZeroCopyStream(inStream.get())) {
             throw ParseError("Failed to parse bloom filter index");
           }
           BloomFilterIndex bfIndex;
@@ -618,7 +618,7 @@ namespace orc {
                                   *contents.pool, contents.readerMetrics);
 
     proto::StripeFooter result;
-    if (!parseProtobufFromStream(&result, pbStream.get())) {
+    if (!result.ParseFromZeroCopyStream(pbStream.get())) {
       throw ParseError(std::string("bad StripeFooter from ") + pbStream->getName());
     }
     // Verify StripeFooter in case it's corrupt
@@ -814,7 +814,7 @@ namespace orc {
                                contents_->blockSize, *(contents_->pool), contents_->readerMetrics);
 
         proto::RowIndex rowIndex;
-        if (!parseProtobufFromStream(&rowIndex, pbStream.get())) {
+        if (!rowIndex.ParseFromZeroCopyStream(pbStream.get())) {
           throw ParseError("Failed to parse RowIndex from stripe footer");
         }
         int num_entries = rowIndex.entry_size();
@@ -912,7 +912,7 @@ namespace orc {
                                                     metadataSize, *contents_->pool),
           contents_->blockSize, *contents_->pool, contents_->readerMetrics);
       contents_->metadata.reset(new proto::Metadata());
-      if (!parseProtobufFromStream(contents_->metadata.get(), pbStream.get())) {
+      if (!contents_->metadata->ParseFromZeroCopyStream(pbStream.get())) {
         throw ParseError("Failed to parse the metadata");
       }
     }
@@ -1612,7 +1612,7 @@ namespace orc {
         getCompressionBlockSize(ps), memoryPool, readerMetrics);
 
     auto footer = std::make_unique<proto::Footer>();
-    if (!parseProtobufFromStream(footer.get(), pbStream.get())) {
+    if (!footer->ParseFromZeroCopyStream(pbStream.get())) {
       throw ParseError("Failed to parse the footer from " + stream->getName());
     }
 
@@ -1712,7 +1712,7 @@ namespace orc {
                                contents_->blockSize, *(contents_->pool), contents_->readerMetrics);
 
         proto::BloomFilterIndex pbBFIndex;
-        if (!parseProtobufFromStream(&pbBFIndex, pbStream.get())) {
+        if (!pbBFIndex.ParseFromZeroCopyStream(pbStream.get())) {
           throw ParseError("Failed to parse BloomFilterIndex");
         }
 
@@ -1769,7 +1769,7 @@ namespace orc {
                                contents_->blockSize, *(contents_->pool), contents_->readerMetrics);
 
         proto::RowIndex pbRowIndex;
-        if (!parseProtobufFromStream(&pbRowIndex, pbStream.get())) {
+        if (!pbRowIndex.ParseFromZeroCopyStream(pbStream.get())) {
           std::stringstream errMsgBuffer;
           errMsgBuffer << "Failed to parse RowIndex at column " << column << " in stripe "
                        << stripeIndex;
diff --git a/c++/src/StripeStream.cc b/c++/src/StripeStream.cc
index dec0c4a7c..f12a28b2c 100644
--- a/c++/src/StripeStream.cc
+++ b/c++/src/StripeStream.cc
@@ -157,7 +157,7 @@ namespace orc {
                                                     footerLength_, memory_),
           blockSize_, memory_, metrics_);
       stripeFooter_ = std::make_unique<proto::StripeFooter>();
-      if (!parseProtobufFromStream(stripeFooter_.get(), pbStream.get())) {
+      if (!stripeFooter_->ParseFromZeroCopyStream(pbStream.get())) {
         throw ParseError("Failed to parse the stripe footer");
       }
     }
diff --git a/c++/src/wrap/coded-stream-wrapper.h b/c++/src/wrap/coded-stream-wrapper.h
index 6489b0273..1373c1892 100644
--- a/c++/src/wrap/coded-stream-wrapper.h
+++ b/c++/src/wrap/coded-stream-wrapper.h
@@ -37,21 +37,4 @@ DIAGNOSTIC_IGNORE("-Wconversion")
 
 DIAGNOSTIC_POP
 
-namespace orc {
-  // Matches the Java reader's InStream.PROTOBUF_MESSAGE_MAX_LIMIT (1 GB) so both
-  // implementations reject oversized messages identically.
-  constexpr int PROTOBUF_MESSAGE_MAX_LIMIT = 1024 << 20;
-
-  // Parse a protobuf message from a ZeroCopyInputStream while enforcing the
-  // total byte limit above. Use this instead of Message::ParseFromZeroCopyStream
-  // for any message read from file contents.
-  template <typename Message>
-  inline bool parseProtobufFromStream(Message* message,
-                                      google::protobuf::io::ZeroCopyInputStream* input) {
-    google::protobuf::io::CodedInputStream codedStream(input);
-    codedStream.SetTotalBytesLimit(PROTOBUF_MESSAGE_MAX_LIMIT);
-    return message->ParseFromCodedStream(&codedStream);
-  }
-}  // namespace orc
-
 #endif