Skip to content

Commit

Permalink
fix macos build
Browse files Browse the repository at this point in the history
  • Loading branch information
marin-ma committed Dec 1, 2023
1 parent 22f7435 commit 8fb0bea
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions velox/common/compression/v2/Lz4Compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
* limitations under the License.
*/

#include <glog/logging.h>

#include "velox/common/base/Exceptions.h"
#include "velox/common/compression/v2/Lz4Compression.h"
#include "velox/common/base/Exceptions.h"

namespace facebook::velox::common {

Expand Down Expand Up @@ -91,8 +89,8 @@ class LZ4Decompressor : public Decompressor {
bool isFinished() override;

protected:
LZ4F_decompressionContext_t ctx_ = nullptr;
bool finished_;
LZ4F_decompressionContext_t ctx_{nullptr};
bool finished_{false};
};

LZ4Compressor::LZ4Compressor(int32_t compressionLevel)
Expand Down Expand Up @@ -142,7 +140,7 @@ Compressor::CompressResult LZ4Compressor::compress(
lz4Error("LZ4 compress update failed: ", numBytesOrError);
}
bytesWritten += static_cast<int64_t>(numBytesOrError);
DCHECK_LE(bytesWritten, outputSize);
VELOX_DCHECK_LE(bytesWritten, outputSize);
return CompressResult{inputLength, bytesWritten, false};
}

Expand Down Expand Up @@ -171,7 +169,7 @@ Compressor::FlushResult LZ4Compressor::flush(
lz4Error("LZ4 flush failed: ", numBytesOrError);
}
bytesWritten += static_cast<uint64_t>(numBytesOrError);
DCHECK_LE(bytesWritten, outputLength);
VELOX_DCHECK_LE(bytesWritten, outputLength);
return FlushResult{bytesWritten, false};
}

Expand Down Expand Up @@ -200,7 +198,7 @@ Compressor::EndResult LZ4Compressor::end(
lz4Error("LZ4 end failed: ", numBytesOrError);
}
bytesWritten += static_cast<uint64_t>(numBytesOrError);
DCHECK_LE(bytesWritten, outputLength);
VELOX_DCHECK_LE(bytesWritten, outputLength);
return EndResult{bytesWritten, false};
}

Expand All @@ -219,27 +217,23 @@ void LZ4Compressor::compressBegin(
}

void common::LZ4Decompressor::init() {
LZ4F_errorCode_t ret;
finished_ = false;

ret = LZ4F_createDecompressionContext(&ctx_, LZ4F_VERSION);
auto ret = LZ4F_createDecompressionContext(&ctx_, LZ4F_VERSION);
if (LZ4F_isError(ret)) {
lz4Error("LZ4 init failed: ", ret);
}
}

void LZ4Decompressor::reset() {
if (ctx_) {
#if defined(LZ4_VERSION_NUMBER) && LZ4_VERSION_NUMBER >= 10800
// LZ4F_resetDecompressionContext appeared in 1.8.0
DCHECK_NE(ctx_, nullptr);
LZ4F_resetDecompressionContext(ctx_);
finished_ = false;
// LZ4F_resetDecompressionContext appeared in 1.8.0.
LZ4F_resetDecompressionContext(ctx_);
#else
if (ctx_ != nullptr) {
LZ4F_freeDecompressionContext(ctx_);
}
init();
init();
#endif
}
}

Decompressor::DecompressResult LZ4Decompressor::decompress(
Expand Down

0 comments on commit 8fb0bea

Please sign in to comment.