github-actions[bot] commented on code in PR #26432:
URL: https://github.com/apache/doris/pull/26432#discussion_r1384804918


##########
be/src/vec/sink/vrow_distribution.cpp:
##########
@@ -0,0 +1,306 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "vec/sink/vrow_distribution.h"
+
+#include <gen_cpp/FrontendService.h>
+#include <gen_cpp/FrontendService_types.h>
+
+#include "runtime/client_cache.h"
+#include "runtime/exec_env.h"
+#include "runtime/runtime_state.h"
+#include "util/thrift_rpc_helper.h"
+#include "vec/columns/column_const.h"
+#include "vec/columns/column_nullable.h"
+#include "vec/columns/column_vector.h"
+#include "vec/sink/writer/vtablet_writer.h"
+
+namespace doris::vectorized {
+
+std::pair<vectorized::VExprContextSPtr, vectorized::VExprSPtr>
+VRowDistribution::_get_partition_function() {
+    return {_vpartition->get_part_func_ctx(), 
_vpartition->get_partition_function()};
+}
+
+void VRowDistribution::_save_missing_values(vectorized::ColumnPtr col,
+                                            vectorized::DataTypePtr 
value_type) {
+    _partitions_need_create.clear();
+    std::set<std::string> deduper;
+    // de-duplication
+    for (auto row : _missing_map) {
+        deduper.emplace(value_type->to_string(*col, row));
+    }
+    for (auto& value : deduper) {
+        TStringLiteral node;
+        node.value = value;
+        _partitions_need_create.emplace_back(std::vector {node}); // only 1 
partition column now
+    }
+}
+
+Status VRowDistribution::_automatic_create_partition() {
+    SCOPED_TIMER(_add_partition_request_timer);
+    TCreatePartitionRequest request;
+    TCreatePartitionResult result;
+    request.__set_txn_id(_txn_id);
+    request.__set_db_id(_vpartition->db_id());
+    request.__set_table_id(_vpartition->table_id());
+    request.__set_partitionValues(_partitions_need_create);
+
+    VLOG(1) << "automatic partition rpc begin request " << request;
+    TNetworkAddress master_addr = 
ExecEnv::GetInstance()->master_info()->network_address;
+    int time_out = _state->execution_timeout() * 1000;
+    RETURN_IF_ERROR(ThriftRpcHelper::rpc<FrontendServiceClient>(
+            master_addr.hostname, master_addr.port,
+            [&request, &result](FrontendServiceConnection& client) {
+                client->createPartition(result, request);
+            },
+            time_out));
+
+    Status status(Status::create(result.status));
+    VLOG(1) << "automatic partition rpc end response " << result;
+    if (result.status.status_code == TStatusCode::OK) {
+        // add new created partitions
+        RETURN_IF_ERROR(_vpartition->add_partitions(result.partitions));
+        RETURN_IF_ERROR(_on_partitions_created(_caller, &result));
+    }
+
+    return status;
+}
+
+void VRowDistribution::_get_tablet_ids(vectorized::Block* block, int32_t 
index_idx,
+                                       std::vector<int64_t>& tablet_ids) {
+    tablet_ids.reserve(block->rows());
+    for (int row_idx = 0; row_idx < block->rows(); row_idx++) {
+        if (_skip[row_idx]) {
+            continue;
+        }
+        auto& partition = _partitions[row_idx];
+        auto& tablet_index = _tablet_indexes[row_idx];
+        auto& index = partition->indexes[index_idx];
+
+        auto tablet_id = index.tablets[tablet_index];
+        tablet_ids[row_idx] = tablet_id;
+    }
+}
+
+void VRowDistribution::_filter_block_by_skip(vectorized::Block* block,

Review Comment:
   warning: method '_filter_block_by_skip' can be made static 
[readability-convert-member-functions-to-static]
   
   be/src/vec/sink/vrow_distribution.h:110:
   ```diff
   -     void _filter_block_by_skip(vectorized::Block* block, RowPartTabletIds& 
row_part_tablet_id);
   +     static void _filter_block_by_skip(vectorized::Block* block, 
RowPartTabletIds& row_part_tablet_id);
   ```
   



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