ソースを参照

HUE-8704 [jb] Fixed profile with missing stats.

jdesjean 6 年 前
コミット
9c8c32cd33

+ 4 - 0
desktop/libs/libanalyze/src/libanalyze/models.py

@@ -63,6 +63,10 @@ def query_node_by_id(profile, node_id, metric_name, averaged=False):
 
   return map(lambda x: L(x['value'], x['unit'], 0, x['node'].fragment.id(), x['node'].host(), 0, x['node'].id(), x['node'].name(), value=x['value'], unit=x['unit'], fragment_id=0, fid=x['node'].fragment.id(), host=x['node'].host(), node_id=x['node'].id(), name=x['node'].name(), node=x['node']), metric)
 
+def query_node_by_id_value(profile, node_id, metric_name, averaged=False, default=0):
+  results = query_node_by_id(profile, node_id, metric_name, averaged)
+  return results and results[0][0] or default
+
 def _filter_averaged(result, averaged=False):
   #nodes = filter(lambda x: x.fragment.is_averaged() == averaged, result)
   # Averaged results are not always present. If we're looking for averaged results, sort by averaged and get first result (hopefully getting averaged!).

+ 10 - 10
desktop/libs/libanalyze/src/libanalyze/rules.py

@@ -261,10 +261,10 @@ class JoinOrderStrategyCheck(SQLOperatorReason):
         """
         self.metric_names = ["Hosts", "Broadcast", "BuildRows", "ProbeRows"]
 
-        hosts = models.query_node_by_id(profile, plan_node_id, "Hosts", True)[0][0]
-        isBroadcast = models.query_node_by_id(profile, plan_node_id, "Broadcast", True)[0][0]
-        buildRows = models.query_node_by_id(profile, plan_node_id, "BuildRows", True)[0][0]
-        probeRows = models.query_node_by_id(profile, plan_node_id, "ProbeRows", True)[0][0]
+        hosts = models.query_node_by_id_value(profile, plan_node_id, "Hosts", True)
+        isBroadcast = models.query_node_by_id_value(profile, plan_node_id, "Broadcast", True)
+        buildRows = models.query_node_by_id_value(profile, plan_node_id, "BuildRows", True)
+        probeRows = models.query_node_by_id_value(profile, plan_node_id, "ProbeRows", True)
 
         rhsRows = 0
         lhsRows = 0
@@ -311,10 +311,10 @@ class ExplodingJoinCheck(SQLOperatorReason):
         """
         self.metric_names = ["Hosts", "Broadcast", "BuildRows", "ProbeRows"]
 
-        hosts = models.query_node_by_id(profile, plan_node_id, "Hosts", True)[0][0]
-        probeRows = models.query_node_by_id(profile, plan_node_id, "ProbeRows", True)[0][0]
-        probeTime = models.query_node_by_id(profile, plan_node_id, "ProbeTime", True)[0][0]
-        rowsReturned = models.query_node_by_id(profile, plan_node_id, "RowsReturned", True)[0][0]
+        hosts = models.query_node_by_id_value(profile, plan_node_id, "Hosts", True)
+        probeRows = models.query_node_by_id_value(profile, plan_node_id, "ProbeRows", True)
+        probeTime = models.query_node_by_id_value(profile, plan_node_id, "ProbeTime", True)
+        rowsReturned = models.query_node_by_id_value(profile, plan_node_id, "RowsReturned", True)
 
         impact = 0
         if (rowsReturned > 0):
@@ -340,8 +340,8 @@ class NNRpcCheck(SQLOperatorReason):
         :return:
         """
         totalStorageTime = models.query_avg_fragment_metric_by_node_nid(profile, plan_node_id, "TotalStorageWaitTime", 0)
-        hdfsRawReadTime = models.query_node_by_id(profile, plan_node_id, "TotalRawHdfsReadTime(*)", True)[0][0]
-        avgReadThreads = models.query_node_by_id(profile, plan_node_id, "AverageHdfsReadThreadConcurrency", True)[0][0]
+        hdfsRawReadTime = models.query_node_by_id_value(profile, plan_node_id, "TotalRawHdfsReadTime(*)", True)
+        avgReadThreads = models.query_node_by_id_value(profile, plan_node_id, "AverageHdfsReadThreadConcurrency", True)
         avgReadThreads = max(1, to_double(avgReadThreads))
         impact = max(0, (totalStorageTime - hdfsRawReadTime) / avgReadThreads)
         return {