From 1be9371fb5a8beefe5343d3c4d379be52492612f Mon Sep 17 00:00:00 2001 From: Nikolay Degterinsky Date: Mon, 1 May 2023 13:01:23 +0000 Subject: [PATCH] Better --- src/IO/HadoopSnappyReadBuffer.cpp | 7 +++---- src/IO/HadoopSnappyReadBuffer.h | 3 +++ src/IO/WithFileName.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/IO/HadoopSnappyReadBuffer.cpp b/src/IO/HadoopSnappyReadBuffer.cpp index 577367e5607..28588854268 100644 --- a/src/IO/HadoopSnappyReadBuffer.cpp +++ b/src/IO/HadoopSnappyReadBuffer.cpp @@ -91,9 +91,8 @@ inline HadoopSnappyDecoder::Status HadoopSnappyDecoder::readCompressedLength(siz { auto status = readLength(avail_in, next_in, &compressed_length); if (unlikely(compressed_length > 0 && static_cast(compressed_length) > sizeof(buffer))) - throw Exception(ErrorCodes::SNAPPY_UNCOMPRESS_FAILED, - "Too large snappy compressed block. buffer size: {}, compressed block size: {}", - sizeof(buffer), compressed_length); + return Status::TOO_LARGE_COMPRESSED_BLOCK; + return status; } return Status::OK; @@ -225,7 +224,7 @@ bool HadoopSnappyReadBuffer::nextImpl() } return true; } - else if (decoder->result == Status::INVALID_INPUT || decoder->result == Status::BUFFER_TOO_SMALL) + else if (decoder->result != Status::NEEDS_MORE_INPUT) { throw Exception( ErrorCodes::SNAPPY_UNCOMPRESS_FAILED, diff --git a/src/IO/HadoopSnappyReadBuffer.h b/src/IO/HadoopSnappyReadBuffer.h index 6d1b95f6813..b5fb1fec093 100644 --- a/src/IO/HadoopSnappyReadBuffer.h +++ b/src/IO/HadoopSnappyReadBuffer.h @@ -29,6 +29,7 @@ public: INVALID_INPUT = 1, BUFFER_TOO_SMALL = 2, NEEDS_MORE_INPUT = 3, + TOO_LARGE_COMPRESSED_BLOCK = 4, }; HadoopSnappyDecoder() = default; @@ -84,6 +85,8 @@ public: return "BUFFER_TOO_SMALL"; case Status::NEEDS_MORE_INPUT: return "NEEDS_MORE_INPUT"; + case Status::TOO_LARGE_COMPRESSED_BLOCK: + return "TOO_LARGE_COMPRESSED_BLOCK"; } UNREACHABLE(); } diff --git a/src/IO/WithFileName.cpp b/src/IO/WithFileName.cpp index 0ec9ed5dd53..ef4b5fed3b1 100644 --- a/src/IO/WithFileName.cpp +++ b/src/IO/WithFileName.cpp @@ -33,7 +33,7 @@ String getExceptionEntryWithFileName(const ReadBuffer & in) if (filename.empty()) return ""; - return "; While reading from: " + filename; + return fmt::format("; While reading from: {}", filename); } }