HappenLee commented on code in PR #23236:
URL: https://github.com/apache/doris/pull/23236#discussion_r1308322494


##########
be/src/vec/sink/vtablet_sink.cpp:
##########
@@ -1328,30 +1538,114 @@ Status VOlapTableSink::send(RuntimeState* state, 
vectorized::Block* input_block,
     _row_distribution_watch.start();
     auto num_rows = block->rows();
     size_t partition_num = _vpartition->get_partitions().size();
-    if (partition_num == 1 && _tablet_finder->is_find_tablet_every_sink()) {
+    if (!_vpartition->is_auto_partition() && partition_num == 1 &&
+        _tablet_finder->is_find_tablet_every_sink()) {
         RETURN_IF_ERROR(_single_partition_generate(state, block.get(), 
channel_to_payload, num_rows,
                                                    has_filtered_rows));
     } else {
-        for (int i = 0; i < num_rows; ++i) {
-            if (UNLIKELY(has_filtered_rows) && 
_block_convertor->filter_bitmap().Get(i)) {
-                continue;
+        if (_vpartition->is_auto_partition()) {
+            std::vector<uint16_t> partition_keys = 
_vpartition->get_partition_keys();
+            //TODO: use loop to create missing_vals for multi column.
+            CHECK(partition_keys.size() == 1)
+                    << "now support only 1 partition column for auto 
partitions.";
+            auto partition_col = block->get_by_position(partition_keys[0]);
+
+            auto missing_vals_col = partition_col.clone_empty();
+
+            // try to find tablet and save missing value
+            for (int i = 0; i < num_rows; ++i) {
+                if (UNLIKELY(has_filtered_rows) && 
_block_convertor->filter_bitmap().Get(i)) {
+                    continue;
+                }
+                const VOlapTablePartition* partition = nullptr;
+                bool is_continue = false;
+                uint32_t tablet_index = 0;
+                bool missing_this = false;
+                RETURN_IF_ERROR(_tablet_finder->find_tablet(state, 
block.get(), i, &partition,
+                                                            tablet_index, 
stop_processing,
+                                                            is_continue, 
&missing_this));
+                if (missing_this) {
+                    
missing_vals_col.column->assume_mutable()->insert_from(*partition_col.column,

Review Comment:
   TODO:reduce the useless virtual function call



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