ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject git commit: AMBARI-5436. Map operator displays wrong statistics for TPC-DS Query27. (srimanth)
Date Fri, 11 Apr 2014 01:21:15 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 93dbf2ba7 -> 2ada153e0


AMBARI-5436. Map operator displays wrong statistics for TPC-DS Query27. (srimanth)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2ada153e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2ada153e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2ada153e

Branch: refs/heads/trunk
Commit: 2ada153e0675d8511d73244182b908653e5b08f5
Parents: 93dbf2b
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Thu Apr 10 18:07:01 2014 -0700
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Thu Apr 10 18:20:56 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/utils/helper.js                  | 65 ++++++++++------
 .../main/jobs/hive_job_details_tez_dag_view.js  | 30 ++++---
 ambari-web/test/utils/string_utils_test.js      | 82 ++++++++++++++++++++
 3 files changed, 142 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2ada153e/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index 1bedd4e..26ec0f1 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -36,34 +36,51 @@ String.prototype.capitalize = function () {
   return this.charAt(0).toUpperCase() + this.slice(1);
 };
 
-// Use: stringvalue.findIn(multi_dimensional_array_or_object)
-/***Example:
- var tofind = 'emotion';
- var person = {'name': 'Bob Loblaw', 'age': '28', 'personality': {'smart': 'yes', 'funny':
'yes', 'emotion': 'happy'} };
- tofind.findIn(person)
- ***/
-String.prototype.findIn = function (multi) {
+/**
+ * Finds the value in an object where this string is a key.
+ * Optionally, the index of the key can be provided where the
+ * value of the nth key in the hierarchy is returned.
+ *
+ * Example:
+ *  var tofind = 'smart';
+ *  var person = {'name': 'Bob Bob', 'smart': 'no', 'age': '28', 'personality': {'smart':
'yes', 'funny': 'yes', 'emotion': 'happy'} };
+ *  tofind.findIn(person); // 'no'
+ *  tofind.findIn(person, 0); // 'no'
+ *  tofind.findIn(person, 1); // 'yes'
+ *  tofind.findIn(person, 2); // null
+ *
+ *  @param multi  Object
+ *  @param index  Occurrence count of this key
+ *  @return Value of key at given index
+ */
+String.prototype.findIn = function(multi, index, _foundValues) {
+  if (!index) {
+    index = 0;
+  }
+  if (!_foundValues) {
+    _foundValues = [];
+  }
   multi = multi || '';
-  var val = this.valueOf();
-  if(typeof multi == 'object' || typeof multi == 'array')
-  {
-    if(val in multi)
-    {
-      return multi[val];
-    }
-    else
-    {
-      for(var x in multi)
-      {
-        var found = this.findIn(multi[x]);
-        if(found != false)
-        {
-          return found;
-        }
+  var value = null;
+  var str = this.valueOf();
+  if (typeof multi == 'object') {
+    for ( var key in multi) {
+      if (value != null) {
+        break;
+      }
+      if (key == str) {
+        _foundValues.push(multi[key]);
+      }
+      if (_foundValues.length - 1 == index) {
+        // Found the value
+        return _foundValues[index];
+      }
+      if (typeof multi[key] == 'object') {
+        value = value || this.findIn(multi[key], index, _foundValues);
       }
     }
   }
-  return false;
+  return value;
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ada153e/ambari-web/app/views/main/jobs/hive_job_details_tez_dag_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/jobs/hive_job_details_tez_dag_view.js b/ambari-web/app/views/main/jobs/hive_job_details_tez_dag_view.js
index ad1b5af..1b761f9 100644
--- a/ambari-web/app/views/main/jobs/hive_job_details_tez_dag_view.js
+++ b/ambari-web/app/views/main/jobs/hive_job_details_tez_dag_view.js
@@ -292,20 +292,27 @@ App.MainHiveJobDetailsTezDagView = Em.View.extend({
       'content.tezDag.vertices.@each.recordReadCount', 'content.tezDag.vertices.@each.recordWriteCount',
       'content.tezDag.vertices.@each.state', 'content.tezDag.vertices.@each.spilledRecords'),
 
-  createOperationPlanObj: function (vertexName, op) {
+  createOperationPlanObj: function (vertexName, op, opIndex) {
     var operatorPlanObj = [];
     var text = this.get('content.tezDag.vertices').findProperty('name', vertexName).get('operationPlan');
     text = text.replace(/:"/g,'"').replace(/([:,])(?=\S)/g,'$1 ');
     var jsonText =  $.parseJSON(text);
-    var jsonText = op.findIn(jsonText);
-    for (var key in jsonText) {
-      if (jsonText.hasOwnProperty(key) && typeof(jsonText[key]) == "string") {
-        operatorPlanObj.push(
-          {
-            name: key,
-            value: jsonText[key]
-          }
-        );
+    if (!opIndex) {
+      opIndex = 0;
+    } else {
+      opIndex = parseInt(opIndex) - 1;
+    }
+    var jsonText = op.findIn(jsonText, opIndex);
+    if (jsonText!=null) {
+      for (var key in jsonText) {
+        if (jsonText.hasOwnProperty(key) && typeof(jsonText[key]) == "string") {
+          operatorPlanObj.push(
+              {
+                name: key,
+                value: jsonText[key]
+              }
+          );
+        }
       }
     }
     return operatorPlanObj;
@@ -670,7 +677,8 @@ App.MainHiveJobDetailsTezDagView = Em.View.extend({
             operationName: op,
             operatorPlanObj: []
           };
-          var operatorPlanObj = self.createOperationPlanObj(n.name, op);
+          var opIndex = this.getAttribute('opIndex');
+          var operatorPlanObj = self.createOperationPlanObj(n.name, op, opIndex);
           viewContent.operatorPlanObj = operatorPlanObj;
           var template = App.HoverOpTable.create({content: viewContent}) ;
           $(this).find('.svg-tooltip').attr('title', template.renderToBuffer().string()).tooltip('fixTitle').tooltip('show');

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ada153e/ambari-web/test/utils/string_utils_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/string_utils_test.js b/ambari-web/test/utils/string_utils_test.js
index 3079c6d..9fb5095 100644
--- a/ambari-web/test/utils/string_utils_test.js
+++ b/ambari-web/test/utils/string_utils_test.js
@@ -17,6 +17,7 @@
  */
 
 var string_utils = require('utils/string_utils');
+require('utils/helper');
 
 describe('string_utils', function () {
 
@@ -152,4 +153,85 @@ describe('string_utils', function () {
       });
     });
   });
+
+  describe('#findIn', function () {
+    var tests = [
+      {
+        obj: {
+          a: '1',
+          b: '2'
+        },
+        key: 'a',
+        index: 0,
+        e: '1'
+      }, {
+        obj: {
+          a: '1',
+          b: '2'
+        },
+        key: 'a',
+        index: 1,
+        e: null
+      }, {
+        obj: {
+          a: '1',
+          b: '2',
+          c: {
+            a: '11',
+            aa: '12'
+          }
+        },
+        key: 'a',
+        index: 1,
+        e: '11'
+      }, {
+        obj: {
+          a: '1',
+          b: '2',
+          c: {
+            a: '11',
+            aa: {
+              a: '22'
+            }
+          }
+        },
+        key: 'a',
+        index: 2,
+        e: '22'
+      }, {
+        obj: {
+          a: '1',
+          b: '2',
+          c: {
+            a: '11',
+            aa: {
+              a: '22'
+            }
+          }
+        },
+        key: 'a',
+        index: 0,
+        e: '1'
+      }, {
+        obj: {
+          a: '1',
+          b: '2',
+          c: {
+            a: '11',
+            aa: {
+              a: '22'
+            }
+          }
+        },
+        key: 'g',
+        index: 0,
+        e: null
+      }
+    ];
+    tests.forEach(function(test) {
+      it(test.key + ' @ ' + test.index + ' = ' + test.e, function () {
+        expect(test.key.findIn(test.obj, test.index)).to.equal(test.e);
+      });
+    });
+  });
 });


Mime
View raw message