phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajeshb...@apache.org
Subject phoenix git commit: PHOENIX-4576 Fix LocalIndexSplitMergeIT tests failing in master branch - addendum(Rajeshbabu)
Date Tue, 20 Mar 2018 14:10:34 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 df1f8ca8d -> 3e87f5d3e


PHOENIX-4576 Fix LocalIndexSplitMergeIT tests failing in master branch - addendum(Rajeshbabu)


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 3e87f5d3e4cc05bc6291afa2dee0f159d6b69085
Parents: df1f8ca
Author: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
Authored: Tue Mar 20 19:40:17 2018 +0530
Committer: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
Committed: Tue Mar 20 19:40:17 2018 +0530

----------------------------------------------------------------------
 .../phoenix/end2end/LocalIndexSplitMergeIT.java | 59 ++++++++++++++++++++
 .../IndexHalfStoreFileReaderGenerator.java      |  8 ++-
 2 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3e87f5d3/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java
index 409e98f..dc3e5d3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java
@@ -263,4 +263,63 @@ public class LocalIndexSplitMergeIT extends BaseTest {
         }
     }
 
+    @Test
+    public void testLocalIndexScanWithMergeSpecialCase() throws Exception {
+        String schemaName = generateUniqueName();
+        String tableName = schemaName + "." + generateUniqueName();
+        String indexName = "IDX_" + generateUniqueName();
+        TableName physicalTableName = SchemaUtil.getPhysicalTableName(tableName.getBytes(),
false);
+        createBaseTable(tableName, "('a','aaaab','def')");
+        Connection conn1 = getConnectionForLocalIndexTest();
+        try {
+            String[] strings =
+                    { "aa", "aaa", "aaaa", "bb", "cc", "dd", "dff", "g", "h", "i", "j", "k",
"l",
+                            "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y",
"z" };
+            for (int i = 0; i < 26; i++) {
+                conn1.createStatement()
+                        .execute("UPSERT INTO " + tableName + " values('" + strings[i] +
"'," + i
+                                + "," + (i + 1) + "," + (i + 2) + ",'" + strings[25 - i]
+ "')");
+            }
+            conn1.commit();
+            conn1.createStatement()
+                    .execute("CREATE LOCAL INDEX " + indexName + " ON " + tableName + "(v1)");
+            conn1.createStatement()
+            .execute("CREATE LOCAL INDEX " + indexName + "_2 ON " + tableName + "(k3)");
+
+            HBaseAdmin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
+            List<HRegionInfo> regionsOfUserTable =
+                    MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(),
+                        admin.getConnection(), physicalTableName, false);
+            admin.mergeRegions(regionsOfUserTable.get(0).getEncodedNameAsBytes(),
+                regionsOfUserTable.get(1).getEncodedNameAsBytes(), false);
+            regionsOfUserTable =
+                    MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(),
+                        admin.getConnection(), physicalTableName, false);
+
+            while (regionsOfUserTable.size() != 3) {
+                Thread.sleep(100);
+                regionsOfUserTable =
+                        MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(),
+                            admin.getConnection(), physicalTableName, false);
+            }
+            String query = "SELECT t_id,k1,v1 FROM " + tableName;
+            ResultSet rs = conn1.createStatement().executeQuery(query);
+            for (int j = 0; j < 26; j++) {
+                assertTrue(rs.next());
+                assertEquals(strings[25-j], rs.getString("t_id"));
+                assertEquals(25-j, rs.getInt("k1"));
+                assertEquals(strings[j], rs.getString("V1"));
+            }
+            query = "SELECT t_id,k1,k3 FROM " + tableName;
+            rs = conn1.createStatement().executeQuery(query);
+            for (int j = 0; j < 26; j++) {
+                assertTrue(rs.next());
+                assertEquals(strings[j], rs.getString("t_id"));
+                assertEquals(j, rs.getInt("k1"));
+                assertEquals(j + 2, rs.getInt("k3"));
+            }
+        } finally {
+            conn1.close();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3e87f5d3/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
index 12fa47a..e41086b 100644
--- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
+++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
+import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SCAN_START_ROW_SUFFIX;
+
 import java.io.IOException;
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -366,8 +368,10 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver
{
         // If the region start key is not the prefix of the scan start row then we can return
empty
         // scanners. This is possible during merge where one of the child region scan should
not return any
         // results as we go through merged region.
-        if (Bytes.compareTo(scan.getStartRow(), 0, startKey.length == 0 ? endKey.length
-                : startKey.length, startKey.length == 0 ? new byte[endKey.length] : startKey,
0,
+        int prefixLength =
+                scan.getAttribute(SCAN_START_ROW_SUFFIX) == null ? (startKey.length == 0
? endKey.length
+                        : startKey.length) : (scan.getStartRow().length - scan.getAttribute(SCAN_START_ROW_SUFFIX).length);
+        if (Bytes.compareTo(scan.getStartRow(), 0, prefixLength, (startKey.length == 0 ?
new byte[endKey.length] : startKey), 0,
             startKey.length == 0 ? endKey.length : startKey.length) != 0) {
             return keyValueScanners;
         }


Mime
View raw message