github-actions[bot] commented on code in PR #15663: URL: https://github.com/apache/doris/pull/15663#discussion_r1063242736
########## be/src/vec/core/block.cpp: ########## @@ -1075,4 +1081,33 @@ void MutableBlock::clear_column_data() noexcept { } } +void MutableBlock::initialize_index_by_name() { + for (size_t i = 0, size = _names.size(); i < size; ++i) { + index_by_name[_names[i]] = i; + } +} + +bool MutableBlock::has(const std::string& name) const { + return index_by_name.end() != index_by_name.find(name); +} + +size_t MutableBlock::get_position_by_name(const std::string& name) const { + auto it = index_by_name.find(name); + if (index_by_name.end() == it) { + LOG(FATAL) << fmt::format("Not found column {} in block. There are only columns: {}", name, + dump_names()); + } + + return it->second; +} + +std::string MutableBlock::dump_names() const { + std::stringstream out; + for (auto it = _names.begin(); it != _names.end(); ++it) { + if (it != _names.begin()) out << ", "; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (it != _names.begin()) { out << ", "; } ``` -- 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