diff --git a/presto-ui/src/components/QueryStageView.jsx b/presto-ui/src/components/QueryStageView.jsx index 95a220330700f..7d9ceac924727 100644 --- a/presto-ui/src/components/QueryStageView.jsx +++ b/presto-ui/src/components/QueryStageView.jsx @@ -334,45 +334,14 @@ function StageOperatorGraph({ id, stage }) { const detailContainer = React.useRef(null); - const computeOperatorMap = () => { - const operatorMap = new Map(); - stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => { - if (!operatorMap.has(operator.planNodeId)) { - operatorMap.set(operator.planNodeId, []) - } - - operatorMap.get(operator.planNodeId).push(operator); - }); - - return operatorMap; - }; - - const computeOperatorGraphs = (planNode, operatorMap) => { - const sources = getChildren(planNode); - const sourceResults = new Map(); - sources.forEach(source => { - const sourceResult = computeOperatorGraphs(source, operatorMap); - sourceResult.forEach((operator, pipelineId) => { - if (sourceResults.has(pipelineId)) { - console.error("Multiple sources for ", planNode['@type'], " had the same pipeline ID"); - return sourceResults; - } - sourceResults.set(pipelineId, operator); - }); - }); - - let nodeOperators = operatorMap.get(planNode.id); - if (!nodeOperators || nodeOperators.length === 0) { - return sourceResults; - } - + const computeOperatorGraphs = () => { const pipelineOperators = new Map(); - nodeOperators.forEach(operator => { + stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => { if (!pipelineOperators.has(operator.pipelineId)) { pipelineOperators.set(operator.pipelineId, []); } pipelineOperators.get(operator.pipelineId).push(operator); - }); + }); const result = new Map(); pipelineOperators.forEach((pipelineOperators, pipelineId) => { @@ -381,13 +350,6 @@ function StageOperatorGraph({ id, stage }) { const sinkOperator = linkedOperators[linkedOperators.length - 1]; const sourceOperator = linkedOperators[0]; - if (sourceResults.has(pipelineId)) { - const pipelineChildResult = sourceResults.get(pipelineId); - if (pipelineChildResult) { - sourceOperator.child = pipelineChildResult; - } - } - // chain operators at this level let currentOperator = sourceOperator; linkedOperators.slice(1).forEach(source => { @@ -398,12 +360,6 @@ function StageOperatorGraph({ id, stage }) { result.set(pipelineId, sinkOperator); }); - sourceResults.forEach((operator, pipelineId) => { - if (!result.has(pipelineId)) { - result.set(pipelineId, operator); - } - }); - return result; }; @@ -411,8 +367,8 @@ function StageOperatorGraph({ id, stage }) { if (!stage) { return; } - const operatorMap = computeOperatorMap(); - const operatorGraphs = computeOperatorGraphs(stage.plan.root, operatorMap); + + const operatorGraphs = computeOperatorGraphs(); const graph = initializeGraph(); operatorGraphs.forEach((operator, pipelineId) => { diff --git a/presto-ui/src/components/StageDetail.jsx b/presto-ui/src/components/StageDetail.jsx index dda2cac5590d3..b940ddc53e5d6 100644 --- a/presto-ui/src/components/StageDetail.jsx +++ b/presto-ui/src/components/StageDetail.jsx @@ -372,33 +372,14 @@ class StageOperatorGraph extends React.Component { document.getElementById('operator-detail')); } - computeOperatorGraphs(planNode, operatorMap) { - const sources = getChildren(planNode); - - const sourceResults = new Map(); - sources.forEach(source => { - const sourceResult = this.computeOperatorGraphs(source, operatorMap); - sourceResult.forEach((operator, pipelineId) => { - if (sourceResults.has(pipelineId)) { - console.error("Multiple sources for ", planNode['@type'], " had the same pipeline ID"); - return sourceResults; - } - sourceResults.set(pipelineId, operator); - }); - }); - - let nodeOperators = operatorMap.get(planNode.id); - if (!nodeOperators || nodeOperators.length === 0) { - return sourceResults; - } - + computeOperatorGraphs() { const pipelineOperators = new Map(); - nodeOperators.forEach(operator => { + this.props.stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => { if (!pipelineOperators.has(operator.pipelineId)) { pipelineOperators.set(operator.pipelineId, []); } pipelineOperators.get(operator.pipelineId).push(operator); - }); + }); const result = new Map(); pipelineOperators.forEach((pipelineOperators, pipelineId) => { @@ -407,13 +388,6 @@ class StageOperatorGraph extends React.Component { const sinkOperator = linkedOperators[linkedOperators.length - 1]; const sourceOperator = linkedOperators[0]; - if (sourceResults.has(pipelineId)) { - const pipelineChildResult = sourceResults.get(pipelineId); - if (pipelineChildResult) { - sourceOperator.child = pipelineChildResult; - } - } - // chain operators at this level let currentOperator = sourceOperator; linkedOperators.slice(1).forEach(source => { @@ -424,28 +398,9 @@ class StageOperatorGraph extends React.Component { result.set(pipelineId, sinkOperator); }); - sourceResults.forEach((operator, pipelineId) => { - if (!result.has(pipelineId)) { - result.set(pipelineId, operator); - } - }); - return result; } - computeOperatorMap() { - const operatorMap = new Map(); - this.props.stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => { - if (!operatorMap.has(operator.planNodeId)) { - operatorMap.set(operator.planNodeId, []) - } - - operatorMap.get(operator.planNodeId).push(operator); - }); - - return operatorMap; - } - computeD3StageOperatorGraph(graph, operator, sink, pipelineNode) { const operatorNodeId = "operator-" + operator.pipelineId + "-" + operator.operatorId; @@ -469,9 +424,7 @@ class StageOperatorGraph extends React.Component { return; } - const stage = this.props.stage; - const operatorMap = this.computeOperatorMap(); - const operatorGraphs = this.computeOperatorGraphs(stage.plan.root, operatorMap); + const operatorGraphs = this.computeOperatorGraphs(); const graph = initializeGraph(); operatorGraphs.forEach((operator, pipelineId) => {