This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch orc
in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git


The following commit(s) were added to refs/heads/orc by this push:
     new c09e9df6a04 [fix] Fix set reader category in late materialization. 
(#257)
c09e9df6a04 is described below

commit c09e9df6a04e5c48ad6c49a339d589d8c1898615
Author: Qi Chen <che...@selectdb.com>
AuthorDate: Wed Nov 27 22:05:51 2024 +0800

    [fix] Fix set reader category in late materialization. (#257)
---
 c++/src/Reader.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
index eddeeee0b05..d721867622e 100644
--- a/c++/src/Reader.cc
+++ b/c++/src/Reader.cc
@@ -340,6 +340,53 @@ namespace orc {
           throw ParseError("Invalid column selected " + colName);
         }
       }
+
+    std::unordered_set<int> filterColIds;
+    if (!filterCols.empty()) {
+      for (const auto& colName : filterCols) {
+        auto iter = nameTypeMap.find(colName);
+        if (iter == nameTypeMap.end()) {
+          throw ParseError("Invalid column selected " + colName);
+        }
+
+        Type* type = iter->second;
+
+        // Process current node and all its parent nodes
+        // Set FILTER_CHILD for leaf nodes and FILTER_PARENT for non-leaf nodes
+        Type* current = type;
+        while (current != nullptr) {
+          if (current->getSubtypeCount() == 0) {
+            current->setReaderCategory(ReaderCategory::FILTER_CHILD);
+          } else {
+            current->setReaderCategory(ReaderCategory::FILTER_PARENT);
+          }
+          filterColIds.emplace(current->getColumnId());
+          current = current->getParent();
+        }
+
+        // Process all child nodes of the current node
+        // For child nodes: set FILTER_PARENT if it's a leaf, FILTER_CHILD if 
it has children
+        std::function<void(Type*)> processChildren = [&processChildren](Type* 
node) {
+          if (node == nullptr) return;
+
+          // Iterate through all child nodes
+          for (int i = 0; i < node->getSubtypeCount(); ++i) {
+            Type* child = node->getSubtype(i);
+            if (child->getSubtypeCount() == 0) {
+              // Leaf node (no children)
+              child->setReaderCategory(ReaderCategory::FILTER_PARENT);
+            } else {
+              // Non-leaf node (has children)
+              child->setReaderCategory(ReaderCategory::FILTER_CHILD);
+              // Recursively process its children
+              processChildren(child);
+            }
+          }
+        };
+
+        processChildren(type);
+      }
+
       startReadPhase = ReadPhase::LEADERS;
       readerContext = std::unique_ptr<ReaderContext>(new ReaderContext());
       readerContext->setFilterCallback(std::move(filterColIds), filter);


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

Reply via email to