You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sk...@apache.org on 2019/07/16 23:24:26 UTC
[phoenix] branch 4.x-HBase-1.4 updated: PHOENIX-5385:
GlobalIndexChecker coproc doesn't load on view indexes
This is an automated email from the ASF dual-hosted git repository.
skadam pushed a commit to branch 4.x-HBase-1.4
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.4 by this push:
new ca13453 PHOENIX-5385: GlobalIndexChecker coproc doesn't load on view indexes
ca13453 is described below
commit ca134532b49a5a7ba77e08b3fcd84486216cd8ee
Author: s.kadam <sk...@apache.org>
AuthorDate: Tue Jul 16 12:34:01 2019 -0700
PHOENIX-5385: GlobalIndexChecker coproc doesn't load on view indexes
---
.../end2end/ParameterizedIndexUpgradeToolIT.java | 31 +++++++------
.../apache/phoenix/end2end/index/DropColumnIT.java | 8 ++--
.../org/apache/phoenix/execute/MutationState.java | 53 ++++++++++++++--------
.../phoenix/mapreduce/index/IndexUpgradeTool.java | 38 ++++++++++------
.../phoenix/query/ConnectionQueryServicesImpl.java | 13 ++----
5 files changed, 84 insertions(+), 59 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java
index 400df93..24c0f39 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java
@@ -60,11 +60,11 @@ import static org.apache.phoenix.mapreduce.index.IndexUpgradeTool.UPGRADE_OP;
@RunWith(Parameterized.class)
@Category(NeedsOwnMiniClusterTest.class)
public class ParameterizedIndexUpgradeToolIT extends BaseTest {
- //Please do not remove/uncomment commented items in the list until PHOENIX-5385 is fixed
private static final String [] INDEXES_LIST = {"TEST.INDEX1", "TEST.INDEX2", "TEST1.INDEX3",
- "TEST1.INDEX2","TEST1.INDEX1","TEST.INDEX3"/*, "_IDX_TEST.MOCK1", "_IDX_TEST1.MOCK2"*/};
- private static final String [] INDEXES_LIST_NAMESPACE = {"TEST:INDEX1", "TEST:INDEX2", "TEST1:INDEX3",
- "TEST1:INDEX2","TEST1:INDEX1","TEST:INDEX3"/*, "TEST:_IDX_MOCK1", "TEST1:_IDX_MOCK2"*/};
+ "TEST1.INDEX2","TEST1.INDEX1","TEST.INDEX3", "_IDX_TEST.MOCK1", "_IDX_TEST1.MOCK2"};
+ private static final String [] INDEXES_LIST_NAMESPACE = {"TEST:INDEX1", "TEST:INDEX2",
+ "TEST1:INDEX3", "TEST1:INDEX2","TEST1:INDEX1","TEST:INDEX3", "TEST:_IDX_MOCK1",
+ "TEST1:_IDX_MOCK2"};
private static final String [] TABLE_LIST = {"TEST.MOCK1","TEST1.MOCK2","TEST.MOCK3"};
private static final String [] TABLE_LIST_NAMESPACE = {"TEST:MOCK1","TEST1:MOCK2","TEST:MOCK3"};
@@ -99,7 +99,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
.getQueryServices();
admin = queryServices.getAdmin();
iut = new IndexUpgradeTool(upgrade ? UPGRADE_OP : ROLLBACK_OP, INPUT_LIST,
- null, "/tmp/index_upgrade_" + UUID.randomUUID().toString(),true, Mockito.mock(IndexTool.class));
+ null, "/tmp/index_upgrade_" + UUID.randomUUID().toString(),
+ true, Mockito.mock(IndexTool.class));
iut.setConf(getUtility().getConfiguration());
iut.setTest(true);
if (!mutable) {
@@ -141,9 +142,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
conn.createStatement().execute("CREATE TABLE TEST.MOCK3 (id bigint NOT NULL "
+ "PRIMARY KEY, name varchar, age bigint)"+tableDDLOptions);
- //Please do not remove/uncomment commented code until PHOENIX-5385 is fixed
//views
- /*conn.createStatement().execute("CREATE VIEW TEST.MOCK1_VIEW (view_column varchar) "
+ conn.createStatement().execute("CREATE VIEW TEST.MOCK1_VIEW (view_column varchar) "
+ "AS SELECT * FROM TEST.MOCK1 WHERE a.name = 'a'");
conn.createStatement().execute("CREATE VIEW TEST.MOCK1_VIEW1 (view_column varchar,"
+ " zip varchar) AS SELECT * FROM TEST.MOCK1 WHERE a.name = 'a'");
@@ -157,7 +157,7 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
conn.createStatement().execute("CREATE INDEX MOCK2_INDEX1 ON TEST1.MOCK2_VIEW "
+ "(state, city)");
conn.createStatement().execute("CREATE INDEX MOCK1_INDEX3 ON TEST.MOCK1_VIEW "
- + "(view_column)");*/
+ + "(view_column)");
//indexes
conn.createStatement().execute("CREATE INDEX INDEX1 ON TEST.MOCK1 (sal, a.name)");
conn.createStatement().execute("CREATE INDEX INDEX2 ON TEST.MOCK1 (a.name)");
@@ -189,7 +189,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
}
}
- private void checkNewIndexingCoprocessors(String [] indexList, String [] tableList) throws IOException {
+ private void checkNewIndexingCoprocessors(String [] indexList, String [] tableList)
+ throws IOException {
if (mutable) {
for (String table : tableList) {
Assert.assertTrue(admin.getTableDescriptor(TableName.valueOf(table))
@@ -204,7 +205,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
}
}
- private void checkOldIndexingCoprocessors(String [] indexList, String [] tableList) throws IOException {
+ private void checkOldIndexingCoprocessors(String [] indexList, String [] tableList)
+ throws IOException {
if (mutable) {
for (String table : tableList) {
Assert.assertTrue(admin.getTableDescriptor(TableName.valueOf(table))
@@ -233,7 +235,8 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
});
}
- public ParameterizedIndexUpgradeToolIT(boolean mutable, boolean upgrade, boolean isNamespaceEnabled) {
+ public ParameterizedIndexUpgradeToolIT(boolean mutable, boolean upgrade, boolean
+ isNamespaceEnabled) {
this.mutable = mutable;
this.upgrade = upgrade;
this.isNamespaceEnabled = isNamespaceEnabled;
@@ -303,16 +306,14 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
conn.createStatement().execute("DROP INDEX INDEX3 ON TEST1.MOCK2");
conn.createStatement().execute("DROP INDEX INDEX3 ON TEST.MOCK3");
-
- //Please do not remove/uncomment commented code until PHOENIX-5385 is fixed
- /*conn.createStatement().execute("DROP INDEX MOCK1_INDEX3 ON TEST.MOCK1_VIEW");
+ conn.createStatement().execute("DROP INDEX MOCK1_INDEX3 ON TEST.MOCK1_VIEW");
conn.createStatement().execute("DROP INDEX MOCK1_INDEX1 ON TEST.MOCK1_VIEW1");
conn.createStatement().execute("DROP INDEX MOCK1_INDEX2 ON TEST.MOCK1_VIEW1");
conn.createStatement().execute("DROP INDEX MOCK2_INDEX1 ON TEST1.MOCK2_VIEW");
conn.createStatement().execute("DROP VIEW TEST.MOCK1_VIEW");
conn.createStatement().execute("DROP VIEW TEST.MOCK1_VIEW1");
- conn.createStatement().execute("DROP VIEW TEST1.MOCK2_VIEW");*/
+ conn.createStatement().execute("DROP VIEW TEST1.MOCK2_VIEW");
conn.createStatement().execute("DROP TABLE TEST.MOCK1");
conn.createStatement().execute("DROP TABLE TEST1.MOCK2");
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java
index e19284a..3ed2f11 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropColumnIT.java
@@ -34,6 +34,7 @@ import java.util.Collection;
import java.util.Properties;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
@@ -342,8 +343,6 @@ public class DropColumnIT extends ParallelStatsDisabledIT {
PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
PTable dataTable = pconn.getTable(new PTableKey(null, dataTableFullName));
assertEquals("Unexpected number of indexes ", 3, dataTable.getIndexes().size());
- PTable indexTable = dataTable.getIndexes().get(0);
- byte[] indexTablePhysicalName = indexTable.getPhysicalName().getBytes();
PName localIndexTablePhysicalName = dataTable.getIndexes().get(1).getPhysicalName();
// drop v2 which causes the regular index and first local index to be dropped
@@ -373,9 +372,10 @@ public class DropColumnIT extends ParallelStatsDisabledIT {
// verify that the regular index physical table was dropped
try {
- conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(indexTablePhysicalName);
+ conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()
+ .getTableDescriptor(TableName.valueOf(indexTableName));
fail("Index table should have been dropped");
- } catch (TableNotFoundException e) {
+ } catch (org.apache.hadoop.hbase.TableNotFoundException e) {
}
// verify that the local index physical table was *not* dropped
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index 9ad6172..856c6bc55 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -83,6 +83,8 @@ import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PIndexState;
import org.apache.phoenix.schema.PMetaData;
import org.apache.phoenix.schema.PName;
+import org.apache.phoenix.schema.PNameFactory;
+import org.apache.phoenix.schema.PNameImpl;
import org.apache.phoenix.schema.PRow;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTableRef;
@@ -103,6 +105,7 @@ import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.apache.phoenix.util.IndexUtil;
import org.apache.phoenix.util.KeyValueUtil;
import org.apache.phoenix.util.LogUtil;
+import org.apache.phoenix.util.MetaDataUtil;
import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.SQLCloseable;
import org.apache.phoenix.util.SchemaUtil;
@@ -507,7 +510,7 @@ public class MutationState implements SQLCloseable {
return ptr;
}
- private Iterator<Pair<PName, List<Mutation>>> addRowMutations(final TableRef tableRef,
+ private Iterator<Pair<PTable, List<Mutation>>> addRowMutations(final TableRef tableRef,
final MultiRowMutationState values, final long mutationTimestamp, final long serverTimestamp,
boolean includeAllIndexes, final boolean sendAll) {
final PTable table = tableRef.getTable();
@@ -520,7 +523,7 @@ public class MutationState implements SQLCloseable {
.<Mutation> newArrayListWithExpectedSize(values.size()) : null;
generateMutations(tableRef, mutationTimestamp, serverTimestamp, values, mutationList,
mutationsPertainingToIndex);
- return new Iterator<Pair<PName, List<Mutation>>>() {
+ return new Iterator<Pair<PTable, List<Mutation>>>() {
boolean isFirst = true;
Map<byte[], List<Mutation>> indexMutationsMap = null;
@@ -530,10 +533,10 @@ public class MutationState implements SQLCloseable {
}
@Override
- public Pair<PName, List<Mutation>> next() {
+ public Pair<PTable, List<Mutation>> next() {
if (isFirst) {
isFirst = false;
- return new Pair<>(table.getPhysicalName(), mutationList);
+ return new Pair<>(table, mutationList);
}
PTable index = indexes.next();
@@ -585,7 +588,7 @@ public class MutationState implements SQLCloseable {
} catch (SQLException | IOException e) {
throw new IllegalDataException(e);
}
- return new Pair<PName, List<Mutation>>(index.getPhysicalName(),
+ return new Pair<PTable, List<Mutation>>(index,
indexMutations == null ? Collections.<Mutation> emptyList() : indexMutations);
}
@@ -690,8 +693,9 @@ public class MutationState implements SQLCloseable {
private Iterator<Pair<byte[], List<Mutation>>> innerIterator = init();
private Iterator<Pair<byte[], List<Mutation>>> init() {
- final Iterator<Pair<PName, List<Mutation>>> mutationIterator = addRowMutations(current.getKey(),
- current.getValue(), mutationTimestamp, serverTimestamp, includeMutableIndexes, true);
+ final Iterator<Pair<PTable, List<Mutation>>> mutationIterator =
+ addRowMutations(current.getKey(), current.getValue(), mutationTimestamp,
+ serverTimestamp, includeMutableIndexes, true);
return new Iterator<Pair<byte[], List<Mutation>>>() {
@Override
public boolean hasNext() {
@@ -700,8 +704,9 @@ public class MutationState implements SQLCloseable {
@Override
public Pair<byte[], List<Mutation>> next() {
- Pair<PName, List<Mutation>> pair = mutationIterator.next();
- return new Pair<byte[], List<Mutation>>(pair.getFirst().getBytes(), pair.getSecond());
+ Pair<PTable, List<Mutation>> pair = mutationIterator.next();
+ return new Pair<byte[], List<Mutation>>(pair.getFirst().getPhysicalName()
+ .getBytes(), pair.getSecond());
}
@Override
@@ -837,14 +842,18 @@ public class MutationState implements SQLCloseable {
private final PName hTableName;
@Nonnull
private final TableRef origTableRef;
+ //This is a phoenix/logical table name
+ private final PTable pTable;
- public TableInfo(boolean isDataTable, PName hTableName, TableRef origTableRef) {
+ public TableInfo(boolean isDataTable, PName hTableName, TableRef origTableRef,
+ PTable pTable) {
super();
checkNotNull(hTableName);
checkNotNull(origTableRef);
this.isDataTable = isDataTable;
this.hTableName = hTableName;
this.origTableRef = origTableRef;
+ this.pTable = pTable;
}
public boolean isDataTable() {
@@ -859,6 +868,10 @@ public class MutationState implements SQLCloseable {
return origTableRef;
}
+ public PTable getPTable() {
+ return pTable;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
@@ -876,6 +889,7 @@ public class MutationState implements SQLCloseable {
TableInfo other = (TableInfo)obj;
if (!hTableName.equals(other.hTableName)) return false;
if (isDataTable != other.isDataTable) return false;
+ if (!pTable.equals(other.pTable)) return false;
return true;
}
@@ -916,17 +930,18 @@ public class MutationState implements SQLCloseable {
long mutationTimestamp = scn == null ?
(table.isTransactional() == true ? HConstants.LATEST_TIMESTAMP : EnvironmentEdgeManager.currentTimeMillis())
: scn;
- Iterator<Pair<PName, List<Mutation>>>
+ Iterator<Pair<PTable, List<Mutation>>>
mutationsIterator =
addRowMutations(tableRef, multiRowMutationState, mutationTimestamp,
serverTimestamp, false, sendAll);
// build map from physical table to mutation list
boolean isDataTable = true;
while (mutationsIterator.hasNext()) {
- Pair<PName, List<Mutation>> pair = mutationsIterator.next();
- PName hTableName = pair.getFirst();
+ Pair<PTable, List<Mutation>> pair = mutationsIterator.next();
+ PTable logicalTable = pair.getFirst();
List<Mutation> mutationList = pair.getSecond();
- TableInfo tableInfo = new TableInfo(isDataTable, hTableName, tableRef);
+ TableInfo tableInfo = new TableInfo(isDataTable, logicalTable.getPhysicalName()
+ , tableRef, logicalTable);
List<Mutation>
oldMutationList =
physicalTableMutationMap.put(tableInfo, mutationList);
@@ -1198,10 +1213,12 @@ public class MutationState implements SQLCloseable {
while (mapIter.hasNext()) {
Entry<TableInfo, List<Mutation>> pair = mapIter.next();
TableInfo tableInfo = pair.getKey();
- if (tableInfo.getOrigTableRef().getTable().isImmutableRows() && IndexUtil.isGlobalIndexCheckerEnabled(connection, tableInfo.getHTableName())) {
- PTable table = PhoenixRuntime.getTable(connection, tableInfo.getHTableName().getString());
- byte[] emptyCF = SchemaUtil.getEmptyColumnFamily(table);
- byte[] emptyCQ = EncodedColumnsUtil.getEmptyKeyValueInfo(table).getFirst();
+ PTable logicalTable = tableInfo.getPTable();
+ if (tableInfo.getOrigTableRef().getTable()
+ .isImmutableRows() && IndexUtil.isGlobalIndexCheckerEnabled(connection,
+ tableInfo.getHTableName())) {
+ byte[] emptyCF = SchemaUtil.getEmptyColumnFamily(logicalTable);
+ byte[] emptyCQ = EncodedColumnsUtil.getEmptyKeyValueInfo(logicalTable).getFirst();
List<Mutation> mutations = pair.getValue();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
index 400747f..53be19e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
@@ -67,7 +67,8 @@ import java.util.UUID;
import java.util.logging.FileHandler;
import java.util.logging.SimpleFormatter;
-import static org.apache.phoenix.query.QueryServicesOptions.GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN;
+import static org.apache.phoenix.query.QueryServicesOptions.
+ GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN;
public class IndexUpgradeTool extends Configured {
@@ -89,7 +90,7 @@ public class IndexUpgradeTool extends Configured {
private static final Option LOG_FILE_OPTION = new Option("lf", "logfile",
true,
"Log file path where the logs are written");
- private static final Option INDEX_SYNC_REBUILD_OPTION = new Option("sr", "index-sync-rebuild",
+ private static final Option INDEX_SYNC_REBUILD_OPTION = new Option("sr","index-sync-rebuild",
false,
"[Optional]Whether or not synchronously rebuild the indexes; default rebuild asynchronous");
@@ -150,7 +151,7 @@ public class IndexUpgradeTool extends Configured {
IndexUpgradeTool iut = new IndexUpgradeTool();
try {
cmdLine = iut.parseOptions(args);
- LOGGER.info("Index Upgrade tool initiated: "+ StringUtils.join( args, ","));
+ LOGGER.info("Index Upgrade tool initiated: "+ StringUtils.join( args,","));
} catch (IllegalStateException e) {
iut.printHelpAndExit(e.getMessage(), iut.getOptions());
}
@@ -331,8 +332,8 @@ public class IndexUpgradeTool extends Configured {
+ GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN + 1
+ " minutes for client cache to expire");
if (!test) {
- Thread.sleep(
- (GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN + 1) * 60 * 1000);
+ Thread.sleep((GLOBAL_INDEX_CHECKER_ENABLED_MAP_EXPIRATION_MIN + 1)
+ * 60 * 1000);
}
}
disableTable(admin, dataTableFullName, indexes);
@@ -346,7 +347,8 @@ public class IndexUpgradeTool extends Configured {
rebuildIndexes(dataTableFullName, indexingTool);
}
} catch (IOException | SQLException | InterruptedException e) {
- LOGGER.severe("Something went wrong while executing " + operation + " steps " + e);
+ LOGGER.severe("Something went wrong while executing "
+ + operation + " steps " + e);
return -1;
}
}
@@ -423,7 +425,8 @@ public class IndexUpgradeTool extends Configured {
}
}
- private void addCoprocessor(Admin admin, String tableName, HTableDescriptor tableDesc, String coprocName) throws IOException {
+ private void addCoprocessor(Admin admin, String tableName, HTableDescriptor tableDesc,
+ String coprocName) throws IOException {
if (!admin.getTableDescriptor(TableName.valueOf(tableName)).hasCoprocessor(coprocName)) {
if (!dryRun) {
tableDesc.addCoprocessor(coprocName,
@@ -435,7 +438,8 @@ public class IndexUpgradeTool extends Configured {
}
}
- private void removeCoprocessor(Admin admin, String tableName, HTableDescriptor tableDesc, String coprocName) throws IOException {
+ private void removeCoprocessor(Admin admin, String tableName, HTableDescriptor tableDesc,
+ String coprocName) throws IOException {
if (admin.getTableDescriptor(TableName.valueOf(tableName)).hasCoprocessor(coprocName)) {
if (!dryRun) {
tableDesc.removeCoprocessor(coprocName);
@@ -453,7 +457,8 @@ public class IndexUpgradeTool extends Configured {
if (upgrade) {
addCoprocessor(admin, indexName, indexTableDesc, GlobalIndexChecker.class.getName());
} else {
- removeCoprocessor(admin, indexName, indexTableDesc, GlobalIndexChecker.class.getName());
+ removeCoprocessor(admin, indexName, indexTableDesc,
+ GlobalIndexChecker.class.getName());
}
if (!dryRun) {
admin.modifyTable(TableName.valueOf(indexName),indexTableDesc);
@@ -469,7 +474,8 @@ public class IndexUpgradeTool extends Configured {
String tenantId = indexMap.getValue();
String indexName = SchemaUtil.getTableNameFromFullName(index);
String outFile = "/tmp/index_rebuild_" + indexName +
- (GLOBAL_INDEX_ID.equals(tenantId)?"":"_"+tenantId) +"_"+ UUID.randomUUID().toString();
+ (GLOBAL_INDEX_ID.equals(tenantId)?"":"_"+tenantId) +"_"
+ + UUID.randomUUID().toString();
String[] args =
{ "-s", schema, "-dt", table, "-it", indexName, "-direct", "-op", outFile };
ArrayList<String> list = new ArrayList<>(Arrays.asList(args));
@@ -488,7 +494,8 @@ public class IndexUpgradeTool extends Configured {
indexingTool.run(args);
}
} catch (Exception e) {
- LOGGER.severe("Something went wrong while building the index " + index + " " + e);
+ LOGGER.severe("Something went wrong while building the index "
+ + index + " " + e);
return -1;
}
}
@@ -509,19 +516,22 @@ public class IndexUpgradeTool extends Configured {
for (PTable indexTable : dataTable.getIndexes()) {
if (indexTable.getIndexType().equals(PTable.IndexType.GLOBAL)) {
physicalIndexes.add(indexTable.getPhysicalName().getString());
- rebuildIndexes.put(indexTable.getPhysicalName().getString(), GLOBAL_INDEX_ID);
+ rebuildIndexes.put(indexTable.getPhysicalName().getString(),
+ GLOBAL_INDEX_ID);
}
}
if (MetaDataUtil.hasViewIndexTable(conn, dataTable.getPhysicalName())) {
- String viewIndexPhysicalName = MetaDataUtil.getViewIndexPhysicalName(physicalTableName);
+ String viewIndexPhysicalName = MetaDataUtil
+ .getViewIndexPhysicalName(physicalTableName);
physicalIndexes.add(viewIndexPhysicalName);
ResultSet rs =
conn.createStatement().executeQuery(
"SELECT DISTINCT TABLE_NAME, TENANT_ID FROM "
+ "SYSTEM.CATALOG WHERE COLUMN_FAMILY = \'"
- + viewIndexPhysicalName +"\' AND TABLE_TYPE = \'i\'");
+ + viewIndexPhysicalName
+ +"\' AND TABLE_TYPE = \'i\'");
while (rs.next()) {
String viewIndexName = rs.getString(1);
String tenantId = rs.getString(2);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index c624b65..94b4f92 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -905,12 +905,13 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
try {
TransactionFactory.Provider provider = getTransactionProvider(tableProps);
boolean isTransactional = (provider != null);
-
+ boolean isViewIndex = TRUE_BYTES_AS_STRING
+ .equals(tableProps.get(MetaDataUtil.IS_VIEW_INDEX_TABLE_PROP_NAME));
boolean indexRegionObserverEnabled = config.getBoolean(
QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB,
QueryServicesOptions.DEFAULT_INDEX_REGION_OBSERVER_ENABLED);
- if (tableType == PTableType.INDEX && !isTransactional) {
+ if ((tableType == PTableType.INDEX && !isTransactional) || isViewIndex) {
if (!indexRegionObserverEnabled && descriptor.hasCoprocessor(GlobalIndexChecker.class.getName())) {
descriptor.removeCoprocessor(GlobalIndexChecker.class.getName());
} else if (indexRegionObserverEnabled && !descriptor.hasCoprocessor(GlobalIndexChecker.class.getName()) &&
@@ -936,7 +937,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
// Since indexes can't have indexes, don't install our indexing coprocessor for indexes.
// Also don't install on the SYSTEM.CATALOG and SYSTEM.STATS table because we use
// all-or-none mutate class which break when this coprocessor is installed (PHOENIX-1318).
- if ((tableType != PTableType.INDEX && tableType != PTableType.VIEW)
+ if ((tableType != PTableType.INDEX && tableType != PTableType.VIEW && !isViewIndex)
&& !SchemaUtil.isMetaTable(tableName)
&& !SchemaUtil.isStatsTable(tableName)) {
if (isTransactional) {
@@ -964,10 +965,6 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
opts.put(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, PhoenixIndexCodec.class.getName());
IndexRegionObserver.enableIndexing(descriptor, PhoenixIndexBuilder.class, opts, priority);
}
- if (descriptor.hasCoprocessor(Indexer.class.getName())) {
- descriptor.removeCoprocessor(Indexer.class.getName());
- }
-
} else {
if (descriptor.hasCoprocessor(IndexRegionObserver.class.getName())) {
descriptor.removeCoprocessor(IndexRegionObserver.class.getName());
@@ -1534,7 +1531,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
tableProps.put(MetaDataUtil.IS_VIEW_INDEX_TABLE_PROP_NAME, TRUE_BYTES_AS_STRING);
HTableDescriptor desc = ensureTableCreated(physicalIndexName, PTableType.TABLE, tableProps, families, splits,
- false, isNamespaceMapped, false);
+ true, isNamespaceMapped, false);
if (desc != null) {
if (!Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(desc.getValue(MetaDataUtil.IS_VIEW_INDEX_TABLE_PROP_BYTES)))) {
String fullTableName = Bytes.toString(physicalIndexName);