This commit is contained in:
Nikolay Degterinsky 2023-05-01 13:01:23 +00:00
parent 111fb4b8a9
commit 1be9371fb5
3 changed files with 7 additions and 5 deletions

View File

@ -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<size_t>(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,

View File

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

View File

@ -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);
}
}