mymeiyi commented on code in PR #33481: URL: https://github.com/apache/doris/pull/33481#discussion_r1560402472
########## be/src/vec/sink/writer/vgroup_commit_block_writer.cpp: ########## @@ -0,0 +1,323 @@ +// 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/writer/vgroup_commit_block_writer.h" + +#include <gen_cpp/DataSinks_types.h> + +#include <future> +#include <shared_mutex> + +#include "common/exception.h" +#include "common/status.h" +#include "runtime/exec_env.h" +#include "runtime/group_commit_mgr.h" +#include "runtime/runtime_state.h" +#include "util/debug_points.h" +#include "util/doris_metrics.h" +#include "vec/exprs/vexpr.h" +#include "vec/sink/vtablet_finder.h" + +namespace doris { + +namespace vectorized { +bvar::Adder<int64_t> g_group_commit_load_rows("doris_group_commit_load_rows"); +bvar::Adder<int64_t> g_group_commit_load_bytes("doris_group_commit_load_bytes"); + +VGroupCommitBlockWriter::VGroupCommitBlockWriter(const TDataSink& t_sink, + const VExprContextSPtrs& output_exprs) + : AsyncResultWriter(output_exprs), _filter_bitmap(1024), _t_sink(t_sink) { + DCHECK(t_sink.__isset.olap_table_sink); +} + +VGroupCommitBlockWriter::~VGroupCommitBlockWriter() { + if (_load_block_queue) { + _remove_estimated_wal_bytes(); + _load_block_queue->remove_load_id(_load_id); + _load_block_queue->group_commit_load_count.fetch_add(1); + } +} + +Status VGroupCommitBlockWriter::_init(RuntimeState* state, RuntimeProfile* profile) { + DCHECK(_t_sink.__isset.olap_table_sink); + auto& table_sink = _t_sink.olap_table_sink; + _tuple_desc_id = table_sink.tuple_id; + _schema.reset(new OlapTableSchemaParam()); + RETURN_IF_ERROR(_schema->init(table_sink.schema)); + _db_id = table_sink.db_id; + _table_id = table_sink.table_id; + _base_schema_version = table_sink.base_schema_version; + _group_commit_mode = table_sink.group_commit_mode; + _load_id = table_sink.load_id; + _max_filter_ratio = table_sink.max_filter_ratio; + _vpartition = std::make_unique<doris::VOlapTablePartitionParam>(_schema, table_sink.partition); + RETURN_IF_ERROR(_vpartition->init()); + + _state = state; + + // profile must add to state's object pool + _profile = profile; + _mem_tracker = std::make_shared<MemTracker>("VGroupCommitBlockWriter:" + + std::to_string(state->load_job_id())); + SCOPED_TIMER(_profile->total_time_counter()); + SCOPED_CONSUME_MEM_TRACKER(_mem_tracker.get()); + + // get table's tuple descriptor + _output_tuple_desc = state->desc_tbl().get_tuple_descriptor(_tuple_desc_id); + if (_output_tuple_desc == nullptr) { + LOG(WARNING) << "unknown destination tuple descriptor, id=" << _tuple_desc_id; + return Status::InternalError("unknown destination tuple descriptor"); + } + + _block_convertor = std::make_unique<vectorized::OlapTableBlockConvertor>(_output_tuple_desc); + _block_convertor->init_autoinc_info(_schema->db_id(), _schema->table_id(), + _state->batch_size()); + return Status::OK(); Review Comment: forget to call output_vexpr_ctxs prepare and open? -- 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