This is an automated email from the ASF dual-hosted git repository.
kadir pushed a commit to branch 4.x-HBase-1.5
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.5 by this push:
new 2088614 PHOENIX-5743 addendum for multi-column family indexes
2088614 is described below
commit 20886148a0f89817bdeafedae55843fc48a3d103
Author: Kadir <[email protected]>
AuthorDate: Sat Feb 22 22:43:46 2020 -0800
PHOENIX-5743 addendum for multi-column family indexes
---
.../end2end/index/GlobalIndexCheckerIT.java | 6 +--
.../apache/phoenix/index/GlobalIndexChecker.java | 8 ++--
.../org/apache/phoenix/index/IndexMaintainer.java | 46 ++++++++++++----------
3 files changed, 33 insertions(+), 27 deletions(-)
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexCheckerIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexCheckerIT.java
index 9cccdd0..f9c50fd 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexCheckerIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexCheckerIT.java
@@ -315,13 +315,13 @@ public class GlobalIndexCheckerIT extends
BaseUniqueNamesOwnClusterIT {
try (Connection conn = DriverManager.getConnection(getUrl())) {
String dataTableName = generateUniqueName();
conn.createStatement().execute("create table " + dataTableName +
- " (id varchar(10) not null primary key, val1 varchar(10),
val2 varchar(10), val3 varchar(10))" + tableDDLOptions);
+ " (id varchar(10) not null primary key, a.val1
varchar(10), b.val2 varchar(10), c.val3 varchar(10))" + tableDDLOptions);
String indexTableName = generateUniqueName();
conn.createStatement().execute("CREATE INDEX " + indexTableName +
" on " +
dataTableName + " (val1) include (val2, val3)");
// Configure IndexRegionObserver to fail the data write phase
IndexRegionObserver.setFailDataTableUpdatesForTesting(true);
- conn.createStatement().execute("upsert into " + dataTableName + "
(id, val1, val2) values ('a', 'ab','abc')");
+ conn.createStatement().execute("upsert into " + dataTableName + "
(id, val1, val3) values ('a', 'ab','abcde')");
commitWithException(conn);
// The above upsert will create an unverified index row
// Configure IndexRegionObserver to allow the data write phase
@@ -346,7 +346,7 @@ public class GlobalIndexCheckerIT extends
BaseUniqueNamesOwnClusterIT {
assertFalse(rs.next());
// Configure IndexRegionObserver to fail the data write phase
IndexRegionObserver.setFailDataTableUpdatesForTesting(true);
- conn.createStatement().execute("upsert into " + dataTableName + "
(id, val1, val2) values ('a', 'ab','abc')");
+ conn.createStatement().execute("upsert into " + dataTableName + "
(id, val1, val3) values ('a', 'ab','abcde')");
commitWithException(conn);
// The above upsert will create an unverified index row
// Configure IndexRegionObserver to allow the data write phase
diff --git
a/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
b/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
index 0f64ed2..7eb95b5 100644
---
a/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
+++
b/phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
@@ -246,11 +246,13 @@ public class GlobalIndexChecker extends
BaseRegionObserver {
private void deleteRowIfAgedEnough(byte[] indexRowKey, List<Cell> row,
long ts, boolean specific) throws IOException {
if ((EnvironmentEdgeManager.currentTimeMillis() - ts) >
ageThreshold) {
- Delete del = new Delete(indexRowKey, ts);
+ Delete del;
if (specific) {
-
del.addFamilyVersion(indexMaintainer.getEmptyKeyValueFamily().copyBytesIfNecessary(),
ts);
+ del = indexMaintainer.buildRowDeleteMutation(indexRowKey,
+ IndexMaintainer.DeleteType.SINGLE_VERSION, ts);
} else {
-
del.addFamily(indexMaintainer.getEmptyKeyValueFamily().copyBytesIfNecessary(),
ts);
+ del = indexMaintainer.buildRowDeleteMutation(indexRowKey,
+ IndexMaintainer.DeleteType.ALL_VERSIONS, ts);
}
Mutation[] mutations = new Mutation[]{del};
region.batchMutate(mutations, HConstants.NO_NONCE,
HConstants.NO_NONCE);
diff --git
a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
index 6ba147f..dba165b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
@@ -1071,7 +1071,7 @@ public class IndexMaintainer implements Writable,
Iterable<ColumnReference> {
return put;
}
- private enum DeleteType {SINGLE_VERSION, ALL_VERSIONS};
+ public enum DeleteType {SINGLE_VERSION, ALL_VERSIONS};
private DeleteType getDeleteTypeOrNull(Collection<? extends Cell>
pendingUpdates) {
return getDeleteTypeOrNull(pendingUpdates, this.nDataCFs);
}
@@ -1150,7 +1150,29 @@ public class IndexMaintainer implements Writable,
Iterable<ColumnReference> {
}
return false;
}
-
+
+ public Delete buildRowDeleteMutation(byte[] indexRowKey, DeleteType
deleteType, long ts) {
+ byte[] emptyCF = emptyKeyValueCFPtr.copyBytesIfNecessary();
+ Delete delete = new Delete(indexRowKey);
+
+ for (ColumnReference ref : getCoveredColumns()) {
+ ColumnReference indexColumn = coveredColumnsMap.get(ref);
+ // If table delete was single version, then index delete should be
as well
+ if (deleteType == DeleteType.SINGLE_VERSION) {
+ delete.addFamilyVersion(indexColumn.getFamily(), ts);
+ } else {
+ delete.addFamily(indexColumn.getFamily(), ts);
+ }
+ }
+ if (deleteType == DeleteType.SINGLE_VERSION) {
+ delete.addFamilyVersion(emptyCF, ts);
+ } else {
+ delete.addFamily(emptyCF, ts);
+ }
+ delete.setDurability(!indexWALDisabled ? Durability.USE_DEFAULT :
Durability.SKIP_WAL);
+ return delete;
+ }
+
/**
* Used for immutable indexes that only index PK column values. In that
case, we can handle a data row deletion,
* since we can build the corresponding index row key.
@@ -1164,25 +1186,7 @@ public class IndexMaintainer implements Writable,
Iterable<ColumnReference> {
// Delete the entire row if any of the indexed columns changed
DeleteType deleteType = null;
if (oldState == null ||
(deleteType=getDeleteTypeOrNull(pendingUpdates)) != null ||
hasIndexedColumnChanged(oldState, pendingUpdates, ts)) { // Deleting the entire
row
- byte[] emptyCF = emptyKeyValueCFPtr.copyBytesIfNecessary();
- Delete delete = new Delete(indexRowKey);
-
- for (ColumnReference ref : getCoveredColumns()) {
- ColumnReference indexColumn = coveredColumnsMap.get(ref);
- // If table delete was single version, then index delete
should be as well
- if (deleteType == DeleteType.SINGLE_VERSION) {
- delete.addFamilyVersion(indexColumn.getFamily(), ts);
- } else {
- delete.addFamily(indexColumn.getFamily(), ts);
- }
- }
- if (deleteType == DeleteType.SINGLE_VERSION) {
- delete.addFamilyVersion(emptyCF, ts);
- } else {
- delete.addFamily(emptyCF, ts);
- }
- delete.setDurability(!indexWALDisabled ? Durability.USE_DEFAULT :
Durability.SKIP_WAL);
- return delete;
+ return buildRowDeleteMutation(indexRowKey, deleteType, ts);
}
Delete delete = null;
Set<ColumnReference> dataTableColRefs = coveredColumnsMap.keySet();