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 2021/01/26 10:30:19 UTC

[GitHub] [incubator-doris] stdpain commented on a change in pull request #5301: [optimization] avoid extra memory copy while build hash table

stdpain commented on a change in pull request #5301:
URL: https://github.com/apache/incubator-doris/pull/5301#discussion_r564406631



##########
File path: be/src/exec/hash_table.hpp
##########
@@ -82,77 +81,78 @@ inline void HashTable::insert_impl(TupleRow* row) {
     uint32_t hash = hash_current_row();
     int64_t bucket_idx = hash & (_num_buckets - 1);
 
-    if (_num_nodes == _nodes_capacity) {
+    if (_current_used == _current_capacity) {
         grow_node_array();
     }
+    // get a node from memory pool
+    Node* node = reinterpret_cast<Node*>(_current_nodes + _node_byte_size * _current_used++);
 
-    Node* node = get_node(_num_nodes);
     TupleRow* data = node->data();
     node->_hash = hash;
     memcpy(data, row, sizeof(Tuple*) * _num_build_tuples);
-    add_to_bucket(&_buckets[bucket_idx], _num_nodes, node);
+    add_to_bucket(&_buckets[bucket_idx], node);
     ++_num_nodes;

Review comment:
       _num_nodes is used by HashTable::size()




----------------------------------------------------------------
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:
users@infra.apache.org



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