aakash-db commented on code in PR #51003: URL: https://github.com/apache/spark/pull/51003#discussion_r2110407703
########## sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/CoreDataflowNodeProcessor.scala: ########## @@ -0,0 +1,232 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.pipelines.graph + +import java.util.concurrent.{ConcurrentHashMap, ConcurrentLinkedQueue} + +import scala.jdk.CollectionConverters._ + +import org.apache.spark.internal.Logging +import org.apache.spark.sql.AnalysisException +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.pipelines.graph.DataflowGraphTransformer.{ + TransformNodeFailedException, + TransformNodeRetryableException +} + +/** + * Core processor that is responsible for analyzing each flow and sort the nodes in + * topological order + */ +class CoreDataflowNodeProcessor(rawGraph: DataflowGraph) { + + private val flowResolver = new FlowResolver(rawGraph) + + // Map of input identifier to resolved [[Input]]. + private val resolvedInputs = new ConcurrentHashMap[TableIdentifier, Input]() + // Map & queue of resolved flows identifiers + // queue is there to track the topological order while map is used to store the id -> flow + // mapping + private val resolvedFlowNodesMap = new ConcurrentHashMap[TableIdentifier, ResolvedFlow]() + private val resolvedFlowNodesQueue = new ConcurrentLinkedQueue[ResolvedFlow]() + + private def processUnresolvedFlow(flow: UnresolvedFlow): ResolvedFlow = { + val resolvedFlow = flowResolver.attemptResolveFlow( + flow, + rawGraph.inputIdentifiers, + resolvedInputs.asScala.toMap + ) + resolvedFlowNodesQueue.add(resolvedFlow) + resolvedFlowNodesMap.put(flow.identifier, resolvedFlow) + resolvedFlow + } + + /** + * Processes the node of the graph, re-arranging them if they are not topologically sorted. + * Takes care of resolving the flows and virtualization if needed for the nodes. + * @param node The node to process + * @param upstreamNodes Upstream nodes for the node + * @return + */ + def processNode(node: GraphElement, upstreamNodes: Seq[GraphElement]): Seq[GraphElement] = { Review Comment: I think this interface is wider to account for decomposition, which may be allowed in the future in OSS. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org