You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by pb...@apache.org on 2018/03/22 21:43:12 UTC
[2/9] phoenix git commit: PHOENIX-4576 Fix LocalIndexSplitMergeIT
tests failing in master branch - addendum(Rajeshbabu)
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/71b528b2
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/71b528b2
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/71b528b2
Branch: refs/heads/4.x-cdh5.11.2
Commit: 71b528b280a551904a2807ce4597b7bcb9235733
Parents: 4debdd1
Author: Rajeshbabu Chintaguntla <ra...@apache.org>
Authored: Tue Mar 20 14:08:03 2018 +0000
Committer: Pedro Boado <pb...@apache.org>
Committed: Wed Mar 21 20:17:40 2018 +0000
----------------------------------------------------------------------
.../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/71b528b2/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/71b528b2/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;
}