-
Notifications
You must be signed in to change notification settings - Fork 175
Add ZSTD compression #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ZSTD compression #367
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ Optional dependencies: | |
- openssl | ||
- liblz4 | ||
- libabsl | ||
- libzstd | ||
|
||
## Building | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,20 @@ | |
|
||
namespace clickhouse { | ||
|
||
/// Methods of block compression. | ||
enum class CompressionMethod : int8_t { | ||
None = -1, | ||
LZ4 = 1, | ||
ZSTD = 2, | ||
}; | ||
|
||
// see DB::CompressionMethodByte from src/Compression/CompressionInfo.h of ClickHouse project | ||
enum class CompressionMethodByte : uint8_t { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that a part of the public API that users should know about? If not, please move away from the headers to the cpp. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to cpp |
||
NONE = 0x02, | ||
LZ4 = 0x82, | ||
ZSTD = 0x90, | ||
}; | ||
|
||
class CompressedInput : public ZeroCopyInput { | ||
public: | ||
explicit CompressedInput(InputStream* input); | ||
|
@@ -25,7 +39,7 @@ class CompressedInput : public ZeroCopyInput { | |
|
||
class CompressedOutput : public OutputStream { | ||
public: | ||
explicit CompressedOutput(OutputStream * destination, size_t max_compressed_chunk_size = 0); | ||
explicit CompressedOutput(OutputStream* destination, size_t max_compressed_chunk_size = 0, CompressionMethod method = CompressionMethod::LZ4); | ||
~CompressedOutput() override; | ||
|
||
protected: | ||
|
@@ -40,6 +54,7 @@ class CompressedOutput : public OutputStream { | |
OutputStream * destination_; | ||
const size_t max_compressed_chunk_size_; | ||
Buffer compressed_buffer_; | ||
CompressionMethod method_; | ||
}; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
#include "query.h" | ||
#include "exceptions.h" | ||
|
||
#include "base/compressed.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this is not the best decision: clients are not expected to rely on stuff in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
#include "columns/array.h" | ||
#include "columns/date.h" | ||
#include "columns/decimal.h" | ||
|
@@ -39,12 +41,6 @@ struct ServerInfo { | |
uint64_t revision; | ||
}; | ||
|
||
/// Methods of block compression. | ||
enum class CompressionMethod { | ||
None = -1, | ||
LZ4 = 1, | ||
}; | ||
|
||
struct Endpoint { | ||
std::string host; | ||
uint16_t port = 9000; | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please handle invalid\unsupported compression methods too:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done