phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [1/3] phoenix git commit: PHOENIX-2884 Fix EXPLAIN plan for offset on salted table
Date Mon, 16 May 2016 07:20:04 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 ea93058f4 -> 4837f1ff9


PHOENIX-2884 Fix EXPLAIN plan for offset on salted table


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a9934ef9
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a9934ef9
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a9934ef9

Branch: refs/heads/4.x-HBase-0.98
Commit: a9934ef90aa12e133a5d609e9c6df57e670e5284
Parents: ea93058
Author: Ankit Singhal <ankitsinghal59@gmail.com>
Authored: Mon May 16 12:43:09 2016 +0530
Committer: Ankit Singhal <ankitsinghal59@gmail.com>
Committed: Mon May 16 12:43:09 2016 +0530

----------------------------------------------------------------------
 .../phoenix/end2end/QueryWithOffsetIT.java      | 25 ++++++++++++++++----
 .../phoenix/iterate/BaseResultIterators.java    |  4 +---
 2 files changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a9934ef9/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java
index 7f360de..f4b3440 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java
@@ -38,6 +38,7 @@ import java.util.Properties;
 
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -50,16 +51,18 @@ import com.google.common.collect.Maps;
 @RunWith(Parameterized.class)
 public class QueryWithOffsetIT extends BaseOwnClusterHBaseManagedTimeIT {
     
-    private String tableName;
+    private String tableName = "T";
     private final String[] strings = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p",
             "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
     private final String ddl;
+    private final boolean isSalted;
 
     public QueryWithOffsetIT(String preSplit) {
         this.tableName = tableName + "_" + preSplit.charAt(2);
         this.ddl = "CREATE TABLE " + tableName + " (t_id VARCHAR NOT NULL,\n" + "k1 INTEGER
NOT NULL,\n"
                 + "k2 INTEGER NOT NULL,\n" + "C3.k3 INTEGER,\n" + "C2.v1 VARCHAR,\n"
                 + "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2)) " + preSplit;
+        this.isSalted = preSplit.startsWith(" SALT_BUCKETS");
     }
 
     @BeforeClass
@@ -122,16 +125,28 @@ public class QueryWithOffsetIT extends BaseOwnClusterHBaseManagedTimeIT
{
         updateStatistics(conn);
         String query = "SELECT t_id from " + tableName + " offset " + offset;
         ResultSet rs = conn.createStatement().executeQuery("EXPLAIN " + query);
-        rs.next();
-        rs.next();
-        rs.next();
-        assertEquals("    SERVER OFFSET " + offset, rs.getString(1));
+        if(!isSalted){
+            assertEquals("CLIENT SERIAL 1-WAY FULL SCAN OVER T_P\n" + "    SERVER FILTER
BY FIRST KEY ONLY\n"
+                    + "    SERVER OFFSET " + offset, QueryUtil.getExplainPlan(rs));
+        }else{
+            assertEquals("CLIENT PARALLEL 10-WAY FULL SCAN OVER T_A\n" + "    SERVER FILTER
BY FIRST KEY ONLY\n"
+                    + "CLIENT MERGE SORT\n" + "CLIENT OFFSET " + offset, QueryUtil.getExplainPlan(rs));
+        }
         rs = conn.createStatement().executeQuery(query);
         int i = 0;
         while (i++ < strings.length - offset) {
             assertTrue(rs.next());
             assertEquals(strings[offset + i - 1], rs.getString(1));
         }
+        query = "SELECT t_id from " + tableName + " ORDER BY v1 offset " + offset;
+        rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+        if (!isSalted) {
+            assertEquals("CLIENT PARALLEL 5-WAY FULL SCAN OVER T_P\n" + "    SERVER SORTED
BY [C2.V1]\n"
+                    + "CLIENT MERGE SORT\n" + "CLIENT OFFSET " + offset, QueryUtil.getExplainPlan(rs));
+        } else {
+            assertEquals("CLIENT PARALLEL 10-WAY FULL SCAN OVER T_A\n" + "    SERVER SORTED
BY [C2.V1]\n"
+                    + "CLIENT MERGE SORT\n" + "CLIENT OFFSET " + offset, QueryUtil.getExplainPlan(rs));
+        }
         conn.close();
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a9934ef9/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
index bee2201..4f49e2d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
@@ -20,7 +20,6 @@ package org.apache.phoenix.iterate;
 import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SCAN_ACTUAL_START_ROW;
 import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SCAN_START_ROW_SUFFIX;
 import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SCAN_STOP_ROW_SUFFIX;
-
 import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_FAILED_QUERY_COUNTER;
 import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_QUERY_TIMEOUT_COUNTER;
 import static org.apache.phoenix.util.ByteUtil.EMPTY_BYTE_ARRAY;
@@ -64,7 +63,6 @@ import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver;
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.execute.MutationState;
-import org.apache.phoenix.execute.ScanPlan;
 import org.apache.phoenix.filter.ColumnProjectionFilter;
 import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.hbase.index.util.VersionUtil;
@@ -334,7 +332,7 @@ public abstract class BaseResultIterators extends ExplainTable implements
Result
     
     public BaseResultIterators(QueryPlan plan, Integer perScanLimit, Integer offset, ParallelScanGrouper
scanGrouper, Scan scan) throws SQLException {
         super(plan.getContext(), plan.getTableRef(), plan.getGroupBy(), plan.getOrderBy(),
-                plan.getStatement().getHint(), plan.getLimit(), plan instanceof ScanPlan
? plan.getOffset() : null);
+                plan.getStatement().getHint(), plan.getLimit(), offset);
         this.plan = plan;
         this.scan = scan;
         this.scanGrouper = scanGrouper;


Mime
View raw message