amorynan commented on code in PR #17330:
URL: https://github.com/apache/doris/pull/17330#discussion_r1123975449


##########
be/src/vec/columns/column_map.cpp:
##########
@@ -135,71 +202,166 @@ void ColumnMap::insert_indices_from(const IColumn& src, 
const int* indices_begin
     }
 }
 
+StringRef ColumnMap::serialize_value_into_arena(size_t n, Arena& arena, char 
const*& begin) const {
+    StringRef res(begin, 0);
+    auto keys_ref = keys_column->serialize_value_into_arena(n, arena, begin);
+    res.data = keys_ref.data - res.size;
+    res.size += keys_ref.size;
+    auto value_ref = values_column->serialize_value_into_arena(n, arena, 
begin);
+    res.data = value_ref.data - res.size;
+    res.size += value_ref.size;
+
+    return res;
+}
+
 const char* ColumnMap::deserialize_and_insert_from_arena(const char* pos) {
-    pos = keys->deserialize_and_insert_from_arena(pos);
-    pos = values->deserialize_and_insert_from_arena(pos);
+    pos = keys_column->deserialize_and_insert_from_arena(pos);
+    pos = values_column->deserialize_and_insert_from_arena(pos);
 
     return pos;
 }
 
 void ColumnMap::update_hash_with_value(size_t n, SipHash& hash) const {
-    keys->update_hash_with_value(n, hash);
-    values->update_hash_with_value(n, hash);
+    keys_column->update_hash_with_value(n, hash);
+    values_column->update_hash_with_value(n, hash);
 }
 
 void ColumnMap::insert_range_from(const IColumn& src, size_t start, size_t 
length) {
-    keys->insert_range_from(*assert_cast<const ColumnMap&>(src).keys, start, 
length);
-    values->insert_range_from(*assert_cast<const ColumnMap&>(src).values, 
start, length);
+    if (length == 0) {
+        return;
+    }
+
+    const ColumnMap& src_concrete = assert_cast<const ColumnMap&>(src);
+
+    if (start + length > src_concrete.get_offsets().size()) {
+        LOG(FATAL) << "Parameter out of bound in ColumnMap::insert_range_from 
method. [start("
+                   << std::to_string(start) << ") + length(" << 
std::to_string(length)
+                   << ") > offsets.size(" << 
std::to_string(src_concrete.get_offsets().size())
+                   << ")]";
+    }
+
+    size_t nested_offset = src_concrete.offset_at(start);
+    size_t nested_length = src_concrete.get_offsets()[start + length - 1] - 
nested_offset;
+
+    keys_column->insert_range_from(src_concrete.get_keys(), nested_offset, 
nested_length);
+    values_column->insert_range_from(src_concrete.get_values(), nested_offset, 
nested_length);
+
+    auto& cur_offsets = get_offsets();
+    const auto& src_offsets = src_concrete.get_offsets();
+
+    if (start == 0 && cur_offsets.empty()) {
+        cur_offsets.assign(src_offsets.begin(), src_offsets.begin() + length);
+    } else {
+        size_t old_size = cur_offsets.size();
+        // -1 is ok, because PaddedPODArray pads zeros on the left.
+        size_t prev_max_offset = cur_offsets.back();
+        cur_offsets.resize(old_size + length);
+
+        for (size_t i = 0; i < length; ++i) {
+            cur_offsets[old_size + i] = src_offsets[start + i] - nested_offset 
+ prev_max_offset;
+        }
+    }
 }
 
 ColumnPtr ColumnMap::filter(const Filter& filt, ssize_t result_size_hint) 
const {
-    return ColumnMap::create(keys->filter(filt, result_size_hint),
-                             values->filter(filt, result_size_hint));
+    auto k_arr =

Review Comment:
   yes , here may  can use nested specific column type to do filter , but I 
want to change map nested column type here in this pr, so just use array filter 
again first...



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