zenoyang commented on a change in pull request #8627: URL: https://github.com/apache/incubator-doris/pull/8627#discussion_r836242857
########## File path: be/src/vec/columns/column_dictionary.h ########## @@ -264,127 +261,121 @@ class ColumnDictionary final : public COWHelper<IColumn, ColumnDictionary<T>> { ColumnPtr convert_to_predicate_column() { auto res = vectorized::PredicateColumnType<StringValue>::create(); - size_t size = codes.size(); + size_t size = _codes.size(); res->reserve(size); for (size_t i = 0; i < size; ++i) { - auto& code = reinterpret_cast<T&>(codes[i]); - auto value = dict.get_value(code); + auto& code = reinterpret_cast<T&>(_codes[i]); + auto value = _dict.get_value(code); res->insert_data(value.ptr, value.len); } - dict.clear(); + _dict.clear(); return res; } - void convert_dict_codes() { - if (!is_dict_sorted()) { - sort_dict(); - } - - if (!is_dict_code_converted()) { - for (size_t i = 0; i < size(); ++i) { - codes[i] = dict.convert_code(codes[i]); - } - _dict_code_converted = true; + ColumnPtr convert_to_predicate_column_if_dictionary() override { + auto res = vectorized::PredicateColumnType<StringValue>::create(); + size_t size = _codes.size(); + res->reserve(size); + for (size_t i = 0; i < size; ++i) { + auto& code = reinterpret_cast<T&>(_codes[i]); + auto value = _dict.get_value(code); + res->insert_data(value.ptr, value.len); } - } - - void sort_dict() { - dict.sort(); - _dict_sorted = true; + _dict.clear(); + return res; } class Dictionary { public: Dictionary() = default; void reserve(size_t n) { - dict_data.reserve(n); - inverted_index.reserve(n); + _dict_data.reserve(n); + _inverted_index.reserve(n); } inline void insert_value(StringValue& value) { - dict_data.push_back_without_reserve(value); - inverted_index[value] = inverted_index.size(); + _dict_data.push_back_without_reserve(value); + _inverted_index[value] = _inverted_index.size(); } - inline T find_code(const StringValue& value) const { - auto it = inverted_index.find(value); - if (it != inverted_index.end()) { + inline int32_t find_code(const StringValue& value) const { + auto it = _inverted_index.find(value); + if (it != _inverted_index.end()) { return it->second; } return -1; } - inline T find_bound_code(const StringValue& value, bool lower, bool eq) const { + inline int32_t find_code_by_bound(const StringValue& value, bool lower, bool eq) const { Review comment: Because the `dict_code` in `ColumnPredicate` is fixed to `int32_t` type, the `dict_code` returned by `find_code...` needs to be compared with the `dict_code` in `ColumnPredicate`. `T` may be `int8_t` or `int16_t`, so cast is performed when find returns. And if there is no cast here, there will be a compilation error, similar to `phmap::flat_hash_set<int8_t>` cannot be converted to `phmap::flat_hash_set<int32_t>` -- 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