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


##########
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:
##########
@@ -456,32 +451,34 @@
 
 class Lz4HCBlockCompression : public BlockCompressionCodec {
 private:
-    struct Context {
+    class Context {
+        ENABLE_FACTORY_CREATOR(Context);
+
+    public:
         Context() : ctx(nullptr) {}
         LZ4_streamHC_t* ctx;
         faststring buffer;
+        ~Context() {
+            if (ctx) {
+                LZ4_freeStreamHC(ctx);
+            }
+        }
     };
 
 public:
     static Lz4HCBlockCompression* instance() {
         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 @@
 
 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:
##########
@@ -456,32 +451,34 @@
 
 class Lz4HCBlockCompression : public BlockCompressionCodec {
 private:
-    struct Context {
+    class Context {
+        ENABLE_FACTORY_CREATOR(Context);
+
+    public:
         Context() : ctx(nullptr) {}
         LZ4_streamHC_t* ctx;
         faststring buffer;
+        ~Context() {
+            if (ctx) {
+                LZ4_freeStreamHC(ctx);
+            }
+        }
     };
 
 public:
     static Lz4HCBlockCompression* instance() {
         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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to