You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@parquet.apache.org by we...@apache.org on 2018/02/21 02:41:13 UTC

[parquet-cpp] branch master updated: PARQUET-1218: More informative error message on too short pages

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

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-cpp.git


The following commit(s) were added to refs/heads/master by this push:
     new 741012f  PARQUET-1218: More informative error message on too short pages
741012f is described below

commit 741012f64ee668d63583ba883d78158f3b8a5101
Author: Uwe L. Korn <uw...@xhochy.com>
AuthorDate: Tue Feb 20 21:41:09 2018 -0500

    PARQUET-1218: More informative error message on too short pages
    
    Author: Uwe L. Korn <uw...@xhochy.com>
    
    Closes #438 from xhochy/PARQUET-1218 and squashes the following commits:
    
    20ba13d [Uwe L. Korn] PARQUET-1218: More informative error message on too short pages
---
 src/parquet/column_reader.cc | 5 ++++-
 src/parquet/exception.cc     | 9 +++++++--
 src/parquet/exception.h      | 2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/parquet/column_reader.cc b/src/parquet/column_reader.cc
index 10d7210..bcbb339 100644
--- a/src/parquet/column_reader.cc
+++ b/src/parquet/column_reader.cc
@@ -180,7 +180,10 @@ std::shared_ptr<Page> SerializedPageReader::NextPage() {
     // Read the compressed data page.
     buffer = stream_->Read(compressed_len, &bytes_read);
     if (bytes_read != compressed_len) {
-      ParquetException::EofException();
+      std::stringstream ss;
+      ss << "Page was smaller (" << bytes_read << ") than expected (" << compressed_len
+         << ")";
+      ParquetException::EofException(ss.str());
     }
 
     // Uncompress it if we need to
diff --git a/src/parquet/exception.cc b/src/parquet/exception.cc
index 2278bc8..5f5525c 100644
--- a/src/parquet/exception.cc
+++ b/src/parquet/exception.cc
@@ -25,8 +25,13 @@
 
 namespace parquet {
 
-PARQUET_NORETURN void ParquetException::EofException() {
-  throw ParquetException("Unexpected end of stream.");
+PARQUET_NORETURN void ParquetException::EofException(const std::string& msg) {
+  std::stringstream ss;
+  ss << "Unexpected end of stream";
+  if (!msg.empty()) {
+    ss << ": " << msg;
+  }
+  throw ParquetException(ss.str());
 }
 
 PARQUET_NORETURN void ParquetException::NYI(const std::string& msg) {
diff --git a/src/parquet/exception.h b/src/parquet/exception.h
index 3748184..08629be 100644
--- a/src/parquet/exception.h
+++ b/src/parquet/exception.h
@@ -59,7 +59,7 @@ namespace parquet {
 
 class PARQUET_EXPORT ParquetException : public std::exception {
  public:
-  PARQUET_NORETURN static void EofException();
+  PARQUET_NORETURN static void EofException(const std::string& msg = "");
   PARQUET_NORETURN static void NYI(const std::string& msg);
   PARQUET_NORETURN static void Throw(const std::string& msg);
 

-- 
To stop receiving notification emails like this one, please contact
wesm@apache.org.