Repository: phoenix
Updated Branches:
  refs/heads/master c7eeda03b -> 1aba55f42


PHOENIX-4930 Add test for ORDER BY and LIMIT queries during a split (addendum)


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

Branch: refs/heads/master
Commit: 1aba55f42510f057c876b17db0331be5b8e35e4e
Parents: c7eeda0
Author: Thomas D'Silva <tdsi...@apache.org>
Authored: Fri Sep 28 17:32:22 2018 -0700
Committer: Thomas D'Silva <tdsi...@apache.org>
Committed: Fri Sep 28 17:35:26 2018 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/SplitIT.java     | 36 +++++++-------------
 .../end2end/UpsertSelectAutoCommitIT.java       | 28 +++++----------
 2 files changed, 20 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1aba55f4/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitIT.java
index 73cf1f0..60694ff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitIT.java
@@ -1,7 +1,8 @@
 package org.apache.phoenix.end2end;
 
 import com.google.common.collect.Maps;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
@@ -56,7 +57,7 @@ public class SplitIT extends BaseUniqueNamesOwnClusterIT {
                     try {
                         // split on the first row being scanned if splitPoint 
is null
                         splitPoint = splitPoint!=null ? splitPoint : 
results.get(0).getRow();
-                        splitTable(splitPoint, tableName);
+                        splitTable(splitPoint, TableName.valueOf(tableName));
                         tableWasSplitDuringScannerNext = true;
                     }
                     catch (SQLException e) {
@@ -69,14 +70,14 @@ public class SplitIT extends BaseUniqueNamesOwnClusterIT {
 
     }
 
-    public static void splitTable(byte[] splitPoint, String tableName) throws 
SQLException, IOException {
-        HBaseAdmin admin = driver.getConnectionQueryServices(getUrl(), 
TestUtil.TEST_PROPERTIES).getAdmin();
-        int nRegions = admin.getTableRegions(tableName.getBytes()).size();
+    public static void splitTable(byte[] splitPoint, TableName tableName) 
throws SQLException, IOException {
+        Admin admin = driver.getConnectionQueryServices(getUrl(), 
TestUtil.TEST_PROPERTIES).getAdmin();
+        int nRegions = admin.getTableRegions(tableName).size();
         int nInitialRegions = nRegions;
-        admin.split(tableName.getBytes(), splitPoint);
+        admin.split(tableName, splitPoint);
         admin.disableTable(tableName);
         admin.enableTable(tableName);
-        nRegions = admin.getTableRegions(tableName.getBytes()).size();
+        nRegions = admin.getTableRegions(tableName).size();
         if (nRegions == nInitialRegions)
             throw new IOException("Could not split for " + tableName);
     }
@@ -99,7 +100,7 @@ public class SplitIT extends BaseUniqueNamesOwnClusterIT {
         for (int i=0; i<7; i++) {
             if (splitTableBeforeUpsertSelect) {
                 // split the table and then run the UPSERT SELECT
-                splitTable(PInteger.INSTANCE.toBytes(Math.pow(2, i)), 
tableName);
+                splitTable(PInteger.INSTANCE.toBytes(Math.pow(2, i)), 
TableName.valueOf(tableName));
             }
             int upsertCount = stmt.executeUpdate();
             assertEquals((int) Math.pow(2, i), upsertCount);
@@ -124,7 +125,7 @@ public class SplitIT extends BaseUniqueNamesOwnClusterIT {
         for (int i=0; i<5; i++) {
             if (splitTableBeforeSelect) {
                 // split the table and then run the SELECT
-                splitTable(PInteger.INSTANCE.toBytes(Math.pow(2, i)), 
tableName);
+                splitTable(PInteger.INSTANCE.toBytes(Math.pow(2, i)), 
TableName.valueOf(tableName));
             }
 
             int count = 0;
@@ -151,21 +152,8 @@ public class SplitIT extends BaseUniqueNamesOwnClusterIT {
             assertTrue(rs.next());
             int rowCount = rs.getInt(1);
             assertFalse(rs.next());
-
-            // for ORDER BY a StaleRegionBoundaryException is thrown when a 
sp[it happens
-            if (orderBy) {
-                // if the table splits before the SELECT we always detect this 
so we never see rows written after the scan started
-                if (splitTableBeforeSelect)
-                    assertEquals((int) Math.pow(2, i + 1), rowCount);
-                // else we see rows written after the SELECT started
-                else if (i == 4) {
-                    assert ((int) Math.pow(2, i + 1) < rowCount);
-                }
-            }
-            // verify that we will see more rows written after the scan 
started after a split happens for simple select
-            else if ((splitTableBeforeSelect && i == 3) || i == 4) {
-                assert ((int) Math.pow(2, i + 1) < rowCount);
-            }
+            // in HBase 2.x we sometimes we see rows written after the scan 
started
+            assertTrue((int) Math.pow(2, i + 1) <= rowCount);
         }
         conn.close();
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1aba55f4/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
index 6210852..73d44ed 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
@@ -17,32 +17,20 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.phoenix.util.TestUtil.A_VALUE;
-import static org.apache.phoenix.util.TestUtil.ROW1;
-import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.hadoop.hbase.client.Admin;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
+import java.sql.*;
+import java.util.Properties;
+
+import static org.apache.phoenix.util.TestUtil.*;
+import static org.junit.Assert.*;
+
 
 public class UpsertSelectAutoCommitIT extends ParallelStatsDisabledIT {
 
@@ -173,7 +161,7 @@ public class UpsertSelectAutoCommitIT extends 
ParallelStatsDisabledIT {
         PreparedStatement stmt =
                 conn.prepareStatement("UPSERT INTO " + tableName
                         + " SELECT NEXT VALUE FOR keys, val FROM " + 
tableName);
-        HBaseAdmin admin =
+        Admin admin =
                 driver.getConnectionQueryServices(getUrl(), 
TestUtil.TEST_PROPERTIES).getAdmin();
         for (int i=0; i<12; i++) {
             admin.split(TableName.valueOf(tableName));

Reply via email to