wangbo commented on a change in pull request #8627:
URL: https://github.com/apache/incubator-doris/pull/8627#discussion_r834937056



##########
File path: be/src/vec/columns/column_dictionary.h
##########
@@ -242,18 +213,73 @@ class ColumnDictionary final : public COWHelper<IColumn, 
ColumnDictionary<T>> {
                                const StringRef* dict_array, size_t data_num,
                                uint32_t dict_num) override {
         if (!is_dict_inited()) {
-            dict.reserve(dict_num);
+            _dict.reserve(dict_num);
             for (uint32_t i = 0; i < dict_num; ++i) {
                 auto value = StringValue(dict_array[i].data, 
dict_array[i].size);
-                dict.insert_value(value);
+                _dict.insert_value(value);
             }
             _dict_inited = true;
         }
 
-        char* end_ptr = (char*)codes.get_end_ptr();
+        char* end_ptr = (char*)_codes.get_end_ptr();
         memcpy(end_ptr, data_array + start_index, data_num * sizeof(T));
         end_ptr += data_num * sizeof(T);
-        codes.set_end_ptr(end_ptr);
+        _codes.set_end_ptr(end_ptr);
+    }
+
+    void convert_dict_codes_if_necessary() override {
+        if (!is_dict_sorted()) {
+            _dict.sort();
+            _dict_sorted = true;
+        }
+
+        if (!is_dict_code_converted()) {
+            for (size_t i = 0; i < size(); ++i) {
+                _codes[i] = _dict.convert_code(_codes[i]);
+            }
+            _dict_code_converted = true;
+        }
+    }
+
+    void set_predicate_dict_code_if_necessary(doris::ColumnPredicate* 
predicate) override {
+        switch (predicate->type()) {
+        case PredicateType::EQ:
+        case PredicateType::NE: {
+            // cast to EqualPredicate, just to get value, may not be 
EqualPredicate
+            auto* comp_pred = 
reinterpret_cast<doris::EqualPredicate<StringValue>*>(predicate);
+            auto pred_value = comp_pred->get_value();
+            auto code = _dict.find_code(pred_value);
+            comp_pred->set_dict_code(code);
+            break;
+        }
+        case PredicateType::LT:
+        case PredicateType::LE:
+        case PredicateType::GT:
+        case PredicateType::GE: {
+            // cast to LessPredicate, just to get value, may not be 
LessPredicate
+            auto* comp_pred = 
reinterpret_cast<doris::LessPredicate<StringValue>*>(predicate);
+            auto pred_value = comp_pred->get_value();
+            auto less = predicate->type() == PredicateType::LT ||
+                        predicate->type() == PredicateType::LE;
+            auto eq = predicate->type() == PredicateType::LE ||
+                      predicate->type() == PredicateType::GE;
+            auto code = _dict.find_bound_code(pred_value, less, eq);
+            comp_pred->set_dict_code(code);
+            break;
+        }
+        case PredicateType::InList:
+        case PredicateType::NotInList: {
+            auto* in_pred = 
reinterpret_cast<doris::InListPredicate<StringValue>*>(predicate);
+            auto pred_values = in_pred->get_values();
+            auto code_set = _dict.find_codes(pred_values);
+            in_pred->set_dict_codes(code_set);
+            break;
+        }
+        default:
+            LOG(FATAL) << "PredicateType: " << 
static_cast<int>(predicate->type())
+                       <<  " not supported in ColumnDictionary";
+            break;

Review comment:
       ```LOG(FATAL)``` could core directly, so break is useless.




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