HappenLee commented on code in PR #63498:
URL: https://github.com/apache/doris/pull/63498#discussion_r3285142379


##########
be/src/core/column/predicate_column.h:
##########
@@ -293,6 +293,41 @@ class PredicateColumnType final : public 
COWHelper<IColumn, PredicateColumnType<
         }
     }
 
+    // Insert `num` entries with only length information (no actual char data).
+    // The chars buffer is zero-filled so that filter_by_selector can safely
+    // memcpy without reading meaningful content. Used in OFFSET_ONLY reading
+    // mode where only string lengths (for length() function) are needed.
+    void insert_offsets_from_lengths(const uint32_t* lengths, size_t num) 
override {
+        if constexpr (std::is_same_v<T, StringRef>) {
+            if (UNLIKELY(num == 0)) {
+                return;
+            }
+            size_t total_bytes = 0;
+            for (size_t i = 0; i < num; ++i) {
+                total_bytes += lengths[i];
+            }
+            // Allocate and zero-fill a single backing buffer so that each 
StringRef
+            // points to valid (though meaningless) memory. filter_by_selector 
will
+            // memcpy from these pointers, so they must not be null for 
non-zero lengths.
+            char* buf = total_bytes > 0 ? _arena.alloc(total_bytes) : nullptr;
+            if (total_bytes > 0) {
+                memset(buf, 0, total_bytes);
+            }
+            size_t org_elem_num = data.size();
+            data.resize(org_elem_num + num);
+            size_t offset = 0;
+            for (size_t i = 0; i < num; ++i) {
+                // For zero-length strings, data pointer is null; 
insert_many_strings
+                // and filter_by_selector both guard on size > 0 before 
dereferencing.
+                data[org_elem_num + i].data = (lengths[i] > 0) ? (buf + 
offset) : nullptr;

Review Comment:
   这里是没问题的,因为insert default就是这个行为



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to