You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/05/14 06:40:48 UTC

[GitHub] [incubator-doris] xiaokang commented on a diff in pull request #9566: optimize lz4 compress and decompress speed by reusing context

xiaokang commented on code in PR #9566:
URL: https://github.com/apache/incubator-doris/pull/9566#discussion_r872940972


##########
be/src/util/block_compression.cpp:
##########
@@ -370,27 +388,39 @@ class ZlibBlockCompression : public BlockCompressionCodec {
 };
 
 Status get_block_compression_codec(segment_v2::CompressionTypePB type,
-                                   const BlockCompressionCodec** codec) {
+                                   std::unique_ptr<BlockCompressionCodec>& codec) {
+    BlockCompressionCodec* ptr = nullptr;
     switch (type) {
     case segment_v2::CompressionTypePB::NO_COMPRESSION:
-        *codec = nullptr;
-        break;
+        codec.reset(nullptr);
+        return Status::OK();
     case segment_v2::CompressionTypePB::SNAPPY:
-        *codec = SnappyBlockCompression::instance();
+        ptr = new SnappyBlockCompression();

Review Comment:
   Yes, it's an easier way to use codec.reset(new SnappyBlockCompression()). 
   
   But I changed to the current more complex way, new a ptr first and then call ptr->init() and call codec.reset(ptr) finally, to avoid reset codec to a not properly initialized prt.



-- 
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-unsubscribe@doris.apache.org

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


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