TsukiokaKogane commented on code in PR #64776:
URL: https://github.com/apache/doris/pull/64776#discussion_r3506611051


##########
be/src/storage/segment/column_reader.h:
##########
@@ -865,5 +873,91 @@ class DefaultValueColumnIterator : public ColumnIterator {
     ordinal_t _current_rowid = 0;
 };
 
+// Produces a column whose every row is the same constant Field value.
+// Used for read-time-filled constant hidden columns (e.g. 
__DORIS_COMMIT_TSO_COL__),
+// where the on-disk value is only a placeholder and the real value comes from 
the read
+// context (StorageReadOptions). Reuses insert_duplicate_fields /
+// convert_to_predicate_column_if_dictionary so predicate / nullable / 
dictionary target
+// columns are all handled uniformly.
+class ConstantColumnIterator : public ColumnIterator {
+public:
+    ConstantColumnIterator() = delete;
+    explicit ConstantColumnIterator(Field value) : _value(std::move(value)) {}
+
+    Status seek_to_ordinal(ordinal_t ord_idx) override {
+        _current_rowid = ord_idx;
+        return Status::OK();
+    }
+
+    Status next_batch(size_t* n, MutableColumnPtr& dst) {
+        bool has_null;
+        return next_batch(n, dst, &has_null);
+    }
+
+    Status next_batch(size_t* n, MutableColumnPtr& dst, bool* has_null) 
override {
+        *has_null = _value.is_null();
+        _insert_many(dst, *n);
+        _current_rowid += *n;
+        return Status::OK();
+    }
+
+    Status next_batch_of_zone_map(size_t* n, MutableColumnPtr& dst) override {
+        return next_batch(n, dst);
+    }
+
+    Status read_by_rowids(const rowid_t* rowids, const size_t count,
+                          MutableColumnPtr& dst) override {
+        _insert_many(dst, count);
+        return Status::OK();
+    }
+
+    ordinal_t get_current_ordinal() const override { return _current_rowid; }
+
+private:
+    void _insert_many(MutableColumnPtr& dst, size_t n) {
+        if (_value.is_null()) {
+            dst->insert_many_defaults(n);

Review Comment:
   fixed



##########
be/src/storage/segment/column_reader.cpp:
##########
@@ -476,6 +480,18 @@ Status ColumnReader::match_condition(const 
AndBlockColumnPredicate* col_predicat
     return Status::OK();
 }
 
+Status ConstantColumnReader::match_condition(const AndBlockColumnPredicate* 
col_predicates,
+                                             bool* matched) const {
+    ZoneMap zone_map;
+    zone_map.min_value = _value;
+    zone_map.max_value = _value;
+    zone_map.has_not_null = true;

Review Comment:
   fixed



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