wangbo commented on a change in pull request #6089:
URL: https://github.com/apache/incubator-doris/pull/6089#discussion_r657677205



##########
File path: be/src/olap/rowset/segment_v2/binary_plain_page.h
##########
@@ -193,18 +194,33 @@ class BinaryPlainPageDecoder : public PageDecoder {
             *n = 0;
             return Status::OK();
         }
-        size_t max_fetch = std::min(*n, static_cast<size_t>(_num_elems - 
_cur_idx));
+        const size_t max_fetch = std::min(*n, static_cast<size_t>(_num_elems - 
_cur_idx));
 
         Slice* out = reinterpret_cast<Slice*>(dst->data());
-
+        std::vector<size_t> mem_len(max_fetch);
         for (size_t i = 0; i < max_fetch; i++, out++, _cur_idx++) {
-            Slice elem(string_at_index(_cur_idx));
-            out->size = elem.size;
-            if (elem.size != 0) {
-                out->data =
-                        
reinterpret_cast<char*>(dst->pool()->allocate(elem.size * sizeof(uint8_t)));
-                memcpy(out->data, elem.data, elem.size);
-            }
+            *out = string_at_index(_cur_idx);
+            mem_len[i] = out->size;
+        }
+
+        // use SIMD instruction to speed up call function `RoundUpToPowerOfTwo`
+        auto mem_size = 0;
+        for (int i = 0; i < max_fetch; ++i) {
+            mem_len[i] = BitUtil::RoundUpToPowerOf2Int32(mem_len[i], 
MemPool::DEFAULT_ALIGNMENT);
+            mem_size += mem_len[i];
+        }
+
+        // allocate a batch of memory and do memcpy
+        out = reinterpret_cast<Slice*>(dst->data());
+        char* destination = 
(char*)dst->column_block()->pool()->allocate(mem_size);
+        if (destination == nullptr) {
+            return Status::MemoryAllocFailed(
+                strings::Substitute("memory allocate failed, size:$0", 
mem_size));
+        }
+        for (int i = 0; i < max_fetch; ++i) {
+            out->relocate(destination);

Review comment:
       Here still need to memcpy ```max_fetch``` times;
   If we use CK's ```ColumnString``` to replace current's ColumnBlock, just 
memcpy once here.
   We can do it later;




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

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