csun5285 commented on code in PR #64128:
URL: https://github.com/apache/doris/pull/64128#discussion_r3410624276


##########
be/src/core/column/column_execute_util.h:
##########
@@ -32,27 +36,55 @@ namespace doris {
 
 // Utility tools for convenient column execution
 
-// ColumnElementView is used to distinguish between scalar columns and string 
columns
+// Per-row read view over a column.  The pointer returned by ptr_at on the
+// string specialization is valid only until the next ptr_at call.
+namespace detail {
+
 template <PrimitiveType PType>
-struct ColumnElementView {
+struct NumericElementView {
     using ColumnType = typename PrimitiveTypeTraits<PType>::ColumnType;
     using ElementType = typename ColumnType::value_type;
     const typename ColumnType::Container& data;
-    ElementType get_element(size_t idx) const { return data[idx]; }
-    const ElementType* get_data() const { return data.data(); }
 
-    ColumnElementView(const IColumn& column)
+    NumericElementView(const IColumn& column)
             : data(assert_cast<const ColumnType&>(column).get_data()) {}
+
+    ElementType get_element(size_t idx) const { return data[idx]; }
+    const ElementType* get_data() const { return data.data(); }
+    ElementType operator[](size_t idx) const { return data[idx]; }
+    const ElementType* ptr_at(size_t idx) const { return data.data() + idx; }
+    size_t size() const { return data.size(); }
 };
 
-template <>
-struct ColumnElementView<TYPE_STRING> {
+struct StringElementView {
     using ColumnType = ColumnString;
     using ElementType = StringRef;
     const ColumnString& string_column;
-    ColumnElementView(const IColumn& column)
+    mutable StringRef _cell {}; // staging for ptr_at
+
+    StringElementView(const IColumn& column)
             : string_column(assert_cast<const ColumnString&>(column)) {}
+
     StringRef get_element(size_t idx) const { return 
string_column.get_data_at(idx); }
+    StringRef operator[](size_t idx) const { return 
string_column.get_data_at(idx); }
+    const StringRef* ptr_at(size_t idx) const {
+        _cell = string_column.get_data_at(idx);
+        return &_cell;
+    }
+    size_t size() const { return string_column.size(); }
+};
+
+} // namespace detail
+
+template <PrimitiveType PType>
+using ColumnElementView = std::conditional_t<is_string_type(PType), 
detail::StringElementView,

Review Comment:
   array 有 ArrayDataView,map,struct 没有。



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