You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2014/04/11 03:16:08 UTC
git commit: AMBARI-5436. Map operator displays wrong statistics for
TPC-DS Query27. (srimanth)
Repository: ambari
Updated Branches:
refs/heads/branch-1.5.1 7f551a8d8 -> 0ea91a7dc
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/0ea91a7d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0ea91a7d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0ea91a7d
Branch: refs/heads/branch-1.5.1
Commit: 0ea91a7dc55644bb7ce86bbbe2f886d93543d6cc
Parents: 7f551a8
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Thu Apr 10 18:07:01 2014 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Thu Apr 10 18:08:21 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/0ea91a7d/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/0ea91a7d/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/0ea91a7d/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);
+ });
+ });
+ });
});