bkietz commented on a change in pull request #11810:
URL: https://github.com/apache/arrow/pull/11810#discussion_r759438645



##########
File path: cpp/src/arrow/util/compression_lz4.cc
##########
@@ -234,14 +242,21 @@ class LZ4Compressor : public Compressor {
   LZ4F_compressionContext_t ctx_ = nullptr;
   LZ4F_preferences_t prefs_;
   bool first_time_;
+
+ private:
+  int compression_level_;
 };
 
 // ----------------------------------------------------------------------
 // Lz4 frame codec implementation
 
 class Lz4FrameCodec : public Codec {
  public:
-  Lz4FrameCodec() : prefs_(DefaultPreferences()) {}
+  Lz4FrameCodec(int compression_level)
+      : compression_level_(compression_level == kUseDefaultCompressionLevel
+                               ? kLZ4DefaultCompressionLevel
+                               : compression_level),
+                               prefs_(DefaultPreferences(compression_level)) {}

Review comment:
       If there's a possibility that `compression_level` could be overridden, 
it seems that same override should be applied to `prefs_`
   ```suggestion
                                  
prefs_(DefaultPreferences(compression_level_)) {}
   ```

##########
File path: cpp/src/arrow/util/compression_lz4.cc
##########
@@ -41,13 +41,20 @@ namespace util {
 
 namespace {
 
+constexpr int kLZ4MinCompressionLevel = 1;
+constexpr int kLZ4DefaultCompressionLevel = 1;
+
 static Status LZ4Error(LZ4F_errorCode_t ret, const char* prefix_msg) {
   return Status::IOError(prefix_msg, LZ4F_getErrorName(ret));
 }
 
 static LZ4F_preferences_t DefaultPreferences() {
-  LZ4F_preferences_t prefs;
-  memset(&prefs, 0, sizeof(prefs));
+  LZ4F_preferences_t prefs = LZ4F_INIT_PREFERENCES;

Review comment:
       Please add a comment explaining this macro (or at least I assume it's a 
macro and not a constant). If it isn't completely trivial, I'd recommend 
ensuring that it is only evaluated once:
   ```suggestion
     static LZ4F_preferences_t prefs = LZ4F_INIT_PREFERENCES;
   ```

##########
File path: cpp/src/arrow/util/compression_lz4.cc
##########
@@ -41,13 +41,20 @@ namespace util {
 
 namespace {
 
+constexpr int kLZ4MinCompressionLevel = 1;
+constexpr int kLZ4DefaultCompressionLevel = 1;
+
 static Status LZ4Error(LZ4F_errorCode_t ret, const char* prefix_msg) {
   return Status::IOError(prefix_msg, LZ4F_getErrorName(ret));
 }
 
 static LZ4F_preferences_t DefaultPreferences() {
-  LZ4F_preferences_t prefs;
-  memset(&prefs, 0, sizeof(prefs));
+  LZ4F_preferences_t prefs = LZ4F_INIT_PREFERENCES;
+  return prefs;
+}
+
+static LZ4F_preferences_t DefaultPreferences(int compression_level) {

Review comment:
       if this argument is intentionally ignored, please make an explanatory 
comment
   




-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to