Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 1abcec1cb -> c422ae9a5


[TRAFODION-807] Fix for zero UEC counts


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/145fbbe4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/145fbbe4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/145fbbe4

Branch: refs/heads/master
Commit: 145fbbe4a2a000eacc3314bfb8922601d2e28adc
Parents: c059444
Author: Dave Birdsall <[email protected]>
Authored: Wed Mar 23 16:57:26 2016 +0000
Committer: Dave Birdsall <[email protected]>
Committed: Wed Mar 23 16:57:26 2016 +0000

----------------------------------------------------------------------
 core/sql/ustat/hs_globals.cpp | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/145fbbe4/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index c323865..84ee7d0 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -5671,7 +5671,7 @@ Lng32 HSGlobalsClass::CollectStatistics()
                                           /* sampled UEC -> est UEC          */
                                           /* sampled ROWCOUNT -> est ROWCOUNT*/
                                           /*=================================*/
-        if (sampleRowCount > 0 && actualRowCount > sampleRowCount)
+        if (samplingUsed && sampleRowCount > 0 && actualRowCount > 
sampleRowCount)
           {
             LM->StartTimer("fix sample row counts");
             retcode = FixSamplingCounts(group);
@@ -5681,6 +5681,24 @@ Lng32 HSGlobalsClass::CollectStatistics()
           }
         group = group->next;
       }
+
+    // If we used cqd USTAT_ESTIMATE_HBASE_ROW_COUNT 'ON', then actualRowCount
+    // is the estimate of the row count given by HBase. If we also did not do
+    // sampling, we know the true row count; this is in sampleRowCount. We
+    // take the opportunity here to correct the actualRowCount in this case.
+    if (!samplingUsed && isHbaseTable &&
+        CmpCommon::getDefault(USTAT_ESTIMATE_HBASE_ROW_COUNT) == DF_ON)
+      {
+        if (LM->LogNeeded())
+          {
+            sprintf(LM->msg, "Correcting actualRowCount (was " PF64 ") from 
sampleRowCount (" PF64 ")",
+                             actualRowCount,sampleRowCount);
+            LM->Log(LM->msg);
+          }
+        actualRowCount = sampleRowCount;
+      }
+         
+
     if (singleGroup && LM->LogNeeded())
       LM->StopTimer();
 
@@ -5712,7 +5730,7 @@ Lng32 HSGlobalsClass::CollectStatistics()
 
         LM->StartTimer("MC: fix MC stats");
 
-        if (sampleRowCount > 0 && actualRowCount > sampleRowCount)
+        if (samplingUsed && sampleRowCount > 0 && actualRowCount > 
sampleRowCount)
           {
             group = multiGroup;
             while (group != NULL)
@@ -11414,7 +11432,7 @@ Lng32 
HSGlobalsClass::createStatsForColumn(HSColGroupStruct *group, Int64 rowsAl
     }
 
     // Upscale rowcounts and estimate UECs when sampling.
-    if (sampleRowCount > 0 && actualRowCount > sampleRowCount)
+    if (samplingUsed && sampleRowCount > 0 && actualRowCount > sampleRowCount)
     {
       retcode = FixSamplingCounts(group);
       HSHandleError(retcode);

Reply via email to