phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [2/5] git commit: PHOENIX-1338 Logic to group together parallel scans is incorrect
Date Tue, 14 Oct 2014 08:24:20 GMT
PHOENIX-1338 Logic to group together parallel scans is incorrect

Conflicts:
	phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
	phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java


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

Branch: refs/heads/3.0
Commit: 0ea2a78d28eb7efe09ef6eb6504a80038d7feede
Parents: 746f42e
Author: James Taylor <jtaylor@salesforce.com>
Authored: Fri Oct 10 20:44:42 2014 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Mon Oct 13 23:16:01 2014 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/BaseViewIT.java  | 21 ++++++++++++++
 .../phoenix/iterate/ParallelIterators.java      | 29 +++++++++-----------
 2 files changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0ea2a78d/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
index b6a9994..f1135ca 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
@@ -17,6 +17,8 @@
  */
 package org.apache.phoenix.end2end;
 
+import static org.apache.phoenix.util.TestUtil.analyzeTable;
+import static org.apache.phoenix.util.TestUtil.getAllSplits;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -25,8 +27,10 @@ import java.math.BigDecimal;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
@@ -103,6 +107,13 @@ public class BaseViewIT extends BaseHBaseManagedTimeIT {
         ResultSet rs;
         Connection conn = DriverManager.getConnection(getUrl());
         conn.createStatement().execute("CREATE INDEX i1 on v(k3) include (s)");
+        conn.createStatement().execute("UPSERT INTO v(k2,S,k3) VALUES(120,'foo',50.0)");
+
+        analyzeTable(conn, "v");        
+        List<KeyRange> splits = getAllSplits(conn, "i1");
+        // More guideposts with salted, since it's already pre-split at salt buckets
+        assertEquals(saltBuckets == null ? 6 : 8, splits.size());
+        
         String query = "SELECT k1, k2, k3, s FROM v WHERE k3 = 51.0";
         rs = conn.createStatement().executeQuery(query);
         assertTrue(rs.next());
@@ -119,6 +130,16 @@ public class BaseViewIT extends BaseHBaseManagedTimeIT {
             QueryUtil.getExplainPlan(rs));
 
         conn.createStatement().execute("CREATE INDEX i2 on v(s)");
+
+        // new index hasn't been analyzed yet
+        splits = getAllSplits(conn, "i2");
+        assertEquals(saltBuckets == null ? 1 : 3, splits.size());
+        
+        // analyze table should analyze all view data
+        //analyzeTable(conn, "t");        
+        //splits = getAllSplits(conn, "i2");
+        //assertEquals(saltBuckets == null ? 6 : 8, splits.size());
+
         query = "SELECT k1, k2, s FROM v WHERE s = 'foo'";
         rs = conn.createStatement().executeQuery(query);
         assertTrue(rs.next());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0ea2a78d/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
index e4fb0ed..4cdda83 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
@@ -157,7 +157,6 @@ public class ParallelIterators extends ExplainTable implements ResultIterators
{
         
         this.iteratorFactory = iteratorFactory;
         this.scans = getParallelScans(context.getScan());
-        List<List<Scan>> scans = getParallelScans(context.getScan());
         List<KeyRange> splitRanges = Lists.newArrayListWithExpectedSize(scans.size()
* ESTIMATED_GUIDEPOSTS_PER_REGION);
         for (List<Scan> scanList : scans) {
             for (Scan aScan : scanList) {
@@ -358,24 +357,22 @@ public class ParallelIterators extends ExplainTable implements ResultIterators
{
             return scans;
         }
         PTable table = getTable();
-        if (!scans.isEmpty()) {
-            boolean startNewScanList = false;
-            if (!plan.isRowKeyOrdered()) {
-                startNewScanList = true;
-            } else if (crossedRegionBoundary) {
-                if (table.getBucketNum() != null) {
-                    byte[] previousStartKey = scans.get(scans.size()-1).getStartRow();
-                    byte[] currentStartKey = scan.getStartRow();
-                    byte[] prefix = ScanUtil.getPrefix(previousStartKey, SaltingUtil.NUM_SALTING_BYTES);
-                    startNewScanList = ScanUtil.crossesPrefixBoundary(currentStartKey, prefix,
SaltingUtil.NUM_SALTING_BYTES);
-                }
-            }
-            if (startNewScanList) {
-                parallelScans.add(scans);
-                scans = Lists.newArrayListWithExpectedSize(1);
+        boolean startNewScanList = false;
+        if (!plan.isRowKeyOrdered()) {
+            startNewScanList = true;
+        } else if (crossedRegionBoundary) {
+            if (table.getBucketNum() != null) {
+                startNewScanList = scans.isEmpty() ||
+                        ScanUtil.crossesPrefixBoundary(scan.getStartRow(),
+                                ScanUtil.getPrefix(scans.get(scans.size()-1).getStartRow(),
SaltingUtil.NUM_SALTING_BYTES), 
+                                SaltingUtil.NUM_SALTING_BYTES);
             }
         }
         scans.add(scan);
+        if (startNewScanList) {
+            parallelScans.add(scans);
+            scans = Lists.newArrayListWithExpectedSize(1);
+        }
         return scans;
     }
     /**


Mime
View raw message