github-actions[bot] commented on code in PR #23681: URL: https://github.com/apache/doris/pull/23681#discussion_r1476050639
########## be/src/olap/rowid_conversion.cpp: ########## @@ -0,0 +1,215 @@ +// 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 "olap/rowid_conversion.h" +namespace doris { +RowIdConversion::RowIdConversion() = default; +RowIdConversion::~RowIdConversion() { + if (_file_reader.get() != nullptr) { + auto st = _file_reader->close(); + if (!st.ok()) { + LOG(WARNING) << "fail to close file " << _file_name; + } + st = io::global_local_filesystem()->delete_file(_file_name); + if (!st.ok()) { + LOG(WARNING) << "fail to delete file " << _file_name; + } + } +} + +// resize segment rowid map to its rows num +void RowIdConversion::init_segment_map(const RowsetId& src_rowset_id, + const std::vector<uint32_t>& num_rows) { + for (size_t i = 0; i < num_rows.size(); i++) { + uint32_t id = _segments_rowid_map.size(); + _segment_to_id_map.emplace(std::pair<RowsetId, uint32_t> {src_rowset_id, i}, id); + _id_to_segment_map.emplace_back(src_rowset_id, i); + _segments_rowid_map.emplace_back(std::vector<std::pair<uint32_t, uint32_t>>( + num_rows[i], std::pair<uint32_t, uint32_t>(UINT32_MAX, UINT32_MAX))); + _count += num_rows[i]; + } +} + +// add row id to the map +void RowIdConversion::add(const std::vector<RowLocation>& rss_row_ids, + const std::vector<uint32_t>& dst_segments_num_row) { + for (auto& item : rss_row_ids) { + if (item.row_id == -1) { + continue; + } + uint32_t id = _segment_to_id_map.at( + std::pair<RowsetId, uint32_t> {item.rowset_id, item.segment_id}); + if (_cur_dst_segment_id < dst_segments_num_row.size() && + _cur_dst_segment_rowid >= dst_segments_num_row[_cur_dst_segment_id]) { + _cur_dst_segment_id++; + _cur_dst_segment_rowid = 0; + } + _segments_rowid_map[id][item.row_id] = + std::pair<uint32_t, uint32_t> {_cur_dst_segment_id, _cur_dst_segment_rowid++}; + } +} + +void RowIdConversion::set_file_name(std::string file_name) { + _file_name = file_name; +} + +Status RowIdConversion::create_file_name(TabletSharedPtr tablet, ReaderType reader_type) { Review Comment: warning: method 'create_file_name' can be made static [readability-convert-member-functions-to-static] be/src/olap/rowid_conversion.h:71: ```diff - Status create_file_name(TabletSharedPtr tablet, ReaderType reader_type); + static Status create_file_name(TabletSharedPtr tablet, ReaderType reader_type); ``` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
