You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "beliefer (via GitHub)" <gi...@apache.org> on 2025/09/23 09:10:49 UTC

Re: [PR] [GLUTEN-10770] Code cleanup for toVeloxPlan with ProjectRel [incubator-gluten]

beliefer commented on code in PR #10771:
URL: https://github.com/apache/incubator-gluten/pull/10771#discussion_r2371661872


##########
cpp/velox/substrait/SubstraitToVeloxPlan.cc:
##########
@@ -475,27 +475,30 @@ core::PlanNodePtr SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
     const auto& fieldName = inputType->nameOf(idx);
     projectNames.emplace_back(fieldName);
     expressions.emplace_back(std::make_shared<core::FieldAccessTypedExpr>(inputType->childAt(idx), fieldName));
-    colIdx += 1;
   }
 
   // Then, adding project expression related project names and expressions.
-  for (const auto& expr : projectExprs) {
-    expressions.emplace_back(exprConverter_->toVeloxExpr(expr, inputType));
-    projectNames.emplace_back(SubstraitParser::makeNodeName(planNodeId_, colIdx));
-    colIdx += 1;
+  const size_t startIdx = expressions.size();
+  for (int i = 0; i < projectExprs.size(); i++) {
+    expressions.emplace_back(exprConverter_->toVeloxExpr(projectExprs[i], inputType));
+    projectNames.emplace_back(SubstraitParser::makeNodeName(planNodeId_, startIdx + i));
   }
 
   if (projectRel.has_common()) {
     auto relCommon = projectRel.common();
     const auto& emit = relCommon.emit();
     int emitSize = emit.output_mapping_size();
-    std::vector<std::string> emitProjectNames(emitSize);
-    std::vector<core::TypedExprPtr> emitExpressions(emitSize);
+    std::vector<std::string> emitProjectNames;
+    std::vector<core::TypedExprPtr> emitExpressions;
+    emitProjectNames.reserve(emitSize);
+    emitExpressions.reserve(emitSize);
+
     for (int i = 0; i < emitSize; i++) {
       int32_t mapId = emit.output_mapping(i);
-      emitProjectNames[i] = projectNames[mapId];
-      emitExpressions[i] = expressions[mapId];
+      emitProjectNames.emplace_back(std::move(projectNames[mapId]));
+      emitExpressions.emplace_back(std::move(expressions[mapId]));

Review Comment:
   Got it. The title updated.



-- 
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-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org