yixiutt commented on code in PR #12573:
URL: https://github.com/apache/doris/pull/12573#discussion_r970840207


##########
be/src/util/block_compression.cpp:
##########
@@ -78,122 +123,260 @@ class Lz4BlockCompression : public BlockCompressionCodec 
{
         return Status::OK();
     }
 
-    size_t max_compressed_len(size_t len) const override {
-        if (len > std::numeric_limits<int32_t>::max()) {
-            return 0;
+    size_t max_compressed_len(size_t len) override { return 
LZ4_compressBound(len); }
+
+private:
+    // reuse LZ4 compress stream
+    Status _acquire_compression_ctx(Context** out) {
+        std::lock_guard<std::mutex> l(_ctx_mutex);
+        if (_ctx_pool.empty()) {
+            Context* context = new (std::nothrow) Context();
+            if (context == nullptr) {
+                return Status::InvalidArgument("new LZ4 context error");
+            }
+            context->ctx = LZ4_createStream();
+            if (context->ctx == nullptr) {
+                delete context;
+                return Status::InvalidArgument("LZ4_createStream error");
+            }
+            *out = context;
+            return Status::OK();
         }
-        return LZ4_compressBound(len);
+        *out = _ctx_pool.back();

Review Comment:
   done



##########
be/src/vec/core/block.cpp:
##########
@@ -711,10 +713,10 @@ Status Block::serialize(PBlock* pblock, std::string* 
compressed_buffer, size_t*
 
     // serialize data values
     // when data type is HLL, content_uncompressed_size maybe larger than real 
size.
-    std::string* column_values = nullptr;
+    std::string column_values;
     try {
-        column_values = pblock->mutable_column_values();
-        column_values->resize(content_uncompressed_size);
+        //column_values = pblock->mutable_column_values();

Review Comment:
   done



-- 
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