ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pallav...@apache.org
Subject ambari git commit: AMBARI-20215. Select operators should not appear before fetch (pallavkul)
Date Tue, 28 Feb 2017 09:39:13 GMT
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 <pallav.kul@gmail.com>
Authored: Tue Feb 28 15:07:29 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
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,
   });


Mime
View raw message