Skip to content

Commit

Permalink
fix: Fix Compression file check output
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhaliqi committed Jan 10, 2025
1 parent 923dcc8 commit 11f2585
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions velox/dwio/common/compression/Compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "velox/dwio/common/IntCodecCommon.h"
#include "velox/dwio/common/compression/PagedInputStream.h"

#include <fmt/format.h>
#include <folly/logging/xlog.h>
#include <lz4.h>
#include <snappy.h>
Expand Down Expand Up @@ -245,9 +246,10 @@ uint64_t LzoAndLz4DecompressorCommon::decompress(
DWIO_ENSURE_GE(
compressedSize,
dwio::common::INT_BYTE_SIZE,
"{} decompression failed, input len is too small: {}",
kind_,
compressedSize);
fmt::format(
"{} decompression failed, input len is too small: {}",
::facebook::velox::common::compressionKindToString(kind_),
compressedSize));

uint32_t decompressedBlockSize =
folly::Endian::big(folly::loadUnaligned<uint32_t>(inputPtr));
Expand All @@ -258,12 +260,13 @@ uint64_t LzoAndLz4DecompressorCommon::decompress(
DWIO_ENSURE_GE(
remainingOutputSize,
decompressedBlockSize,
"{} decompression failed, remainingOutputSize is less than "
"decompressedBlockSize, remainingOutputSize: {}, "
"decompressedBlockSize: {}",
kind_,
remainingOutputSize,
decompressedBlockSize);
fmt::format(
"{} decompression failed, remainingOutputSize is less than "
"decompressedBlockSize, remainingOutputSize: {}, "
"decompressedBlockSize: {}",
::facebook::velox::common::compressionKindToString(kind_),
remainingOutputSize,
decompressedBlockSize));

if (compressedSize <= 0) {
break;
Expand All @@ -274,9 +277,10 @@ uint64_t LzoAndLz4DecompressorCommon::decompress(
DWIO_ENSURE_GE(
compressedSize,
dwio::common::INT_BYTE_SIZE,
"{} decompression failed, input len is too small: {}",
kind_,
compressedSize);
fmt::format(
"{} decompression failed, input len is too small: {}",
::facebook::velox::common::compressionKindToString(kind_),
compressedSize));
// Read the length of the next lz4/lzo compressed block.
uint32_t compressedBlockSize =
folly::Endian::big(folly::loadUnaligned<uint32_t>(inputPtr));
Expand All @@ -286,15 +290,15 @@ uint64_t LzoAndLz4DecompressorCommon::decompress(
if (compressedBlockSize == 0) {
continue;
}

DWIO_ENSURE_LE(
compressedBlockSize,
compressedSize,
"{} decompression failed, compressedBlockSize is greater than compressedSize, "
"compressedBlockSize: {}, compressedSize: {}",
kind_,
compressedBlockSize,
compressedSize);
fmt::format(
"{} decompression failed, compressedBlockSize is greater than compressedSize, "
"compressedBlockSize: {}, compressedSize: {}",
::facebook::velox::common::compressionKindToString(kind_),
compressedBlockSize,
compressedSize));

// Decompress this block.
remainingOutputSize = uncompressedSize - decompressedTotalSize;
Expand All @@ -307,11 +311,12 @@ uint64_t LzoAndLz4DecompressorCommon::decompress(
DWIO_ENSURE_LE(
decompressedSize,
remainingOutputSize,
"{} decompression failed, decompressedSize is not less than or equal to remainingOutputSize, "
"decompressedSize: {}, remainingOutputSize: {}",
::facebook::velox::common::compressionKindToString(kind_),
decompressedSize,
remainingOutputSize);
fmt::format(
"{} decompression failed, decompressedSize is not less than or equal to remainingOutputSize, "
"decompressedSize: {}, remainingOutputSize: {}",
::facebook::velox::common::compressionKindToString(kind_),
decompressedSize,
remainingOutputSize));

outPtr += decompressedSize;
inputPtr += compressedBlockSize;
Expand All @@ -324,11 +329,12 @@ uint64_t LzoAndLz4DecompressorCommon::decompress(
DWIO_ENSURE_EQ(
decompressedTotalSize,
uncompressedSize,
"{} decompression failed, decompressedTotalSize is not equal to uncompressedSize, "
"decompressedTotalSize: {}, uncompressedSize: {}",
kind_,
decompressedTotalSize,
uncompressedSize);
fmt::format(
"{} decompression failed, decompressedTotalSize is not equal to uncompressedSize, "
"decompressedTotalSize: {}, uncompressedSize: {}",
::facebook::velox::common::compressionKindToString(kind_),
decompressedTotalSize,
uncompressedSize));

return decompressedTotalSize;
}
Expand Down

0 comments on commit 11f2585

Please sign in to comment.