github-actions[bot] commented on code in PR #33622:
URL: https://github.com/apache/doris/pull/33622#discussion_r1564770168


##########
be/src/util/block_compression.cpp:
##########
@@ -90,22 +91,26 @@
 
 class Lz4BlockCompression : public BlockCompressionCodec {
 private:
-    struct Context {
+    class Context {
+        ENABLE_FACTORY_CREATOR(Context);
+
+    public:
         Context() : ctx(nullptr) {}
         LZ4_stream_t* ctx;
         faststring buffer;
+        ~Context() {
+            if (ctx) {
+                LZ4_freeStream(ctx);
+            }
+        }
     };
 
 public:
     static Lz4BlockCompression* instance() {
         static Lz4BlockCompression s_instance;
         return &s_instance;
     }
-    ~Lz4BlockCompression() {
-        for (auto ctx : _ctx_pool) {
-            _delete_compression_ctx(ctx);
-        }
-    }
+    ~Lz4BlockCompression() { _ctx_pool.clear(); }

Review Comment:
   warning: annotate this function with 'override' or (rarely) 'final' 
[modernize-use-override]
   
   ```suggestion
       ~Lz4BlockCompression() override { _ctx_pool.clear(); }
   ```
   



##########
be/src/util/block_compression.cpp:
##########
@@ -467,20 +467,14 @@
         static Lz4HCBlockCompression s_instance;
         return &s_instance;
     }
-    ~Lz4HCBlockCompression() {
-        for (auto ctx : _ctx_pool) {
-            _delete_compression_ctx(ctx);
-        }
-    }
+    ~Lz4HCBlockCompression() { _ctx_pool.clear(); }

Review Comment:
   warning: use '= default' to define a trivial destructor 
[modernize-use-equals-default]
   ```cpp
       ~Lz4HCBlockCompression() { _ctx_pool.clear(); }
       ^
   ```
   



##########
be/src/util/block_compression.cpp:
##########
@@ -90,22 +91,26 @@ bool BlockCompressionCodec::exceed_max_compress_len(size_t 
uncompressed_size) {
 
 class Lz4BlockCompression : public BlockCompressionCodec {
 private:
-    struct Context {
+    class Context {
+        ENABLE_FACTORY_CREATOR(Context);
+
+    public:
         Context() : ctx(nullptr) {}
         LZ4_stream_t* ctx;
         faststring buffer;
+        ~Context() {
+            if (ctx) {
+                LZ4_freeStream(ctx);
+            }
+        }
     };
 
 public:
     static Lz4BlockCompression* instance() {
         static Lz4BlockCompression s_instance;
         return &s_instance;
     }
-    ~Lz4BlockCompression() {
-        for (auto ctx : _ctx_pool) {
-            _delete_compression_ctx(ctx);
-        }
-    }
+    ~Lz4BlockCompression() { _ctx_pool.clear(); }

Review Comment:
   warning: use '= default' to define a trivial destructor 
[modernize-use-equals-default]
   ```cpp
       ~Lz4BlockCompression() { _ctx_pool.clear(); }
       ^
   ```
   



##########
be/src/util/block_compression.cpp:
##########
@@ -467,20 +467,14 @@
         static Lz4HCBlockCompression s_instance;
         return &s_instance;
     }
-    ~Lz4HCBlockCompression() {
-        for (auto ctx : _ctx_pool) {
-            _delete_compression_ctx(ctx);
-        }
-    }
+    ~Lz4HCBlockCompression() { _ctx_pool.clear(); }

Review Comment:
   warning: annotate this function with 'override' or (rarely) 'final' 
[modernize-use-override]
   
   ```suggestion
       ~Lz4HCBlockCompression() override { _ctx_pool.clear(); }
   ```
   



-- 
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: commits-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to