You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/04/06 22:48:30 UTC
[GitHub] [orc] noirello opened a new pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
noirello opened a new pull request #679:
URL: https://github.com/apache/orc/pull/679
<!--
Thanks for sending a pull request! Here are some tips for you:
1. File a JIRA issue first and use it as a prefix of your PR title, e.g., `ORC-001: Fix ABC`.
2. Use your PR title to summarize what this PR proposes instead of describing the problem.
3. Make PR title and description complete because these will be the permanent commit log.
4. If possible, provide a concise and reproducible example to reproduce the issue for a faster review.
5. If the PR is unfinished, use GitHub PR Draft feature.
-->
### What changes were proposed in this pull request?
A new BlockCompressionStream class was implemented, that can be used for LZ4 compression kind.
### Why are the changes needed?
The C++ Writer doesn't support LZ4 compression. This PR aims to fix that.
### How was this patch tested?
The existing compression tests were copied and changed to use LZ4 compression,
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] noirello commented on a change in pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
noirello commented on a change in pull request #679:
URL: https://github.com/apache/orc/pull/679#discussion_r609418988
##########
File path: c++/src/Compression.cc
##########
@@ -36,6 +36,10 @@
#define ZSTD_CLEVEL_DEFAULT 3
#endif
+#ifndef LZ4_ACCELERATION_MAX
+#define LZ4_ACCELERATION_MAX 65537
Review comment:
These macros are defined in `lz4.c` instead of the header file for some reason. That's why I needed to redefined them here. Their values are looked up from the docs/[sources](https://github.com/lz4/lz4/blob/bdc9d3b0c10cbf7e1ff40fc6e27dad5f693a00e7/lib/lz4.c#L47-L57).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] noirello commented on a change in pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
noirello commented on a change in pull request #679:
URL: https://github.com/apache/orc/pull/679#discussion_r609418988
##########
File path: c++/src/Compression.cc
##########
@@ -36,6 +36,10 @@
#define ZSTD_CLEVEL_DEFAULT 3
#endif
+#ifndef LZ4_ACCELERATION_MAX
+#define LZ4_ACCELERATION_MAX 65537
Review comment:
These macros are defined in `lz4.c` instead of the header file for some reason. That's why I needed to redefine them here. Their values are looked up from the docs/[sources](https://github.com/lz4/lz4/blob/bdc9d3b0c10cbf7e1ff40fc6e27dad5f693a00e7/lib/lz4.c#L47-L57).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] dongjoon-hyun commented on pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #679:
URL: https://github.com/apache/orc/pull/679#issuecomment-817087241
Merged to master. Thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] dongjoon-hyun commented on pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #679:
URL: https://github.com/apache/orc/pull/679#issuecomment-869065354
I updated the JIRA for Apache ORC 1.7.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] noirello commented on a change in pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
noirello commented on a change in pull request #679:
URL: https://github.com/apache/orc/pull/679#discussion_r609409159
##########
File path: c++/src/Compression.cc
##########
@@ -897,6 +901,70 @@ DIAGNOSTIC_POP
return true;
}
+ /**
+ * LZ4 block compression
+ */
+ class Lz4CompressionSteam: public BlockCompressionStream {
+ public:
+ Lz4CompressionSteam(OutputStream * outStream,
+ int compressionLevel,
+ uint64_t capacity,
+ uint64_t blockSize,
+ MemoryPool& pool)
+ : BlockCompressionStream(outStream,
+ compressionLevel,
+ capacity,
+ blockSize,
+ pool) {
+ this->init();
+ }
+
+ virtual std::string getName() const override {
+ return "Lz4CompressionStream";
+ }
+
+ virtual ~Lz4CompressionSteam() override {
+ this->end();
+ }
+
+ protected:
+ virtual uint64_t doBlockCompression() override;
+
+ virtual uint64_t estimateMaxCompressionSize() override {
+ return static_cast<uint64_t>(LZ4_compressBound(bufferSize));
+ }
+
+ private:
+ void init();
+ void end();
+ LZ4_stream_t *state;
+ };
+
+ uint64_t Lz4CompressionSteam::doBlockCompression() {
+ int result = LZ4_compress_fast_extState(static_cast<void*>(state),
+ reinterpret_cast<const char*>(rawInputBuffer.data()),
+ reinterpret_cast<char*>(compressorBuffer.data()),
+ bufferSize,
+ static_cast<int>(compressorBuffer.size()),
+ level);
+ if (result == 0) {
+ throw std::runtime_error("Error during block compression using lz4.");
+ }
+ return static_cast<uint64_t>(result);
+ }
+
+ void Lz4CompressionSteam::init() {
+ state = static_cast<LZ4_stream_t*>(malloc(static_cast<size_t>(LZ4_sizeofState())));
Review comment:
I just overlooked it. Somehow the `void*` cast through me off a little. Fixed it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] wgtmac commented on a change in pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
wgtmac commented on a change in pull request #679:
URL: https://github.com/apache/orc/pull/679#discussion_r609218500
##########
File path: c++/src/Compression.cc
##########
@@ -897,6 +901,70 @@ DIAGNOSTIC_POP
return true;
}
+ /**
+ * LZ4 block compression
+ */
+ class Lz4CompressionSteam: public BlockCompressionStream {
+ public:
+ Lz4CompressionSteam(OutputStream * outStream,
+ int compressionLevel,
+ uint64_t capacity,
+ uint64_t blockSize,
+ MemoryPool& pool)
+ : BlockCompressionStream(outStream,
+ compressionLevel,
+ capacity,
+ blockSize,
+ pool) {
+ this->init();
+ }
+
+ virtual std::string getName() const override {
+ return "Lz4CompressionStream";
+ }
+
+ virtual ~Lz4CompressionSteam() override {
+ this->end();
+ }
+
+ protected:
+ virtual uint64_t doBlockCompression() override;
+
+ virtual uint64_t estimateMaxCompressionSize() override {
+ return static_cast<uint64_t>(LZ4_compressBound(bufferSize));
+ }
+
+ private:
+ void init();
+ void end();
+ LZ4_stream_t *state;
+ };
+
+ uint64_t Lz4CompressionSteam::doBlockCompression() {
+ int result = LZ4_compress_fast_extState(static_cast<void*>(state),
+ reinterpret_cast<const char*>(rawInputBuffer.data()),
+ reinterpret_cast<char*>(compressorBuffer.data()),
+ bufferSize,
+ static_cast<int>(compressorBuffer.size()),
+ level);
+ if (result == 0) {
+ throw std::runtime_error("Error during block compression using lz4.");
+ }
+ return static_cast<uint64_t>(result);
+ }
+
+ void Lz4CompressionSteam::init() {
+ state = static_cast<LZ4_stream_t*>(malloc(static_cast<size_t>(LZ4_sizeofState())));
Review comment:
why not use LZ4_createStream() to create one and free it via LZ4_freeStream() ?
##########
File path: c++/src/Compression.cc
##########
@@ -36,6 +36,10 @@
#define ZSTD_CLEVEL_DEFAULT 3
#endif
+#ifndef LZ4_ACCELERATION_MAX
+#define LZ4_ACCELERATION_MAX 65537
Review comment:
Why set to 65537? Will it overflows to be a negative number as the acceleration parameter used in lz4 is of type int.
##########
File path: c++/src/Compression.cc
##########
@@ -1064,9 +1132,15 @@ DIAGNOSTIC_PUSH
(new ZSTDCompressionStream(
outStream, level, bufferCapacity, compressionBlockSize, pool));
}
+ case CompressionKind_LZ4: {
+ int level = (strategy == CompressionStrategy_SPEED) ?
+ LZ4_ACCELERATION_MAX : 1;
Review comment:
replace magic number 1 with macro ACCELERATION_DEFAULT defined in lz4.h
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] dongjoon-hyun merged pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun merged pull request #679:
URL: https://github.com/apache/orc/pull/679
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [orc] dongjoon-hyun commented on pull request #679: ORC-780: Add LZ4 Compression to the C++ Writer
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #679:
URL: https://github.com/apache/orc/pull/679#issuecomment-816223339
+1, LGTM.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org