You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by la...@apache.org on 2019/01/30 23:40:14 UTC

[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5106 Avoid getting an explain plan for each query (even without tracing).

This is an automated email from the ASF dual-hosted git repository.

larsh pushed a commit to branch 4.x-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
     new 74bd929  PHOENIX-5106 Avoid getting an explain plan for each query (even without tracing).
74bd929 is described below

commit 74bd929d5a6754ed66f4e0e95b00a971f335af05
Author: Lars Hofhansl <la...@apache.org>
AuthorDate: Wed Jan 30 15:40:04 2019 -0800

    PHOENIX-5106 Avoid getting an explain plan for each query (even without tracing).
---
 .../main/java/org/apache/phoenix/execute/BaseQueryPlan.java    | 10 ++++++----
 .../src/main/java/org/apache/phoenix/trace/util/Tracing.java   |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
index 25980b9..55dbfae 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
@@ -367,10 +367,12 @@ public abstract class BaseQueryPlan implements QueryPlan {
         }
 
         // wrap the iterator so we start/end tracing as we expect
-        TraceScope scope =
-                Tracing.startNewSpan(context.getConnection(), "Creating basic query for "
-                        + getPlanSteps(iterator));
-        return (scope.getSpan() != null) ? new TracingIterator(scope, iterator) : iterator;
+        if (Tracing.isTracing()) {
+            TraceScope scope = Tracing.startNewSpan(context.getConnection(),
+                    "Creating basic query for " + getPlanSteps(iterator));
+            if (scope.getSpan() != null) return new TracingIterator(scope, iterator);
+        }
+        return iterator;
     }
 
     private void serializeIndexMaintainerIntoScan(Scan scan, PTable dataTable) throws SQLException {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
index 35cc6dc..616ad30 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
@@ -300,4 +300,11 @@ public class Tracing {
         }
     }
 
+    /**
+     * Check whether tracing is generally enabled.
+     * @return true If tracing is enabled, false otherwise
+     */
+    public static boolean isTracing() {
+        return Trace.isTracing();
+    }
 }