You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/09/21 08:15:09 UTC

[GitHub] [doris] adonis0147 commented on a diff in pull request #12807: [Enhancement](optimize) optimize for insert_indices_from

adonis0147 commented on code in PR #12807:
URL: https://github.com/apache/doris/pull/12807#discussion_r976185747


##########
be/src/vec/columns/column_vector.cpp:
##########
@@ -324,20 +324,21 @@ void ColumnVector<T>::insert_range_from(const IColumn& src, size_t start, size_t
 template <typename T>
 void ColumnVector<T>::insert_indices_from(const IColumn& src, const int* indices_begin,
                                           const int* indices_end) {
-    const Self& src_vec = assert_cast<const Self&>(src);
     auto origin_size = size();
     auto new_size = indices_end - indices_begin;
     data.resize(origin_size + new_size);
 
-    for (int i = 0; i < new_size; ++i) {
-        int offset = indices_begin[i];
-        if constexpr (std::is_same_v<T, UInt8>) {
-            // Now Uint8 use to identify null and non null
-            // 1. nullable column : offset == -1 means is null at the here, set true here
-            // 2. real data column : offset == -1 what at is meaningless
-            data[origin_size + i] = (offset == -1) ? T {1} : src_vec.get_element(offset);
-        } else {
-            data[origin_size + i] = (offset == -1) ? T {0} : src_vec.get_element(offset);
+    const T* src_data = reinterpret_cast<const T*>(src.get_raw_data().data);
+
+    if constexpr (std::is_same_v<T, UInt8>) {
+        // nullmap : offset == -1 means is null at the here, set true here
+        for (int i = 0; i < new_size; ++i) {
+            data[origin_size + i] = (indices_begin[i] == -1);
+        }
+    } else {
+        // real data : offset == -1 what at is meaningless

Review Comment:
   ditto



##########
be/src/vec/columns/column_vector.cpp:
##########
@@ -324,20 +324,21 @@ void ColumnVector<T>::insert_range_from(const IColumn& src, size_t start, size_t
 template <typename T>
 void ColumnVector<T>::insert_indices_from(const IColumn& src, const int* indices_begin,
                                           const int* indices_end) {
-    const Self& src_vec = assert_cast<const Self&>(src);
     auto origin_size = size();
     auto new_size = indices_end - indices_begin;
     data.resize(origin_size + new_size);
 
-    for (int i = 0; i < new_size; ++i) {
-        int offset = indices_begin[i];
-        if constexpr (std::is_same_v<T, UInt8>) {
-            // Now Uint8 use to identify null and non null
-            // 1. nullable column : offset == -1 means is null at the here, set true here
-            // 2. real data column : offset == -1 what at is meaningless
-            data[origin_size + i] = (offset == -1) ? T {1} : src_vec.get_element(offset);
-        } else {
-            data[origin_size + i] = (offset == -1) ? T {0} : src_vec.get_element(offset);
+    const T* src_data = reinterpret_cast<const T*>(src.get_raw_data().data);
+
+    if constexpr (std::is_same_v<T, UInt8>) {
+        // nullmap : offset == -1 means is null at the here, set true here

Review Comment:
   Is the comment relevant? `offset` is missing here.



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org