You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by se...@apache.org on 2017/05/10 22:49:41 UTC

[3/7] incubator-trafodion git commit: [TRAFODION-2420] RMS enhancements

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_hashj.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_hashj.cpp b/core/sql/executor/ex_hashj.cpp
index 1828a0f..dd783eb 100644
--- a/core/sql/executor/ex_hashj.cpp
+++ b/core/sql/executor/ex_hashj.cpp
@@ -131,6 +131,14 @@ digraph hasjoin {
 }
 */
 
+// In the reverse order of ex_hashj_tcb::HashJoinPhase
+const char *ex_hashj_tcb::HashJoinPhaseStr[] = {
+    "PHASE_END",
+    "PHASE_3",
+    "PHASE_2",
+    "PHASE_1"
+};
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 //  TDB procedures
@@ -1161,7 +1169,7 @@ ExWorkProcRetcode ex_hashj_tcb::workDown() {
 	// If new input matches the previous input, then reuse the old hash-table
 	if ( will_reuse_old_HT = isSameInputAgain(downParentEntry) ) {
 	  // the hash table is already prepared. Go on with phase 2 of the join
-	  pstate.setPhase(PHASE_2);
+	  pstate.setPhase(PHASE_2, bmoStats_);
 	  pstate.usePreviousHT();
 	  pstate.reliesOnIdx = prevReqIdx_;
 	  pstate.setState(HASHJ_READ_OUTER); // all set to start reading the outer
@@ -1226,7 +1234,7 @@ ExWorkProcRetcode ex_hashj_tcb::workDown() {
 	  // Even though we reuse, still need to finish up few things before
 	  // phase two; e.g., handle delayed or non-delayed left request
 	  pstate.setState(HASHJ_END_PHASE_1);
-	  pstate.setPhase(PHASE_1);  // needed ?  just in case ...
+	  pstate.setPhase(PHASE_1, bmoStats_);  // needed ?  just in case ...
 	}
 	else { // no reuse
 	  // Change the request: only one row from the right child is needed
@@ -1647,7 +1655,7 @@ short ex_hashj_tcb::workReadInner() {
 
   switch (rightEntry->upState.status) {
   case ex_queue::Q_OK_MMORE: {
-   
+
     if ( isAllOrNothing_ ) {  // Special case: AntiSemi HJ, no search expr
       pstate.setReadRightRow(); // this request actualy read a row from the right
       anyRightRowsRead_ = TRUE ; // Got a right row --> left rows are not needed !!
@@ -2033,9 +2041,8 @@ void ex_hashj_tcb::workEndPhase1() {
   } // if logDiagnostics
 
 #endif
-
   // all clusters are prepared. Go on with phase 2 of the join
-  pstate.setPhase(PHASE_2);
+  pstate.setPhase(PHASE_2, bmoStats_);
 
   // from now on, we want to charge the next phase with time
   if (hashJoinStats_)
@@ -2370,7 +2377,7 @@ void ex_hashj_tcb::workEndPhase2() {
   // all clusters are prepared. Go on with phase 3 of the join
   // set the first inner cluster to read
   clusterDb_->setClusterToRead(clusterDb_->getClusterList());
-  pstate.setPhase(PHASE_3);
+  pstate.setPhase(PHASE_3, bmoStats_);
   // from now on, we want to charge the next phase with time
   if (hashJoinStats_)
     hashJoinStats_->incPhase();
@@ -2545,6 +2552,9 @@ short ex_hashj_tcb::workProbe() {
     workAtp_->getTupp(hashJoinTdb().extRightRowAtpIndex1_).
       setDataPointer(hashRow->getData());
 
+    if (bmoStats_)
+       bmoStats_->incInterimRowCount();
+
     // evaluate beforeJoinPredicate
     beforeJoinPred = phase2 ? beforeJoinPred1_ : beforeJoinPred2_ ;
 
@@ -2566,7 +2576,7 @@ short ex_hashj_tcb::workProbe() {
     // if right-outer join, mark this right row
     if (isRightJoin())  
       hashRow->setBit(TRUE);
-
+   
     // if this is a left outer join or semi join and if we are in a hash loop,
     // the outer cluster has a bitmap. Update this bitmap now
     if( oCluster && oCluster->hasBitMap() )  oCluster->updateBitMap();
@@ -3482,7 +3492,7 @@ ExWorkProcRetcode ExUniqueHashJoinTcb::workUp()
           else
             {
               pstate.setState(HASHJ_READ_OUTER);
-	      pstate.setPhase(PHASE_2);
+	      pstate.setPhase(PHASE_2, bmoStats_);
 
               // from now on, we want to charge the next phase with time
               if (hashJoinStats_)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_hashj.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_hashj.h b/core/sql/executor/ex_hashj.h
index b22a95f..c2e5130 100644
--- a/core/sql/executor/ex_hashj.h
+++ b/core/sql/executor/ex_hashj.h
@@ -39,7 +39,7 @@
  */
 
 #include "cluster.h"
-
+#include "ExStats.h"
 /////////////////////////////////////////////////////////////////////////////
 // Task Definition Block
 // for a description of the expressions see GerRelJoin.C
@@ -110,8 +110,6 @@ private:
   // ---------------------------------------------------------------------
 };
 
-
-
 /////////////////////////////////////////////////////
 // Task control block
 /////////////////////////////////////////////////////
@@ -162,11 +160,17 @@ public:
   };
 
   // the phase of the hash join algorithm
+  // Change ex_hashj_tcb::HashJoinPhaseStr when you add new value to this enum
+  // New phase enum value should be added before PHASE_END
   enum HashJoinPhase {
     PHASE_1,
     PHASE_2,
-    PHASE_3
+    PHASE_3,
+    PHASE_END
   };
+
+  static const char *HashJoinPhaseStr[];
+
   virtual NA_EIDPROC NABoolean needStatsEntry();
   virtual NA_EIDPROC ExOperStats *doAllocateStatsEntry(CollHeap *heap,
                                                        ComTdb *tdb);
@@ -451,7 +455,7 @@ public:
   inline ex_hashj_tcb::HashJoinState getState();
   inline void setOldState(ex_hashj_tcb::HashJoinState state);
   inline ex_hashj_tcb::HashJoinState getOldState();
-  inline void setPhase(ex_hashj_tcb::HashJoinPhase phase);
+  inline void setPhase(ex_hashj_tcb::HashJoinPhase phase, ExBMOStats *bmoStats);
   inline ex_hashj_tcb::HashJoinPhase getPhase();
   inline void usePreviousHT();
   inline NABoolean usingPreviousHT();
@@ -487,8 +491,10 @@ inline ex_hashj_tcb::HashJoinState ex_hashj_private_state::getOldState() {
   return (oldState_);
 }
 
-inline void ex_hashj_private_state::setPhase(ex_hashj_tcb::HashJoinPhase phase) {
+inline void ex_hashj_private_state::setPhase(ex_hashj_tcb::HashJoinPhase phase, ExBMOStats *bmoStats) {
   phase_ = phase;
+  if (bmoStats)
+     bmoStats->setBmoPhase(ex_hashj_tcb::HashJoinPhase::PHASE_END-phase);
 }
 
 inline ex_hashj_tcb::HashJoinPhase ex_hashj_private_state::getPhase() {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_sort.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_sort.cpp b/core/sql/executor/ex_sort.cpp
index b56cdce..1482bb9 100644
--- a/core/sql/executor/ex_sort.cpp
+++ b/core/sql/executor/ex_sort.cpp
@@ -55,6 +55,14 @@
 void ReleaseTupp(void * td);
 void CaptureTupp(void * td);
 
+// Dont exceed more than 11 characters
+const char *ExSortTcb::SortPhaseStr[] = {
+  "SORT_PREP",
+  "SORT_SEND",
+  "SORT_RECV",
+  "SORT_MERGE"
+};
+
 NABoolean ExSortTcb::needStatsEntry()
 {
   ComTdb::CollectStatsType statsType = getGlobals()->getStatsArea()->getCollectStatsType();
@@ -685,7 +693,8 @@ short ExSortTcb::workUp()
 		sortDiag_ = NULL;              // reset
                 // LCOV_EXCL_STOP
 	      }
-	    
+	    if (bmoStats_)
+               bmoStats_->setBmoPhase(SORT_PHASE_END-SORT_PREP_PHASE);
 	    setupPoolBuffers(pentry_down);
  
       if((request == ex_queue::GET_N) &&
@@ -737,6 +746,8 @@ short ExSortTcb::workUp()
 	    ex_queue_entry * centry = qchild_.up->getHeadEntry();
 	    ex_queue::up_status child_status = centry->upState.status;
 	    ex_queue_entry *upEntry = qparent_.up->getTailEntry();
+	    if (bmoStats_)
+               bmoStats_->setBmoPhase(SORT_PHASE_END-SORT_SEND_PHASE); 
 	    
 	    rc = sortSend(centry, child_status, pentry_down, upEntry, 
 			  FALSE, // not sort from top
@@ -846,6 +857,8 @@ short ExSortTcb::workUp()
 	    if (qparent_.up->isFull()){
 	      return workStatus(WORK_OK); // parent queue is full. Just return
 	    }
+	    if (bmoStats_)
+               bmoStats_->setBmoPhase(SORT_PHASE_END-SORT_RECV_PHASE); 
 
 	    ex_queue_entry * pentry = qparent_.up->getTailEntry();
 	    rc = sortReceive(pentry_down, request, pentry, FALSE,
@@ -1279,6 +1292,8 @@ short ExSortTcb::sortSend(ex_queue_entry * srcEntry,
 		  }
 	      }
 	  }
+        if (bmoStats_)
+           bmoStats_->incInterimRowCount();
 	// LCOV_EXCL_STOP
 	rc = sortUtil_->sortSend(dataPointer,
 				 newRecLen,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/executor/ex_sort.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_sort.h b/core/sql/executor/ex_sort.h
index 72229cd..4822aea 100644
--- a/core/sql/executor/ex_sort.h
+++ b/core/sql/executor/ex_sort.h
@@ -136,7 +136,17 @@ public:
     SORT_CANCEL_CHILD,
     SORT_DONE_WITH_QND
     };
-  
+
+  // Change ExSortTcb::SortPhaseStr[] when a new value is added to this enum
+  // Add new value before SORT_PHASE_END
+  enum SortPhase  {
+    SORT_PREP_PHASE,
+    SORT_SEND_PHASE,
+    SORT_RECV_PHASE,
+    SORT_MERGE_PHASE,
+    SORT_PHASE_END
+  };
+  static const char *SortPhaseStr[];
 protected:
   friend class   ExSortTdb;
   friend class   ExSortPrivateState;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7719015/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 0ed6bc5..bf579aa 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -15275,7 +15275,7 @@ exe_util_get_statistics : TOK_GET TOK_STATISTICS stats_merge_clause get_statisti
                   {
                     stats =
                       new (PARSERHEAP ()) ExeUtilGetStatistics
-                    (*$5, NULL,
+                    (*$5, ($7 ? (char*)$7->data() : NULL),
                       PARSERHEAP (), SQLCLI_STATS_REQ_QID, (short)$6, -1); /*RtsQueryId::ANY_QUERY_*/
                   }
                   $$ = stats;