Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 086EB200C29 for ; Tue, 28 Feb 2017 10:39:15 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 07024160B7C; Tue, 28 Feb 2017 09:39:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2BEC1160B6A for ; Tue, 28 Feb 2017 10:39:14 +0100 (CET) Received: (qmail 24934 invoked by uid 500); 28 Feb 2017 09:39:13 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 24925 invoked by uid 99); 28 Feb 2017 09:39:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2017 09:39:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3E1CBDFDE6; Tue, 28 Feb 2017 09:39:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pallavkul@apache.org To: commits@ambari.apache.org Message-Id: <86103ac0d9b9430480187deb16a2e09e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-20215. Select operators should not appear before fetch (pallavkul) Date: Tue, 28 Feb 2017 09:39:13 +0000 (UTC) archived-at: Tue, 28 Feb 2017 09:39:15 -0000 Repository: ambari Updated Branches: refs/heads/branch-2.5 d65a776a7 -> df22ebccc AMBARI-20215. Select operators should not appear before fetch (pallavkul) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/df22ebcc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/df22ebcc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/df22ebcc Branch: refs/heads/branch-2.5 Commit: df22ebcccfa9f1348a44fd1b013698a432e69c1e Parents: d65a776 Author: pallavkul Authored: Tue Feb 28 15:07:29 2017 +0530 Committer: pallavkul Committed: Tue Feb 28 15:08:57 2017 +0530 ---------------------------------------------------------------------- .../ui/app/utils/hive-explainer/processor.js | 67 ++++++++++++++++++++ .../ui/app/utils/hive-explainer/renderer.js | 2 +- .../ui/app/utils/hive-explainer/transformer.js | 33 ++++++---- 3 files changed, 87 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/df22ebcc/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js index a252498..48706cb 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/processor.js @@ -260,3 +260,70 @@ export function getEdgesWithCorrectedUnion(edges) { }); } + +// DANGER: impure function +// DANGER: breaks if there is a many-one / one-many connection +export function getAdjustedVerticesAndEdges(vertices, edges) { + + vertices + .filter(cVertex => ['Select Operator', 'HASHTABLEDUMMY', 'File Output Operator'].indexOf(getFirstOperatorOf(cVertex)._operator) >= 0) + .map(cVertex => edges.filter(cEdge => cEdge._target === cVertex._vertex)) + .forEach(cEdges => { + const source = vertices.find(cVertex => cEdges.some(tcEdge => cVertex._vertex === tcEdge._source)); + const target = vertices.find(cVertex => cEdges.some(tcEdge => cVertex._vertex === tcEdge._target)); + + const operatorLastOfSource = getLastOperatorOf(source); + const operatorFirstOfTarget = getFirstOperatorOf(target); + + operatorLastOfSource._groups = [ + ...(operatorLastOfSource._groups || [doCloneAndOmit(operatorLastOfSource, ['_groups'])]), + ...(operatorFirstOfTarget._groups || [doCloneAndOmit(operatorFirstOfTarget, ['_groups'])]), + ]; + target._children = operatorFirstOfTarget._children; + + target._isGroupedWith = source._vertex; + }); + + // cleanup + const adjustedVertices = vertices.filter(cVertex => cVertex._children.length > 0); + const cleanedVertices = vertices.filter(cVertex => cVertex._children.length === 0); + console.log(cleanedVertices); + + const adjustedEdges = + edges + .reduce((accumulator, cEdge) => { + const cleanedAtSourceVertex = cleanedVertices.find(cVertex => cEdge._source === cVertex._vertex); + const cleanedAtTargetVertex = cleanedVertices.find(cVertex => cEdge._target === cVertex._vertex); + if(cleanedAtSourceVertex) { + // do not add edge back + // add new edge instead + accumulator.push(Object.assign({}, cEdge, { + _source: cleanedAtSourceVertex._isGroupedWith, + _target: cEdge._target + })); + } else if(cleanedAtTargetVertex) { + // do not add edge back + } else { + accumulator.push(cEdge); + } + return accumulator; + }, []); + + return ({ + adjustedVertices, + adjustedEdges + }); +} + + +function getLastOperatorOf(vertex) { + let operator = vertex._children[0]; + while(operator._children.length > 0) { + operator = operator._children[0]; + } + return operator; +} + +function getFirstOperatorOf(vertex) { + return vertex._children[0]; +} http://git-wip-us.apache.org/repos/asf/ambari/blob/df22ebcc/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js index 196a514..f69b1d4 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js @@ -18,7 +18,7 @@ export default function doRender(data, selector, onRequestDetail) { - const width = '1200', height = '960'; + const width = '1600', height = '800'; d3.select(selector).select('*').remove(); const svg = http://git-wip-us.apache.org/repos/asf/ambari/blob/df22ebcc/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js index 01d6000..e6cf3f3 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js +++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/transformer.js @@ -17,37 +17,42 @@ */ import doEnhance from './enhancer'; -import {getProcessedVertices, getEdgesWithCorrectedUnion} from './processor'; +import {getProcessedVertices, getEdgesWithCorrectedUnion, getAdjustedVerticesAndEdges} from './processor'; export default function doTransform(data) { const plan = getTezPlan(data); const fetch = getFetchPlan(data); - const vertices = [ + let vertices = [ ...getVertices(plan), getFetchVertex(fetch) ]; - const tezEdges = getEdges(plan, vertices); - const edgesWithCorrectedUnion = getEdgesWithCorrectedUnion(tezEdges); - const edges = getEdgesWithFetch(edgesWithCorrectedUnion, vertices); + let edges = getEdges(plan, vertices); + edges = getEdgesWithCorrectedUnion(edges); + edges = getEdgesWithFetch(edges, vertices); - const enhancedVertices = doEnhance(vertices); + vertices = doEnhance(vertices); - const processedVertices = getProcessedVertices(enhancedVertices, edges); + vertices = getProcessedVertices(vertices, edges); - const verticesWithIndexOfChildren = getVerticesWithIndexOfChildren(processedVertices); + const {adjustedVertices, adjustedEdges} = getAdjustedVerticesAndEdges(vertices, edges); + vertices = adjustedVertices; + edges = adjustedEdges; - const tree = getVertexTree(edges); - const connections = getConnections(verticesWithIndexOfChildren, edges); - const treeWithOffsetY = getTreeWithOffsetAndHeight(tree, verticesWithIndexOfChildren, connections); + vertices = getVerticesWithIndexOfChildren(vertices); - const nodes = getNodes(verticesWithIndexOfChildren); + let tree = getVertexTree(edges); + + const connections = getConnections(vertices, edges); + tree = getTreeWithOffsetAndHeight(tree, vertices, connections); + + const nodes = getNodes(vertices); return ({ - vertices: verticesWithIndexOfChildren, + vertices, edges, - tree: treeWithOffsetY, + tree, nodes, connections, });