This is an automated email from the ASF dual-hosted git repository. pboado pushed a commit to branch 4.x-cdh5.16 in repository https://gitbox.apache.org/repos/asf/phoenix.git
commit 622fcf4802d83316111fd19203723e74f843f67d Author: Chinmay Kulkarni <chinmayskulka...@gmail.com> AuthorDate: Mon Dec 10 05:07:41 2018 +0000 PHOENIX-4763: Changing a base table property value should be reflected in child views (if the property wasn't changed) --- .../phoenix/end2end/AlterTableWithViewsIT.java | 117 +++++-- .../end2end/ExplainPlanWithStatsEnabledIT.java | 8 +- .../apache/phoenix/end2end/PropertiesInSyncIT.java | 6 +- .../IndexHalfStoreFileReaderGenerator.java | 3 +- .../org/apache/phoenix/compile/DeleteCompiler.java | 2 +- .../org/apache/phoenix/compile/JoinCompiler.java | 2 +- .../phoenix/compile/TupleProjectionCompiler.java | 3 +- .../org/apache/phoenix/compile/UpsertCompiler.java | 2 +- .../org/apache/phoenix/compile/WhereOptimizer.java | 3 +- .../phoenix/coprocessor/MetaDataEndpointImpl.java | 134 ++++++-- .../phoenix/coprocessor/MetaDataProtocol.java | 32 +- .../coprocessor/generated/MetaDataProtos.java | 356 ++++++++++----------- .../coprocessor/generated/PTableProtos.java | 99 +++--- .../coprocessor/generated/ServerCachingProtos.java | 122 +++---- .../org/apache/phoenix/index/IndexMaintainer.java | 16 +- .../phoenix/index/PhoenixIndexFailurePolicy.java | 2 +- .../org/apache/phoenix/schema/DelegateTable.java | 12 +- .../org/apache/phoenix/schema/MetaDataClient.java | 25 +- .../java/org/apache/phoenix/schema/PTable.java | 6 +- .../java/org/apache/phoenix/schema/PTableImpl.java | 56 +++- .../java/org/apache/phoenix/util/MetaDataUtil.java | 46 ++- .../org/apache/phoenix/util/MetaDataUtilTest.java | 115 +++++-- phoenix-protocol/src/main/MetaDataService.proto | 4 +- phoenix-protocol/src/main/PTable.proto | 2 +- .../src/main/ServerCachingService.proto | 2 +- 25 files changed, 739 insertions(+), 436 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java index 9e7aaa2..82a119f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java @@ -73,6 +73,8 @@ import org.junit.runners.Parameterized.Parameters; import com.google.common.base.Function; import com.google.common.collect.Lists; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_USE_STATS_FOR_PARALLELIZATION; + @RunWith(Parameterized.class) public class AlterTableWithViewsIT extends SplitSystemCatalogIT { @@ -174,41 +176,53 @@ public class AlterTableWithViewsIT extends SplitSystemCatalogIT { conn.createStatement().execute(generateDDL("UPDATE_CACHE_FREQUENCY=2", ddlFormat)); viewConn.createStatement().execute("CREATE VIEW " + viewOfTable1 + " ( VIEW_COL1 DECIMAL(10,2), VIEW_COL2 VARCHAR ) AS SELECT * FROM " + tableName); viewConn.createStatement().execute("CREATE VIEW " + viewOfTable2 + " ( VIEW_COL1 DECIMAL(10,2), VIEW_COL2 VARCHAR ) AS SELECT * FROM " + tableName); - - viewConn.createStatement().execute("ALTER VIEW " + viewOfTable2 + " SET UPDATE_CACHE_FREQUENCY = 1"); - - PhoenixConnection phoenixConn = conn.unwrap(PhoenixConnection.class); - PTable table = phoenixConn.getTable(new PTableKey(null, tableName)); PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; - assertFalse(table.isImmutableRows()); - assertEquals(2, table.getUpdateCacheFrequency()); + + // Initially all property values should be the same for the base table and its views + PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)); PTable viewTable1 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable1)); + PTable viewTable2 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); + assertFalse(table.isImmutableRows()); assertFalse(viewTable1.isImmutableRows()); + assertFalse(viewTable2.isImmutableRows()); + assertEquals(2, table.getUpdateCacheFrequency()); assertEquals(2, viewTable1.getUpdateCacheFrequency()); + assertEquals(2, viewTable2.getUpdateCacheFrequency()); + assertNull(table.useStatsForParallelization()); + assertNull(viewTable1.useStatsForParallelization()); + assertNull(viewTable2.useStatsForParallelization()); + + // Alter a property value for one of the views + viewConn.createStatement().execute("ALTER VIEW " + viewOfTable2 + + " SET UPDATE_CACHE_FREQUENCY=1, USE_STATS_FOR_PARALLELIZATION=false"); // query the view to force the table cache to be updated viewConn.createStatement().execute("SELECT * FROM "+viewOfTable2); - PTable viewTable2 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); - assertFalse(viewTable2.isImmutableRows()); + viewTable2 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); assertEquals(1, viewTable2.getUpdateCacheFrequency()); - - conn.createStatement().execute("ALTER TABLE " + tableName + " SET IMMUTABLE_ROWS=true, UPDATE_CACHE_FREQUENCY=3"); + assertFalse(viewTable2.useStatsForParallelization()); + + // Alter a property value for the base table. So the view for which this property was + // not modified earlier should get the base table's altered property value + conn.createStatement().execute("ALTER TABLE " + tableName + + " SET IMMUTABLE_ROWS=true, UPDATE_CACHE_FREQUENCY=3, " + + "USE_STATS_FOR_PARALLELIZATION=true"); // query the views to force the table cache to be updated viewConn.createStatement().execute("SELECT * FROM "+viewOfTable1); viewConn.createStatement().execute("SELECT * FROM "+viewOfTable2); - - phoenixConn = conn.unwrap(PhoenixConnection.class); - table = phoenixConn.getTable(new PTableKey(null, tableName)); - assertTrue(table.isImmutableRows()); - assertEquals(3, table.getUpdateCacheFrequency()); - + table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)); viewTable1 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable1)); - assertTrue(viewTable1.isImmutableRows()); - assertEquals(2, viewTable1.getUpdateCacheFrequency()); - viewTable2 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); + assertTrue(table.isImmutableRows()); + assertTrue(viewTable1.isImmutableRows()); assertTrue(viewTable2.isImmutableRows()); - // update cache frequency is not propagated to the view since it was altered on the view + assertEquals(3, table.getUpdateCacheFrequency()); + // The updated property value in the base table is reflected in this view + assertEquals(3, viewTable1.getUpdateCacheFrequency()); + // The update property is not propagated to this view since it was altered on the view assertEquals(1, viewTable2.getUpdateCacheFrequency()); + assertTrue(table.useStatsForParallelization()); + assertTrue(viewTable1.useStatsForParallelization()); + assertFalse(viewTable2.useStatsForParallelization()); long gpw = 1000000; conn.createStatement().execute("ALTER TABLE " + tableName + " SET GUIDE_POSTS_WIDTH=" + gpw); @@ -234,6 +248,67 @@ public class AlterTableWithViewsIT extends SplitSystemCatalogIT { assertTrue(rs.wasNull()); } } + + @Test + public void testCreateViewWithPropsMaintainsOwnProps() throws Exception { + try (Connection conn = DriverManager.getConnection(getUrl()); + Connection viewConn = isMultiTenant ? + DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn) { + String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); + String viewOfTable1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); + String viewOfTable2 = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); + + String ddlFormat = "CREATE TABLE IF NOT EXISTS " + tableName + " (" + + " %s ID char(1) NOT NULL," + " COL1 integer NOT NULL, COL2 bigint NOT NULL," + + " CONSTRAINT NAME_PK PRIMARY KEY (%s ID, COL1, COL2)) %s "; + conn.createStatement().execute(generateDDL("UPDATE_CACHE_FREQUENCY=2", ddlFormat)); + + viewConn.createStatement().execute("CREATE VIEW " + viewOfTable1 + + " ( VIEW_COL1 DECIMAL(10,2), VIEW_COL2 VARCHAR ) AS SELECT * FROM " + + tableName + " UPDATE_CACHE_FREQUENCY=7"); + viewConn.createStatement().execute("CREATE VIEW " + viewOfTable2 + + " ( VIEW_COL1 DECIMAL(10,2), VIEW_COL2 VARCHAR ) AS SELECT * FROM " + + tableName + " USE_STATS_FOR_PARALLELIZATION=true"); + PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; + + // Initially, property values not specified during view creation should be the same for + // the base table and its views those specified should have corresponding values + PTable table = conn.unwrap(PhoenixConnection.class) + .getTable(new PTableKey(null, tableName)); + PTable viewTable1 = viewConn.unwrap(PhoenixConnection.class) + .getTable(new PTableKey(tenantId, viewOfTable1)); + PTable viewTable2 = viewConn.unwrap(PhoenixConnection.class) + .getTable(new PTableKey(tenantId, viewOfTable2)); + assertEquals(2, table.getUpdateCacheFrequency()); + assertEquals(7, viewTable1.getUpdateCacheFrequency()); + assertEquals(2, viewTable2.getUpdateCacheFrequency()); + assertNull(table.useStatsForParallelization()); + assertNull(viewTable1.useStatsForParallelization()); + assertTrue(viewTable2.useStatsForParallelization()); + + // Alter a property value for the base table. So the view for which this property was + // not explicitly set or modified earlier should get the base table's new property value + conn.createStatement().execute("ALTER TABLE " + tableName + + " SET UPDATE_CACHE_FREQUENCY=3, USE_STATS_FOR_PARALLELIZATION=false"); + // query the views to force the table cache to be updated + viewConn.createStatement().execute("SELECT * FROM " + viewOfTable1); + viewConn.createStatement().execute("SELECT * FROM " + viewOfTable2); + table = conn.unwrap(PhoenixConnection.class) + .getTable(new PTableKey(null, tableName)); + viewTable1 = viewConn.unwrap(PhoenixConnection.class) + .getTable(new PTableKey(tenantId, viewOfTable1)); + viewTable2 = viewConn.unwrap(PhoenixConnection.class) + .getTable(new PTableKey(tenantId, viewOfTable2)); + assertEquals(3, table.getUpdateCacheFrequency()); + // The updated property value is only propagated to the view in which we did not specify + // a value for the property during view creation or alter its value later on + assertEquals(7, viewTable1.getUpdateCacheFrequency()); + assertEquals(3, viewTable2.getUpdateCacheFrequency()); + assertFalse(table.useStatsForParallelization()); + assertFalse(viewTable1.useStatsForParallelization()); + assertTrue(viewTable2.useStatsForParallelization()); + } + } @Test public void testDropColumnsFromBaseTableWithView() throws Exception { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 0dc4410..bd95dc1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -1220,12 +1220,8 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { tenantConn.createStatement().execute("CREATE VIEW " + tenantViewName + " AS SELECT * FROM " + viewName); conn.createStatement() .execute("ALTER TABLE " + tableName + " set USE_STATS_FOR_PARALLELIZATION=" + useStats); - // changing a property on a base table does not change the property on a view - validatePropertyOnViewIndex(viewName, viewIndexName, !useStats, conn, tenantConn); - - // need to explicitly change the property on the view - conn.createStatement() - .execute("ALTER VIEW " + viewName + " set USE_STATS_FOR_PARALLELIZATION=" + useStats); + // changing a property on a base table is propagated to its view + // if the view has not previously modified the property validatePropertyOnViewIndex(viewName, viewIndexName, useStats, conn, tenantConn); } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java index 66379d4..cf3c27e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java @@ -398,8 +398,10 @@ public class PropertiesInSyncIT extends ParallelStatsDisabledIT { } } // Now synchronize required properties and verify HBase metadata property values - syncTableAndIndexProperties(conn.unwrap(PhoenixConnection.class), - conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()); + PhoenixConnection upgradeConn = conn.unwrap(PhoenixConnection.class); + // Simulate an upgrade by setting the upgrade flag + upgradeConn.setRunningUpgrade(true); + syncTableAndIndexProperties(upgradeConn, upgradeConn.getQueryServices().getAdmin()); for (String t: createdTables) { verifyHBaseColumnFamilyProperties(t, conn, false, false); } 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 e56dd9d..fcf8547 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 @@ -59,7 +59,6 @@ import org.apache.phoenix.schema.PTable.IndexType; import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.IndexUtil; -import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.RepairUtil; @@ -157,7 +156,7 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver { for (PTable index : indexes) { if (index.getIndexType() == IndexType.LOCAL) { IndexMaintainer indexMaintainer = index.getIndexMaintainer(dataTable, conn); - indexMaintainers.put(new ImmutableBytesWritable(index.getViewIndexType().toBytes(index.getViewIndexId())), + indexMaintainers.put(new ImmutableBytesWritable(index.getviewIndexIdType().toBytes(index.getViewIndexId())), indexMaintainer); } } diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java index ed21374..d414205 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java @@ -156,7 +156,7 @@ public class DeleteCompiler { int offset = (table.getBucketNum() == null ? 0 : 1); byte[][] values = new byte[pkColumns.size()][]; if (isSharedViewIndex) { - values[offset++] = table.getViewIndexType().toBytes(table.getViewIndexId()); + values[offset++] = table.getviewIndexIdType().toBytes(table.getViewIndexId()); } if (isMultiTenant) { values[offset++] = tenantIdBytes; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java index 807e54b..b2b660e 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java @@ -1283,7 +1283,7 @@ public class JoinCompiler { .setMultiTenant(left.isMultiTenant()) .setStoreNulls(left.getStoreNulls()) .setViewType(left.getViewType()) - .setViewIndexType(left.getViewIndexType()) + .setViewIndexIdType(left.getviewIndexIdType()) .setViewIndexId(left.getViewIndexId()) .setIndexType(left.getIndexType()) .setTransactionProvider(left.getTransactionProvider()) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java index 5b92a5d..40a0ee4 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java @@ -18,7 +18,6 @@ package org.apache.phoenix.compile; import static org.apache.phoenix.query.QueryConstants.VALUE_COLUMN_FAMILY; import static org.apache.phoenix.query.QueryConstants.BASE_TABLE_BASE_COLUMN_COUNT; -import static org.apache.phoenix.schema.PTable.ImmutableStorageScheme; import java.sql.SQLException; import java.util.ArrayList; @@ -203,7 +202,7 @@ public class TupleProjectionCompiler { .setMultiTenant(table.isMultiTenant()) .setStoreNulls(table.getStoreNulls()) .setViewType(table.getViewType()) - .setViewIndexType(table.getViewIndexType()) + .setViewIndexIdType(table.getviewIndexIdType()) .setViewIndexId(table.getViewIndexId()) .setTransactionProvider(table.getTransactionProvider()) .setUpdateCacheFrequency(table.getUpdateCacheFrequency()) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java index 410ac22..a770339 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java @@ -753,7 +753,7 @@ public class UpsertCompiler { final byte[][] values = new byte[nValuesToSet][]; int nodeIndex = 0; if (isSharedViewIndex) { - values[nodeIndex++] = table.getViewIndexType().toBytes(table.getViewIndexId()); + values[nodeIndex++] = table.getviewIndexIdType().toBytes(table.getViewIndexId()); } if (isTenantSpecific) { PName tenantId = connection.getTenantId(); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java index b2e4c41..b845a09 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java @@ -69,7 +69,6 @@ import org.apache.phoenix.schema.types.PDataType; import org.apache.phoenix.schema.types.PVarbinary; import org.apache.phoenix.schema.types.PVarchar; import org.apache.phoenix.util.ByteUtil; -import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.ScanUtil; import org.apache.phoenix.util.SchemaUtil; @@ -179,7 +178,7 @@ public class WhereOptimizer { // Add unique index ID for shared indexes on views. This ensures // that different indexes don't interleave. if (hasViewIndex) { - byte[] viewIndexBytes = table.getViewIndexType().toBytes(table.getViewIndexId()); + byte[] viewIndexBytes = table.getviewIndexIdType().toBytes(table.getViewIndexId()); KeyRange indexIdKeyRange = KeyRange.getKeyRange(viewIndexBytes); cnf.add(Collections.singletonList(indexIdKeyRange)); pkPos++; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java index d138132..cd9efee 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java @@ -87,7 +87,6 @@ import java.security.PrivilegedExceptionAction; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; -import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -464,6 +463,9 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso // index for link type key value that is used to store linking rows private static final int LINK_TYPE_INDEX = 0; + // Used to add a tag to a cell when a view modifies a table property to indicate that this + // property should not be derived from the base table + private static final byte[] VIEW_MODIFIED_PROPERTY_BYTES = Bytes.toBytes(1); private static final KeyValue CLASS_NAME_KV = createFirstOnRow(ByteUtil.EMPTY_BYTE_ARRAY, TABLE_FAMILY_BYTES, CLASS_NAME_BYTES); private static final KeyValue JAR_PATH_KV = createFirstOnRow(ByteUtil.EMPTY_BYTE_ARRAY, TABLE_FAMILY_BYTES, JAR_PATH_BYTES); @@ -786,11 +788,12 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso // now go up from child to parent all the way to the base table: PTable baseTable = null; + PTable immediateParent = null; long maxTableTimestamp = -1; int numPKCols = table.getPKColumns().size(); for (int i = 0; i < ancestorList.size(); i++) { TableInfo parentTableInfo = ancestorList.get(i); - PTable pTable = null; + PTable pTable; String fullParentTableName = SchemaUtil.getTableName(parentTableInfo.getSchemaName(), parentTableInfo.getTableName()); PName parentTenantId = @@ -815,6 +818,9 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso if (pTable == null) { throw new ParentTableNotFoundException(parentTableInfo, fullTableName); } else { + if (immediateParent == null) { + immediateParent = pTable; + } // only combine columns for view indexes (and not local indexes on regular tables // which also have a viewIndexId) if (i == 0 && hasIndexId && pTable.getType() != PTableType.VIEW) { @@ -951,13 +957,21 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso isDiverged ? QueryConstants.DIVERGED_VIEW_BASE_COLUMN_COUNT : columnsToAdd.size() - myColumns.size() + (isSalted ? 1 : 0); + // Inherit view-modifiable properties from the parent table/view if the current view has + // not previously modified this property + Long updateCacheFreq = (table.getType() != PTableType.VIEW || + table.hasViewModifiedUpdateCacheFrequency()) ? + table.getUpdateCacheFrequency() : immediateParent.getUpdateCacheFrequency(); + Boolean useStatsForParallelization = (table.getType() != PTableType.VIEW || + table.hasViewModifiedUseStatsForParallelization()) ? + table.useStatsForParallelization() : immediateParent.useStatsForParallelization(); // When creating a PTable for views or view indexes, use the baseTable PTable for attributes // inherited from the physical base table. // if a TableProperty is not valid on a view we set it to the base table value // if a TableProperty is valid on a view and is not mutable on a view we set it to the base table value - // if a TableProperty is valid on a view and is mutable on a view we use the value set on the view - // TODO Implement PHOENIX-4763 to set the view properties correctly instead of just - // setting them same as the base table + // if a TableProperty is valid on a view and is mutable on a view, we use the value set + // on the view if the view had previously modified the property, otherwise we propagate the + // value from the base table (see PHOENIX-4763) PTableImpl pTable = PTableImpl.builderWithColumns(table, columnsToAdd) .setImmutableRows(baseTable.isImmutableRows()) .setDisableWAL(baseTable.isWALDisabled()) @@ -974,6 +988,8 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso .setTimeStamp(maxTableTimestamp) .setExcludedColumns(excludedColumns == null ? ImmutableList.<PColumn>of() : ImmutableList.copyOf(excludedColumns)) + .setUpdateCacheFrequency(updateCacheFreq) + .setUseStatsForParallelization(useStatsForParallelization) .build(); return WhereConstantParser.addViewInfoToPColumnsIfNeeded(pTable); } @@ -1436,8 +1452,8 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso } Cell viewTypeKv = tableKeyValues[VIEW_TYPE_INDEX]; ViewType viewType = viewTypeKv == null ? null : ViewType.fromSerializedValue(viewTypeKv.getValueArray()[viewTypeKv.getValueOffset()]); - PDataType viewIndexType = getViewIndexType(tableKeyValues); - Long viewIndexId = getViewIndexId(tableKeyValues, viewIndexType); + PDataType viewIndexIdType = getViewIndexIdType(tableKeyValues); + Long viewIndexId = getViewIndexId(tableKeyValues, viewIndexIdType); Cell indexTypeKv = tableKeyValues[INDEX_TYPE_INDEX]; IndexType indexType = indexTypeKv == null ? null : IndexType.fromSerializedValue(indexTypeKv.getValueArray()[indexTypeKv.getValueOffset()]); Cell baseColumnCountKv = tableKeyValues[BASE_COLUMN_COUNT_INDEX]; @@ -1449,6 +1465,12 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso long updateCacheFrequency = updateCacheFrequencyKv == null ? 0 : PLong.INSTANCE.getCodec().decodeLong(updateCacheFrequencyKv.getValueArray(), updateCacheFrequencyKv.getValueOffset(), SortOrder.getDefault()); + + // Check the cell tag to see whether the view has modified this property + final byte[] tagUpdateCacheFreq = (updateCacheFrequencyKv == null) ? + HConstants.EMPTY_BYTE_ARRAY : CellUtil.getTagArray(updateCacheFrequencyKv); + boolean viewModifiedUpdateCacheFrequency = (PTableType.VIEW.equals(tableType)) && + Bytes.contains(tagUpdateCacheFreq, VIEW_MODIFIED_PROPERTY_BYTES); Cell indexDisableTimestampKv = tableKeyValues[INDEX_DISABLE_TIMESTAMP]; long indexDisableTimestamp = indexDisableTimestampKv == null ? 0L : PLong.INSTANCE.getCodec().decodeLong(indexDisableTimestampKv.getValueArray(), indexDisableTimestampKv.getValueOffset(), SortOrder.getDefault()); @@ -1474,6 +1496,12 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso encodingSchemeKv.getValueOffset(), encodingSchemeKv.getValueLength())); Cell useStatsForParallelizationKv = tableKeyValues[USE_STATS_FOR_PARALLELIZATION_INDEX]; Boolean useStatsForParallelization = useStatsForParallelizationKv == null ? null : Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(useStatsForParallelizationKv.getValueArray(), useStatsForParallelizationKv.getValueOffset(), useStatsForParallelizationKv.getValueLength())); + + // Check the cell tag to see whether the view has modified this property + final byte[] tagUseStatsForParallelization = (useStatsForParallelizationKv == null) ? + HConstants.EMPTY_BYTE_ARRAY : CellUtil.getTagArray(useStatsForParallelizationKv); + boolean viewModifiedUseStatsForParallelization = (PTableType.VIEW.equals(tableType)) && + Bytes.contains(tagUseStatsForParallelization, VIEW_MODIFIED_PROPERTY_BYTES); List<PColumn> columns = Lists.newArrayListWithExpectedSize(columnCount); List<PTable> indexes = Lists.newArrayList(); @@ -1529,7 +1557,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso .setMultiTenant(multiTenant) .setStoreNulls(storeNulls) .setViewType(viewType) - .setViewIndexType(viewIndexType) + .setViewIndexIdType(viewIndexIdType) .setViewIndexId(viewIndexId) .setIndexType(indexType) .setTransactionProvider(transactionProvider) @@ -1557,28 +1585,30 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso .setParentTableName(parentTableName) .setPhysicalNames(physicalTables == null ? ImmutableList.<PName>of() : ImmutableList.copyOf(physicalTables)) + .setViewModifiedUpdateCacheFrequency(viewModifiedUpdateCacheFrequency) + .setViewModifiedUseStatsForParallelization(viewModifiedUseStatsForParallelization) .setColumns(columns) .build(); } - private Long getViewIndexId(Cell[] tableKeyValues, PDataType viewIndexType) { + private Long getViewIndexId(Cell[] tableKeyValues, PDataType viewIndexIdType) { Cell viewIndexIdKv = tableKeyValues[VIEW_INDEX_ID_INDEX]; return viewIndexIdKv == null ? null : - decodeViewIndexId(viewIndexIdKv, viewIndexType); + decodeViewIndexId(viewIndexIdKv, viewIndexIdType); } /** * Returns viewIndexId based on its underlying data type * - * @param tableKeyValues - * @param viewIndexType + * @param viewIndexIdKv + * @param viewIndexIdType * @return */ - private Long decodeViewIndexId(Cell viewIndexIdKv, PDataType viewIndexType) { - return viewIndexType.getCodec().decodeLong(viewIndexIdKv.getValueArray(), + private Long decodeViewIndexId(Cell viewIndexIdKv, PDataType viewIndexIdType) { + return viewIndexIdType.getCodec().decodeLong(viewIndexIdKv.getValueArray(), viewIndexIdKv.getValueOffset(), SortOrder.getDefault()); } - private PDataType getViewIndexType(Cell[] tableKeyValues) { + private PDataType getViewIndexIdType(Cell[] tableKeyValues) { Cell dataTypeKv = tableKeyValues[VIEW_INDEX_ID_DATA_TYPE_INDEX]; return dataTypeKv == null ? MetaDataUtil.getLegacyViewIndexIdDataType() : @@ -2349,6 +2379,12 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso return; } + if (tableType == PTableType.VIEW) { + // Pass in the parent's PTable so that we only tag cells corresponding to the + // view's property in case they are different from the parent + addTagsToPutsForViewAlteredProperties(tableMetadata, parentTable); + } + // When we drop a view we first drop the view metadata and then drop the parent->child linking row List<Mutation> localMutations = Lists.newArrayListWithExpectedSize(tableMetadata.size()); @@ -2406,7 +2442,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso builder.setReturnCode(MetaDataProtos.MutationCode.TABLE_NOT_FOUND); if (indexId != null) { builder.setViewIndexId(indexId); - builder.setViewIndexType(PLong.INSTANCE.getSqlType()); + builder.setViewIndexIdType(PLong.INSTANCE.getSqlType()); } builder.setMutationTime(currentTimeStamp); done.run(builder.build()); @@ -3514,19 +3550,23 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso } } tableMetaData.addAll(additionalTableMetadataMutations); - if (type == PTableType.VIEW - && EncodedColumnsUtil.usesEncodedColumnNames(table) && addingCol + if (type == PTableType.VIEW) { + if (EncodedColumnsUtil.usesEncodedColumnNames(table) && addingCol && !table.isAppendOnlySchema()) { - // When adding a column to a view that uses encoded column name - // scheme, we need to modify the CQ counters stored in the view's - // physical table. So to make sure clients get the latest PTable, we - // need to invalidate the cache entry. - // If the table uses APPEND_ONLY_SCHEMA we use the position of the - // column as the encoded column qualifier and so we don't need to - // update the CQ counter in the view physical table (see - // PHOENIX-4737) - invalidateList.add(new ImmutableBytesPtr( - MetaDataUtil.getPhysicalTableRowForView(table))); + // When adding a column to a view that uses encoded column name + // scheme, we need to modify the CQ counters stored in the view's + // physical table. So to make sure clients get the latest PTable, we + // need to invalidate the cache entry. + // If the table uses APPEND_ONLY_SCHEMA we use the position of the + // column as the encoded column qualifier and so we don't need to + // update the CQ counter in the view physical table (see + // PHOENIX-4737) + invalidateList.add(new ImmutableBytesPtr( + MetaDataUtil.getPhysicalTableRowForView(table))); + } + // Pass in null as the parent PTable, since we always want to tag the cells + // in this case, irrespective of the property values of the parent + addTagsToPutsForViewAlteredProperties(tableMetaData, null); } return null; } @@ -3541,6 +3581,44 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso } } + /** + * See PHOENIX-4763. If we are modifying any table-level properties that are mutable on a view, + * we mark these cells in SYSTEM.CATALOG with tags to indicate that this view property should + * not be kept in-sync with the base table and so we shouldn't propagate the base table's + * property value when resolving the view + * @param tableMetaData list of mutations on the view + * @param parent PTable of the parent or null + */ + private void addTagsToPutsForViewAlteredProperties(List<Mutation> tableMetaData, + PTable parent) { + byte[] parentUpdateCacheFreqBytes = null; + byte[] parentUseStatsForParallelizationBytes = null; + if (parent != null) { + parentUpdateCacheFreqBytes = new byte[PLong.INSTANCE.getByteSize()]; + PLong.INSTANCE.getCodec().encodeLong(parent.getUpdateCacheFrequency(), + parentUpdateCacheFreqBytes, 0); + if (parent.useStatsForParallelization() != null) { + parentUseStatsForParallelizationBytes = + PBoolean.INSTANCE.toBytes(parent.useStatsForParallelization()); + } + } + for (Mutation m: tableMetaData) { + if (m instanceof Put) { + MetaDataUtil.conditionallyAddTagsToPutCells((Put)m, + PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES, + PhoenixDatabaseMetaData.UPDATE_CACHE_FREQUENCY_BYTES, + parentUpdateCacheFreqBytes, + VIEW_MODIFIED_PROPERTY_BYTES); + MetaDataUtil.conditionallyAddTagsToPutCells((Put)m, + PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES, + PhoenixDatabaseMetaData.USE_STATS_FOR_PARALLELIZATION_BYTES, + parentUseStatsForParallelizationBytes, + VIEW_MODIFIED_PROPERTY_BYTES); + } + + } + } + private PTable doGetTable(byte[] tenantId, byte[] schemaName, byte[] tableName, long clientTimeStamp, int clientVersion) throws IOException, SQLException { return doGetTable(tenantId, schemaName, tableName, clientTimeStamp, null, clientVersion, diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java index 86878c2..4160b8b 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java @@ -175,7 +175,7 @@ public abstract class MetaDataProtocol extends MetaDataService { private PName tableName; private List<PColumn> columns; private List<PName> physicalNames; - private PDataType viewIndexType; + private PDataType viewIndexIdType; private Long viewIndexId; public SharedTableState(PTable table) { @@ -184,7 +184,7 @@ public abstract class MetaDataProtocol extends MetaDataService { this.tableName = table.getTableName(); this.columns = table.getColumns(); this.physicalNames = table.getPhysicalNames(); - this.viewIndexType = table.getViewIndexType(); + this.viewIndexIdType = table.getviewIndexIdType(); this.viewIndexId = table.getViewIndexId(); } @@ -208,8 +208,8 @@ public abstract class MetaDataProtocol extends MetaDataService { } }); this.viewIndexId = sharedTable.getViewIndexId(); - this.viewIndexType = sharedTable.hasViewIndexType() - ? PDataType.fromTypeId(sharedTable.getViewIndexType()) + this.viewIndexIdType = sharedTable.hasViewIndexIdType() + ? PDataType.fromTypeId(sharedTable.getViewIndexIdType()) : MetaDataUtil.getLegacyViewIndexIdDataType(); } @@ -237,8 +237,8 @@ public abstract class MetaDataProtocol extends MetaDataService { return viewIndexId; } - public PDataType getViewIndexType() { - return viewIndexType; + public PDataType getViewIndexIdType() { + return viewIndexIdType; } } @@ -253,7 +253,7 @@ public abstract class MetaDataProtocol extends MetaDataService { private boolean wasUpdated; private PSchema schema; private Long viewIndexId; - private PDataType viewIndexType; + private PDataType viewIndexIdType; private List<PFunction> functions = new ArrayList<PFunction>(1); private long autoPartitionNum; @@ -298,10 +298,10 @@ public abstract class MetaDataProtocol extends MetaDataService { this.tableNamesToDelete = tableNamesToDelete; } - public MetaDataMutationResult(MutationCode returnCode, int currentTime, PTable table, long viewIndexId, PDataType viewIndexType ) { + public MetaDataMutationResult(MutationCode returnCode, int currentTime, PTable table, long viewIndexId, PDataType viewIndexIdType) { this(returnCode, currentTime, table, Collections.<byte[]> emptyList()); this.viewIndexId = viewIndexId; - this.viewIndexType = viewIndexType; + this.viewIndexIdType = viewIndexIdType; } public MetaDataMutationResult(MutationCode returnCode, long currentTime, PTable table, List<byte[]> tableNamesToDelete, List<SharedTableState> sharedTablesToDelete) { @@ -361,8 +361,8 @@ public abstract class MetaDataProtocol extends MetaDataService { return viewIndexId; } - public PDataType getViewIndexType() { - return viewIndexType; + public PDataType getViewIndexIdType() { + return viewIndexIdType; } public static MetaDataMutationResult constructFromProto(MetaDataResponse proto) { @@ -410,8 +410,8 @@ public abstract class MetaDataProtocol extends MetaDataService { result.viewIndexId = proto.getViewIndexId(); } - result.viewIndexType = proto.hasViewIndexType() - ? PDataType.fromTypeId(proto.getViewIndexType()) + result.viewIndexIdType = proto.hasViewIndexIdType() + ? PDataType.fromTypeId(proto.getViewIndexIdType()) : MetaDataUtil.getLegacyViewIndexIdDataType(); return result; } @@ -453,7 +453,7 @@ public abstract class MetaDataProtocol extends MetaDataService { sharedTableStateBuilder.setSchemaName(ByteStringer.wrap(sharedTableState.getSchemaName().getBytes())); sharedTableStateBuilder.setTableName(ByteStringer.wrap(sharedTableState.getTableName().getBytes())); sharedTableStateBuilder.setViewIndexId(sharedTableState.getViewIndexId()); - sharedTableStateBuilder.setViewIndexType(sharedTableState.viewIndexType.getSqlType()); + sharedTableStateBuilder.setViewIndexIdType(sharedTableState.viewIndexIdType.getSqlType()); builder.addSharedTablesToDelete(sharedTableStateBuilder.build()); } } @@ -464,9 +464,9 @@ public abstract class MetaDataProtocol extends MetaDataService { if (result.getViewIndexId() != null) { builder.setViewIndexId(result.getViewIndexId()); } - builder.setViewIndexType(result.getViewIndexType() == null + builder.setViewIndexIdType(result.getViewIndexIdType() == null ? MetaDataUtil.getLegacyViewIndexIdDataType().getSqlType() - : result.getViewIndexType().getSqlType()); + : result.getViewIndexIdType().getSqlType()); } return builder.build(); } diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/MetaDataProtos.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/MetaDataProtos.java index 360dd77..d8152a9 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/MetaDataProtos.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/MetaDataProtos.java @@ -379,15 +379,15 @@ public final class MetaDataProtos { */ long getViewIndexId(); - // optional int32 viewIndexType = 7 [default = 5]; + // optional int32 viewIndexIdType = 7 [default = 5]; /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - boolean hasViewIndexType(); + boolean hasViewIndexIdType(); /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - int getViewIndexType(); + int getViewIndexIdType(); } /** * Protobuf type {@code SharedTableState} @@ -478,7 +478,7 @@ public final class MetaDataProtos { } case 56: { bitField0_ |= 0x00000010; - viewIndexType_ = input.readInt32(); + viewIndexIdType_ = input.readInt32(); break; } } @@ -650,20 +650,20 @@ public final class MetaDataProtos { return viewIndexId_; } - // optional int32 viewIndexType = 7 [default = 5]; - public static final int VIEWINDEXTYPE_FIELD_NUMBER = 7; - private int viewIndexType_; + // optional int32 viewIndexIdType = 7 [default = 5]; + public static final int VIEWINDEXIDTYPE_FIELD_NUMBER = 7; + private int viewIndexIdType_; /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField0_ & 0x00000010) == 0x00000010); } /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } private void initFields() { @@ -673,7 +673,7 @@ public final class MetaDataProtos { columns_ = java.util.Collections.emptyList(); physicalNames_ = java.util.Collections.emptyList(); viewIndexId_ = 0L; - viewIndexType_ = 5; + viewIndexIdType_ = 5; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -724,7 +724,7 @@ public final class MetaDataProtos { output.writeInt64(6, viewIndexId_); } if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeInt32(7, viewIndexType_); + output.writeInt32(7, viewIndexIdType_); } getUnknownFields().writeTo(output); } @@ -766,7 +766,7 @@ public final class MetaDataProtos { } if (((bitField0_ & 0x00000010) == 0x00000010)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(7, viewIndexType_); + .computeInt32Size(7, viewIndexIdType_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -815,10 +815,10 @@ public final class MetaDataProtos { result = result && (getViewIndexId() == other.getViewIndexId()); } - result = result && (hasViewIndexType() == other.hasViewIndexType()); - if (hasViewIndexType()) { - result = result && (getViewIndexType() - == other.getViewIndexType()); + result = result && (hasViewIndexIdType() == other.hasViewIndexIdType()); + if (hasViewIndexIdType()) { + result = result && (getViewIndexIdType() + == other.getViewIndexIdType()); } result = result && getUnknownFields().equals(other.getUnknownFields()); @@ -857,9 +857,9 @@ public final class MetaDataProtos { hash = (37 * hash) + VIEWINDEXID_FIELD_NUMBER; hash = (53 * hash) + hashLong(getViewIndexId()); } - if (hasViewIndexType()) { - hash = (37 * hash) + VIEWINDEXTYPE_FIELD_NUMBER; - hash = (53 * hash) + getViewIndexType(); + if (hasViewIndexIdType()) { + hash = (37 * hash) + VIEWINDEXIDTYPE_FIELD_NUMBER; + hash = (53 * hash) + getViewIndexIdType(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; @@ -987,7 +987,7 @@ public final class MetaDataProtos { bitField0_ = (bitField0_ & ~0x00000010); viewIndexId_ = 0L; bitField0_ = (bitField0_ & ~0x00000020); - viewIndexType_ = 5; + viewIndexIdType_ = 5; bitField0_ = (bitField0_ & ~0x00000040); return this; } @@ -1050,7 +1050,7 @@ public final class MetaDataProtos { if (((from_bitField0_ & 0x00000040) == 0x00000040)) { to_bitField0_ |= 0x00000010; } - result.viewIndexType_ = viewIndexType_; + result.viewIndexIdType_ = viewIndexIdType_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -1115,8 +1115,8 @@ public final class MetaDataProtos { if (other.hasViewIndexId()) { setViewIndexId(other.getViewIndexId()); } - if (other.hasViewIndexType()) { - setViewIndexType(other.getViewIndexType()); + if (other.hasViewIndexIdType()) { + setViewIndexIdType(other.getViewIndexIdType()); } this.mergeUnknownFields(other.getUnknownFields()); return this; @@ -1616,35 +1616,35 @@ public final class MetaDataProtos { return this; } - // optional int32 viewIndexType = 7 [default = 5]; - private int viewIndexType_ = 5; + // optional int32 viewIndexIdType = 7 [default = 5]; + private int viewIndexIdType_ = 5; /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField0_ & 0x00000040) == 0x00000040); } /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - public Builder setViewIndexType(int value) { + public Builder setViewIndexIdType(int value) { bitField0_ |= 0x00000040; - viewIndexType_ = value; + viewIndexIdType_ = value; onChanged(); return this; } /** - * <code>optional int32 viewIndexType = 7 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 7 [default = 5];</code> */ - public Builder clearViewIndexType() { + public Builder clearViewIndexIdType() { bitField0_ = (bitField0_ & ~0x00000040); - viewIndexType_ = 5; + viewIndexIdType_ = 5; onChanged(); return this; } @@ -1825,15 +1825,15 @@ public final class MetaDataProtos { */ long getViewIndexId(); - // optional int32 viewIndexType = 13 [default = 5]; + // optional int32 viewIndexIdType = 13 [default = 5]; /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - boolean hasViewIndexType(); + boolean hasViewIndexIdType(); /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - int getViewIndexType(); + int getViewIndexIdType(); } /** * Protobuf type {@code MetaDataResponse} @@ -1979,7 +1979,7 @@ public final class MetaDataProtos { } case 104: { bitField0_ |= 0x00000200; - viewIndexType_ = input.readInt32(); + viewIndexIdType_ = input.readInt32(); break; } } @@ -2282,20 +2282,20 @@ public final class MetaDataProtos { return viewIndexId_; } - // optional int32 viewIndexType = 13 [default = 5]; - public static final int VIEWINDEXTYPE_FIELD_NUMBER = 13; - private int viewIndexType_; + // optional int32 viewIndexIdType = 13 [default = 5]; + public static final int VIEWINDEXIDTYPE_FIELD_NUMBER = 13; + private int viewIndexIdType_; /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField0_ & 0x00000200) == 0x00000200); } /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } private void initFields() { @@ -2311,7 +2311,7 @@ public final class MetaDataProtos { schema_ = org.apache.phoenix.coprocessor.generated.PSchemaProtos.PSchema.getDefaultInstance(); autoPartitionNum_ = 0L; viewIndexId_ = 0L; - viewIndexType_ = 5; + viewIndexIdType_ = 5; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -2386,7 +2386,7 @@ public final class MetaDataProtos { output.writeInt64(12, viewIndexId_); } if (((bitField0_ & 0x00000200) == 0x00000200)) { - output.writeInt32(13, viewIndexType_); + output.writeInt32(13, viewIndexIdType_); } getUnknownFields().writeTo(output); } @@ -2452,7 +2452,7 @@ public final class MetaDataProtos { } if (((bitField0_ & 0x00000200) == 0x00000200)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(13, viewIndexType_); + .computeInt32Size(13, viewIndexIdType_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -2528,10 +2528,10 @@ public final class MetaDataProtos { result = result && (getViewIndexId() == other.getViewIndexId()); } - result = result && (hasViewIndexType() == other.hasViewIndexType()); - if (hasViewIndexType()) { - result = result && (getViewIndexType() - == other.getViewIndexType()); + result = result && (hasViewIndexIdType() == other.hasViewIndexIdType()); + if (hasViewIndexIdType()) { + result = result && (getViewIndexIdType() + == other.getViewIndexIdType()); } result = result && getUnknownFields().equals(other.getUnknownFields()); @@ -2594,9 +2594,9 @@ public final class MetaDataProtos { hash = (37 * hash) + VIEWINDEXID_FIELD_NUMBER; hash = (53 * hash) + hashLong(getViewIndexId()); } - if (hasViewIndexType()) { - hash = (37 * hash) + VIEWINDEXTYPE_FIELD_NUMBER; - hash = (53 * hash) + getViewIndexType(); + if (hasViewIndexIdType()) { + hash = (37 * hash) + VIEWINDEXIDTYPE_FIELD_NUMBER; + hash = (53 * hash) + getViewIndexIdType(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; @@ -2751,7 +2751,7 @@ public final class MetaDataProtos { bitField0_ = (bitField0_ & ~0x00000400); viewIndexId_ = 0L; bitField0_ = (bitField0_ & ~0x00000800); - viewIndexType_ = 5; + viewIndexIdType_ = 5; bitField0_ = (bitField0_ & ~0x00001000); return this; } @@ -2851,7 +2851,7 @@ public final class MetaDataProtos { if (((from_bitField0_ & 0x00001000) == 0x00001000)) { to_bitField0_ |= 0x00000200; } - result.viewIndexType_ = viewIndexType_; + result.viewIndexIdType_ = viewIndexIdType_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -2957,8 +2957,8 @@ public final class MetaDataProtos { if (other.hasViewIndexId()) { setViewIndexId(other.getViewIndexId()); } - if (other.hasViewIndexType()) { - setViewIndexType(other.getViewIndexType()); + if (other.hasViewIndexIdType()) { + setViewIndexIdType(other.getViewIndexIdType()); } this.mergeUnknownFields(other.getUnknownFields()); return this; @@ -4040,35 +4040,35 @@ public final class MetaDataProtos { return this; } - // optional int32 viewIndexType = 13 [default = 5]; - private int viewIndexType_ = 5; + // optional int32 viewIndexIdType = 13 [default = 5]; + private int viewIndexIdType_ = 5; /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField0_ & 0x00001000) == 0x00001000); } /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - public Builder setViewIndexType(int value) { + public Builder setViewIndexIdType(int value) { bitField0_ |= 0x00001000; - viewIndexType_ = value; + viewIndexIdType_ = value; onChanged(); return this; } /** - * <code>optional int32 viewIndexType = 13 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 13 [default = 5];</code> */ - public Builder clearViewIndexType() { + public Builder clearViewIndexIdType() { bitField0_ = (bitField0_ & ~0x00001000); - viewIndexType_ = 5; + viewIndexIdType_ = 5; onChanged(); return this; } @@ -17827,105 +17827,105 @@ public final class MetaDataProtos { static { java.lang.String[] descriptorData = { "\n\025MetaDataService.proto\032\014PTable.proto\032\017P" + - "Function.proto\032\rPSchema.proto\"\254\001\n\020Shared" + + "Function.proto\032\rPSchema.proto\"\256\001\n\020Shared" + "TableState\022\020\n\010tenantId\030\001 \001(\014\022\022\n\nschemaNa" + "me\030\002 \002(\014\022\021\n\ttableName\030\003 \002(\014\022\031\n\007columns\030\004" + " \003(\0132\010.PColumn\022\025\n\rphysicalNames\030\005 \003(\014\022\023\n" + - "\013viewIndexId\030\006 \002(\003\022\030\n\rviewIndexType\030\007 \001(" + - "\005:\0015\"\353\002\n\020MetaDataResponse\022!\n\nreturnCode\030" + - "\001 \001(\0162\r.MutationCode\022\024\n\014mutationTime\030\002 \001" + - "(\003\022\026\n\005table\030\003 \001(\0132\007.PTable\022\026\n\016tablesToDe" + - "lete\030\004 \003(\014\022\022\n\ncolumnName\030\005 \001(\014\022\022\n\nfamily", - "Name\030\006 \001(\014\022\024\n\014functionName\030\007 \001(\014\022\034\n\010func" + - "tion\030\010 \003(\0132\n.PFunction\022/\n\024sharedTablesTo" + - "Delete\030\t \003(\0132\021.SharedTableState\022\030\n\006schem" + - "a\030\n \001(\0132\010.PSchema\022\030\n\020autoPartitionNum\030\013 " + - "\001(\003\022\023\n\013viewIndexId\030\014 \001(\003\022\030\n\rviewIndexTyp" + - "e\030\r \001(\005:\0015\"\364\001\n\017GetTableRequest\022\020\n\010tenant" + - "Id\030\001 \002(\014\022\022\n\nschemaName\030\002 \002(\014\022\021\n\ttableNam" + - "e\030\003 \002(\014\022\026\n\016tableTimestamp\030\004 \002(\003\022\027\n\017clien" + - "tTimestamp\030\005 \002(\003\022\025\n\rclientVersion\030\006 \001(\005\022" + - "\037\n\027skipAddingParentColumns\030\007 \001(\010\022\031\n\021skip", - "AddingIndexes\030\010 \001(\010\022$\n\023lockedAncestorTab" + - "le\030\t \001(\0132\007.PTable\"\212\001\n\023GetFunctionsReques" + - "t\022\020\n\010tenantId\030\001 \002(\014\022\025\n\rfunctionNames\030\002 \003" + - "(\014\022\032\n\022functionTimestamps\030\003 \003(\003\022\027\n\017client" + - "Timestamp\030\004 \002(\003\022\025\n\rclientVersion\030\005 \001(\005\"V" + - "\n\020GetSchemaRequest\022\022\n\nschemaName\030\001 \002(\t\022\027" + - "\n\017clientTimestamp\030\002 \002(\003\022\025\n\rclientVersion" + - "\030\003 \002(\005\"d\n\022CreateTableRequest\022\036\n\026tableMet" + + "\013viewIndexId\030\006 \002(\003\022\032\n\017viewIndexIdType\030\007 " + + "\001(\005:\0015\"\355\002\n\020MetaDataResponse\022!\n\nreturnCod" + + "e\030\001 \001(\0162\r.MutationCode\022\024\n\014mutationTime\030\002" + + " \001(\003\022\026\n\005table\030\003 \001(\0132\007.PTable\022\026\n\016tablesTo" + + "Delete\030\004 \003(\014\022\022\n\ncolumnName\030\005 \001(\014\022\022\n\nfami", + "lyName\030\006 \001(\014\022\024\n\014functionName\030\007 \001(\014\022\034\n\010fu" + + "nction\030\010 \003(\0132\n.PFunction\022/\n\024sharedTables" + + "ToDelete\030\t \003(\0132\021.SharedTableState\022\030\n\006sch" + + "ema\030\n \001(\0132\010.PSchema\022\030\n\020autoPartitionNum\030" + + "\013 \001(\003\022\023\n\013viewIndexId\030\014 \001(\003\022\032\n\017viewIndexI" + + "dType\030\r \001(\005:\0015\"\364\001\n\017GetTableRequest\022\020\n\010te" + + "nantId\030\001 \002(\014\022\022\n\nschemaName\030\002 \002(\014\022\021\n\ttabl" + + "eName\030\003 \002(\014\022\026\n\016tableTimestamp\030\004 \002(\003\022\027\n\017c" + + "lientTimestamp\030\005 \002(\003\022\025\n\rclientVersion\030\006 " + + "\001(\005\022\037\n\027skipAddingParentColumns\030\007 \001(\010\022\031\n\021", + "skipAddingIndexes\030\010 \001(\010\022$\n\023lockedAncesto" + + "rTable\030\t \001(\0132\007.PTable\"\212\001\n\023GetFunctionsRe" + + "quest\022\020\n\010tenantId\030\001 \002(\014\022\025\n\rfunctionNames" + + "\030\002 \003(\014\022\032\n\022functionTimestamps\030\003 \003(\003\022\027\n\017cl" + + "ientTimestamp\030\004 \002(\003\022\025\n\rclientVersion\030\005 \001" + + "(\005\"V\n\020GetSchemaRequest\022\022\n\nschemaName\030\001 \002" + + "(\t\022\027\n\017clientTimestamp\030\002 \002(\003\022\025\n\rclientVer" + + "sion\030\003 \002(\005\"d\n\022CreateTableRequest\022\036\n\026tabl" + + "eMetadataMutations\030\001 \003(\014\022\025\n\rclientVersio" + + "n\030\002 \001(\005\022\027\n\017allocateIndexId\030\003 \001(\010\"r\n\025Crea", + "teFunctionRequest\022\036\n\026tableMetadataMutati" + + "ons\030\001 \003(\014\022\021\n\ttemporary\030\002 \002(\010\022\017\n\007replace\030" + + "\003 \001(\010\022\025\n\rclientVersion\030\004 \001(\005\"`\n\023CreateSc" + + "hemaRequest\022\036\n\026tableMetadataMutations\030\001 " + + "\003(\014\022\022\n\nschemaName\030\002 \002(\t\022\025\n\rclientVersion" + + "\030\003 \002(\005\"\216\001\n\020DropTableRequest\022\036\n\026tableMeta" + + "dataMutations\030\001 \003(\014\022\021\n\ttableType\030\002 \002(\t\022\017" + + "\n\007cascade\030\003 \001(\010\022\025\n\rclientVersion\030\004 \001(\005\022\037" + + "\n\027skipAddingParentColumns\030\005 \001(\010\"_\n\021DropS" + + "chemaRequest\022\037\n\027schemaMetadataMutations\030", + "\001 \003(\014\022\022\n\nschemaName\030\002 \002(\t\022\025\n\rclientVersi" + + "on\030\003 \002(\005\"I\n\020AddColumnRequest\022\036\n\026tableMet" + "adataMutations\030\001 \003(\014\022\025\n\rclientVersion\030\002 " + - "\001(\005\022\027\n\017allocateIndexId\030\003 \001(\010\"r\n\025CreateFu", - "nctionRequest\022\036\n\026tableMetadataMutations\030" + - "\001 \003(\014\022\021\n\ttemporary\030\002 \002(\010\022\017\n\007replace\030\003 \001(" + - "\010\022\025\n\rclientVersion\030\004 \001(\005\"`\n\023CreateSchema" + - "Request\022\036\n\026tableMetadataMutations\030\001 \003(\014\022" + - "\022\n\nschemaName\030\002 \002(\t\022\025\n\rclientVersion\030\003 \002" + - "(\005\"\216\001\n\020DropTableRequest\022\036\n\026tableMetadata" + - "Mutations\030\001 \003(\014\022\021\n\ttableType\030\002 \002(\t\022\017\n\007ca" + - "scade\030\003 \001(\010\022\025\n\rclientVersion\030\004 \001(\005\022\037\n\027sk" + - "ipAddingParentColumns\030\005 \001(\010\"_\n\021DropSchem" + - "aRequest\022\037\n\027schemaMetadataMutations\030\001 \003(", - "\014\022\022\n\nschemaName\030\002 \002(\t\022\025\n\rclientVersion\030\003" + - " \002(\005\"I\n\020AddColumnRequest\022\036\n\026tableMetadat" + + "\001(\005\"J\n\021DropColumnRequest\022\036\n\026tableMetadat" + "aMutations\030\001 \003(\014\022\025\n\rclientVersion\030\002 \001(\005\"" + - "J\n\021DropColumnRequest\022\036\n\026tableMetadataMut" + - "ations\030\001 \003(\014\022\025\n\rclientVersion\030\002 \001(\005\"^\n\023D" + - "ropFunctionRequest\022\036\n\026tableMetadataMutat" + - "ions\030\001 \003(\014\022\020\n\010ifExists\030\002 \001(\010\022\025\n\rclientVe" + - "rsion\030\003 \001(\005\"P\n\027UpdateIndexStateRequest\022\036" + - "\n\026tableMetadataMutations\030\001 \003(\014\022\025\n\rclient" + - "Version\030\002 \001(\005\"*\n\021ClearCacheRequest\022\025\n\rcl", - "ientVersion\030\001 \001(\005\"*\n\022ClearCacheResponse\022" + - "\024\n\014unfreedBytes\030\001 \001(\003\"*\n\021GetVersionReque" + - "st\022\025\n\rclientVersion\030\001 \001(\005\"E\n\022GetVersionR" + - "esponse\022\017\n\007version\030\001 \002(\003\022\036\n\026systemCatalo" + - "gTimestamp\030\002 \001(\003\"\205\001\n\032ClearTableFromCache" + - "Request\022\020\n\010tenantId\030\001 \002(\014\022\022\n\nschemaName\030" + - "\002 \002(\014\022\021\n\ttableName\030\003 \002(\014\022\027\n\017clientTimest" + - "amp\030\004 \002(\003\022\025\n\rclientVersion\030\005 \001(\005\"\035\n\033Clea" + - "rTableFromCacheResponse*\271\005\n\014MutationCode" + - "\022\030\n\024TABLE_ALREADY_EXISTS\020\000\022\023\n\017TABLE_NOT_", - "FOUND\020\001\022\024\n\020COLUMN_NOT_FOUND\020\002\022\031\n\025COLUMN_" + - "ALREADY_EXISTS\020\003\022\035\n\031CONCURRENT_TABLE_MUT" + - "ATION\020\004\022\027\n\023TABLE_NOT_IN_REGION\020\005\022\025\n\021NEWE" + - "R_TABLE_FOUND\020\006\022\034\n\030UNALLOWED_TABLE_MUTAT" + - "ION\020\007\022\021\n\rNO_PK_COLUMNS\020\010\022\032\n\026PARENT_TABLE" + - "_NOT_FOUND\020\t\022\033\n\027FUNCTION_ALREADY_EXISTS\020" + - "\n\022\026\n\022FUNCTION_NOT_FOUND\020\013\022\030\n\024NEWER_FUNCT" + - "ION_FOUND\020\014\022\032\n\026FUNCTION_NOT_IN_REGION\020\r\022" + - "\031\n\025SCHEMA_ALREADY_EXISTS\020\016\022\026\n\022NEWER_SCHE" + - "MA_FOUND\020\017\022\024\n\020SCHEMA_NOT_FOUND\020\020\022\030\n\024SCHE", - "MA_NOT_IN_REGION\020\021\022\032\n\026TABLES_EXIST_ON_SC" + - "HEMA\020\022\022\035\n\031UNALLOWED_SCHEMA_MUTATION\020\023\022%\n" + - "!AUTO_PARTITION_SEQUENCE_NOT_FOUND\020\024\022#\n\037" + - "CANNOT_COERCE_AUTO_PARTITION_ID\020\025\022\024\n\020TOO" + - "_MANY_INDEXES\020\026\022\037\n\033UNABLE_TO_CREATE_CHIL" + - "D_LINK\020\027\022!\n\035UNABLE_TO_UPDATE_PARENT_TABL" + - "E\020\0302\345\006\n\017MetaDataService\022/\n\010getTable\022\020.Ge" + - "tTableRequest\032\021.MetaDataResponse\0227\n\014getF" + - "unctions\022\024.GetFunctionsRequest\032\021.MetaDat" + - "aResponse\0221\n\tgetSchema\022\021.GetSchemaReques", - "t\032\021.MetaDataResponse\0225\n\013createTable\022\023.Cr" + - "eateTableRequest\032\021.MetaDataResponse\022;\n\016c" + - "reateFunction\022\026.CreateFunctionRequest\032\021." + - "MetaDataResponse\0227\n\014createSchema\022\024.Creat" + - "eSchemaRequest\032\021.MetaDataResponse\0221\n\tdro" + - "pTable\022\021.DropTableRequest\032\021.MetaDataResp" + - "onse\0223\n\ndropSchema\022\022.DropSchemaRequest\032\021" + - ".MetaDataResponse\0227\n\014dropFunction\022\024.Drop" + - "FunctionRequest\032\021.MetaDataResponse\0221\n\tad" + - "dColumn\022\021.AddColumnRequest\032\021.MetaDataRes", - "ponse\0223\n\ndropColumn\022\022.DropColumnRequest\032" + - "\021.MetaDataResponse\022?\n\020updateIndexState\022\030" + - ".UpdateIndexStateRequest\032\021.MetaDataRespo" + - "nse\0225\n\nclearCache\022\022.ClearCacheRequest\032\023." + - "ClearCacheResponse\0225\n\ngetVersion\022\022.GetVe" + - "rsionRequest\032\023.GetVersionResponse\022P\n\023cle" + - "arTableFromCache\022\033.ClearTableFromCacheRe" + - "quest\032\034.ClearTableFromCacheResponseBB\n(o" + - "rg.apache.phoenix.coprocessor.generatedB" + - "\016MetaDataProtosH\001\210\001\001\240\001\001" + "^\n\023DropFunctionRequest\022\036\n\026tableMetadataM" + + "utations\030\001 \003(\014\022\020\n\010ifExists\030\002 \001(\010\022\025\n\rclie" + + "ntVersion\030\003 \001(\005\"P\n\027UpdateIndexStateReque" + + "st\022\036\n\026tableMetadataMutations\030\001 \003(\014\022\025\n\rcl" + + "ientVersion\030\002 \001(\005\"*\n\021ClearCacheRequest\022\025", + "\n\rclientVersion\030\001 \001(\005\"*\n\022ClearCacheRespo" + + "nse\022\024\n\014unfreedBytes\030\001 \001(\003\"*\n\021GetVersionR" + + "equest\022\025\n\rclientVersion\030\001 \001(\005\"E\n\022GetVers" + + "ionResponse\022\017\n\007version\030\001 \002(\003\022\036\n\026systemCa" + + "talogTimestamp\030\002 \001(\003\"\205\001\n\032ClearTableFromC" + + "acheRequest\022\020\n\010tenantId\030\001 \002(\014\022\022\n\nschemaN" + + "ame\030\002 \002(\014\022\021\n\ttableName\030\003 \002(\014\022\027\n\017clientTi" + + "mestamp\030\004 \002(\003\022\025\n\rclientVersion\030\005 \001(\005\"\035\n\033" + + "ClearTableFromCacheResponse*\271\005\n\014Mutation" + + "Code\022\030\n\024TABLE_ALREADY_EXISTS\020\000\022\023\n\017TABLE_", + "NOT_FOUND\020\001\022\024\n\020COLUMN_NOT_FOUND\020\002\022\031\n\025COL" + + "UMN_ALREADY_EXISTS\020\003\022\035\n\031CONCURRENT_TABLE" + + "_MUTATION\020\004\022\027\n\023TABLE_NOT_IN_REGION\020\005\022\025\n\021" + + "NEWER_TABLE_FOUND\020\006\022\034\n\030UNALLOWED_TABLE_M" + + "UTATION\020\007\022\021\n\rNO_PK_COLUMNS\020\010\022\032\n\026PARENT_T" + + "ABLE_NOT_FOUND\020\t\022\033\n\027FUNCTION_ALREADY_EXI" + + "STS\020\n\022\026\n\022FUNCTION_NOT_FOUND\020\013\022\030\n\024NEWER_F" + + "UNCTION_FOUND\020\014\022\032\n\026FUNCTION_NOT_IN_REGIO" + + "N\020\r\022\031\n\025SCHEMA_ALREADY_EXISTS\020\016\022\026\n\022NEWER_" + + "SCHEMA_FOUND\020\017\022\024\n\020SCHEMA_NOT_FOUND\020\020\022\030\n\024", + "SCHEMA_NOT_IN_REGION\020\021\022\032\n\026TABLES_EXIST_O" + + "N_SCHEMA\020\022\022\035\n\031UNALLOWED_SCHEMA_MUTATION\020" + + "\023\022%\n!AUTO_PARTITION_SEQUENCE_NOT_FOUND\020\024" + + "\022#\n\037CANNOT_COERCE_AUTO_PARTITION_ID\020\025\022\024\n" + + "\020TOO_MANY_INDEXES\020\026\022\037\n\033UNABLE_TO_CREATE_" + + "CHILD_LINK\020\027\022!\n\035UNABLE_TO_UPDATE_PARENT_" + + "TABLE\020\0302\345\006\n\017MetaDataService\022/\n\010getTable\022" + + "\020.GetTableRequest\032\021.MetaDataResponse\0227\n\014" + + "getFunctions\022\024.GetFunctionsRequest\032\021.Met" + + "aDataResponse\0221\n\tgetSchema\022\021.GetSchemaRe", + "quest\032\021.MetaDataResponse\0225\n\013createTable\022" + + "\023.CreateTableRequest\032\021.MetaDataResponse\022" + + ";\n\016createFunction\022\026.CreateFunctionReques" + + "t\032\021.MetaDataResponse\0227\n\014createSchema\022\024.C" + + "reateSchemaRequest\032\021.MetaDataResponse\0221\n" + + "\tdropTable\022\021.DropTableRequest\032\021.MetaData" + + "Response\0223\n\ndropSchema\022\022.DropSchemaReque" + + "st\032\021.MetaDataResponse\0227\n\014dropFunction\022\024." + + "DropFunctionRequest\032\021.MetaDataResponse\0221" + + "\n\taddColumn\022\021.AddColumnRequest\032\021.MetaDat", + "aResponse\0223\n\ndropColumn\022\022.DropColumnRequ" + + "est\032\021.MetaDataResponse\022?\n\020updateIndexSta" + + "te\022\030.UpdateIndexStateRequest\032\021.MetaDataR" + + "esponse\0225\n\nclearCache\022\022.ClearCacheReques" + + "t\032\023.ClearCacheResponse\0225\n\ngetVersion\022\022.G" + + "etVersionRequest\032\023.GetVersionResponse\022P\n" + + "\023clearTableFromCache\022\033.ClearTableFromCac" + + "heRequest\032\034.ClearTableFromCacheResponseB" + + "B\n(org.apache.phoenix.coprocessor.genera" + + "tedB\016MetaDataProtosH\001\210\001\001\240\001\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -17937,13 +17937,13 @@ public final class MetaDataProtos { internal_static_SharedTableState_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_SharedTableState_descriptor, - new java.lang.String[] { "TenantId", "SchemaName", "TableName", "Columns", "PhysicalNames", "ViewIndexId", "ViewIndexType", }); + new java.lang.String[] { "TenantId", "SchemaName", "TableName", "Columns", "PhysicalNames", "ViewIndexId", "ViewIndexIdType", }); internal_static_MetaDataResponse_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_MetaDataResponse_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_MetaDataResponse_descriptor, - new java.lang.String[] { "ReturnCode", "MutationTime", "Table", "TablesToDelete", "ColumnName", "FamilyName", "FunctionName", "Function", "SharedTablesToDelete", "Schema", "AutoPartitionNum", "ViewIndexId", "ViewIndexType", }); + new java.lang.String[] { "ReturnCode", "MutationTime", "Table", "TablesToDelete", "ColumnName", "FamilyName", "FunctionName", "Function", "SharedTablesToDelete", "Schema", "AutoPartitionNum", "ViewIndexId", "ViewIndexIdType", }); internal_static_GetTableRequest_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_GetTableRequest_fieldAccessorTable = new diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/PTableProtos.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/PTableProtos.java index 938ae1f..4a3b43f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/PTableProtos.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/PTableProtos.java @@ -3695,15 +3695,15 @@ public final class PTableProtos { */ int getTransactionProvider(); - // optional int32 viewIndexType = 39 [default = 5]; + // optional int32 viewIndexIdType = 39 [default = 5]; /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - boolean hasViewIndexType(); + boolean hasViewIndexIdType(); /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - int getViewIndexType(); + int getViewIndexIdType(); } /** * Protobuf type {@code PTable} @@ -3962,7 +3962,7 @@ public final class PTableProtos { } case 312: { bitField1_ |= 0x00000002; - viewIndexType_ = input.readInt32(); + viewIndexIdType_ = input.readInt32(); break; } } @@ -4745,20 +4745,20 @@ public final class PTableProtos { return transactionProvider_; } - // optional int32 viewIndexType = 39 [default = 5]; - public static final int VIEWINDEXTYPE_FIELD_NUMBER = 39; - private int viewIndexType_; + // optional int32 viewIndexIdType = 39 [default = 5]; + public static final int VIEWINDEXIDTYPE_FIELD_NUMBER = 39; + private int viewIndexIdType_; /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField1_ & 0x00000002) == 0x00000002); } /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } private void initFields() { @@ -4799,7 +4799,7 @@ public final class PTableProtos { encodedCQCounters_ = java.util.Collections.emptyList(); useStatsForParallelization_ = false; transactionProvider_ = 0; - viewIndexType_ = 5; + viewIndexIdType_ = 5; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -4979,7 +4979,7 @@ public final class PTableProtos { output.writeInt32(38, transactionProvider_); } if (((bitField1_ & 0x00000002) == 0x00000002)) { - output.writeInt32(39, viewIndexType_); + output.writeInt32(39, viewIndexIdType_); } getUnknownFields().writeTo(output); } @@ -5145,7 +5145,7 @@ public final class PTableProtos { } if (((bitField1_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(39, viewIndexType_); + .computeInt32Size(39, viewIndexIdType_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -5343,10 +5343,10 @@ public final class PTableProtos { result = result && (getTransactionProvider() == other.getTransactionProvider()); } - result = result && (hasViewIndexType() == other.hasViewIndexType()); - if (hasViewIndexType()) { - result = result && (getViewIndexType() - == other.getViewIndexType()); + result = result && (hasViewIndexIdType() == other.hasViewIndexIdType()); + if (hasViewIndexIdType()) { + result = result && (getViewIndexIdType() + == other.getViewIndexIdType()); } result = result && getUnknownFields().equals(other.getUnknownFields()); @@ -5509,9 +5509,9 @@ public final class PTableProtos { hash = (37 * hash) + TRANSACTIONPROVIDER_FIELD_NUMBER; hash = (53 * hash) + getTransactionProvider(); } - if (hasViewIndexType()) { - hash = (37 * hash) + VIEWINDEXTYPE_FIELD_NUMBER; - hash = (53 * hash) + getViewIndexType(); + if (hasViewIndexIdType()) { + hash = (37 * hash) + VIEWINDEXIDTYPE_FIELD_NUMBER; + hash = (53 * hash) + getViewIndexIdType(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; @@ -5711,7 +5711,7 @@ public final class PTableProtos { bitField1_ = (bitField1_ & ~0x00000008); transactionProvider_ = 0; bitField1_ = (bitField1_ & ~0x00000010); - viewIndexType_ = 5; + viewIndexIdType_ = 5; bitField1_ = (bitField1_ & ~0x00000020); return this; } @@ -5910,7 +5910,7 @@ public final class PTableProtos { if (((from_bitField1_ & 0x00000020) == 0x00000020)) { to_bitField1_ |= 0x00000002; } - result.viewIndexType_ = viewIndexType_; + result.viewIndexIdType_ = viewIndexIdType_; result.bitField0_ = to_bitField0_; result.bitField1_ = to_bitField1_; onBuilt(); @@ -6119,8 +6119,8 @@ public final class PTableProtos { if (other.hasTransactionProvider()) { setTransactionProvider(other.getTransactionProvider()); } - if (other.hasViewIndexType()) { - setViewIndexType(other.getViewIndexType()); + if (other.hasViewIndexIdType()) { + setViewIndexIdType(other.getViewIndexIdType()); } this.mergeUnknownFields(other.getUnknownFields()); return this; @@ -8234,35 +8234,35 @@ public final class PTableProtos { return this; } - // optional int32 viewIndexType = 39 [default = 5]; - private int viewIndexType_ = 5; + // optional int32 viewIndexIdType = 39 [default = 5]; + private int viewIndexIdType_ = 5; /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField1_ & 0x00000020) == 0x00000020); } /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - public Builder setViewIndexType(int value) { + public Builder setViewIndexIdType(int value) { bitField1_ |= 0x00000020; - viewIndexType_ = value; + viewIndexIdType_ = value; onChanged(); return this; } /** - * <code>optional int32 viewIndexType = 39 [default = 5];</code> + * <code>optional int32 viewIndexIdType = 39 [default = 5];</code> */ - public Builder clearViewIndexType() { + public Builder clearViewIndexIdType() { bitField1_ = (bitField1_ & ~0x00000020); - viewIndexType_ = 5; + viewIndexIdType_ = 5; onChanged(); return this; } @@ -8936,7 +8936,7 @@ public final class PTableProtos { "es\030\002 \003(\014\022\033\n\023guidePostsByteCount\030\003 \001(\003\022\025\n" + "\rkeyBytesCount\030\004 \001(\003\022\027\n\017guidePostsCount\030" + "\005 \001(\005\022!\n\013pGuidePosts\030\006 \001(\0132\014.PGuidePosts" + - "\"\307\007\n\006PTable\022\027\n\017schemaNameBytes\030\001 \002(\014\022\026\n\016" + + "\"\311\007\n\006PTable\022\027\n\017schemaNameBytes\030\001 \002(\014\022\026\n\016" + "tableNameBytes\030\002 \002(\014\022\036\n\ttableType\030\003 \002(\0162" + "\013.PTableType\022\022\n\nindexState\030\004 \001(\t\022\026\n\016sequ" + "enceNumber\030\005 \002(\003\022\021\n\ttimeStamp\030\006 \002(\003\022\023\n\013p" + @@ -8959,12 +8959,13 @@ public final class PTableProtos { "eme\030\" \001(\014\022\026\n\016encodingScheme\030# \001(\014\022,\n\021enc" + "odedCQCounters\030$ \003(\0132\021.EncodedCQCounter\022" + "\"\n\032useStatsForParallelization\030% \001(\010\022\033\n\023t" + - "ransactionProvider\030& \001(\005\022\030\n\rviewIndexTyp" + - "e\030\' \001(\005:\0015\"6\n\020EncodedCQCounter\022\021\n\tcolFam" + - "ily\030\001 \002(\t\022\017\n\007counter\030\002 \002(\005*A\n\nPTableType", - "\022\n\n\006SYSTEM\020\000\022\010\n\004USER\020\001\022\010\n\004VIEW\020\002\022\t\n\005INDE" + - "X\020\003\022\010\n\004JOIN\020\004B@\n(org.apache.phoenix.copr" + - "ocessor.generatedB\014PTableProtosH\001\210\001\001\240\001\001" + "ransactionProvider\030& \001(\005\022\032\n\017viewIndexIdT" + + "ype\030\' \001(\005:\0015\"6\n\020EncodedCQCounter\022\021\n\tcolF" + + "amily\030\001 \002(\t\022\017\n\007counter\030\002 \002(\005*A\n\nPTableTy", + "pe\022\n\n\006SYSTEM\020\000\022\010\n\004USER\020\001\022\010\n\004VIEW\020\002\022\t\n\005IN" + + "DEX\020\003\022\010\n\004JOIN\020\004B@\n(org.apache.phoenix.co" + + "processor.generatedB\014PTableProtosH\001\210\001\001\240\001" + + "\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -8988,7 +8989,7 @@ public final class PTableProtos { internal_static_PTable_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_PTable_descriptor, - new java.lang.String[] { "SchemaNameBytes", "TableNameBytes", "TableType", "IndexState", "SequenceNumber", "TimeStamp", "PkNameBytes", "BucketNum", "Columns", "Indexes", "IsImmutableRows", "DataTableNameBytes", "DefaultFamilyName", "DisableWAL", "MultiTenant", "ViewType", "ViewStatement", "PhysicalNames", "TenantId", "ViewIndexId", "IndexType", "StatsTimeStamp", "StoreNulls", "BaseColumnCount", "RowKeyOrderOptimizable", "Transactional", "UpdateCacheFrequency", "IndexDisable [...] + new java.lang.String[] { "SchemaNameBytes", "TableNameBytes", "TableType", "IndexState", "SequenceNumber", "TimeStamp", "PkNameBytes", "BucketNum", "Columns", "Indexes", "IsImmutableRows", "DataTableNameBytes", "DefaultFamilyName", "DisableWAL", "MultiTenant", "ViewType", "ViewStatement", "PhysicalNames", "TenantId", "ViewIndexId", "IndexType", "StatsTimeStamp", "StoreNulls", "BaseColumnCount", "RowKeyOrderOptimizable", "Transactional", "UpdateCacheFrequency", "IndexDisable [...] internal_static_EncodedCQCounter_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_EncodedCQCounter_fieldAccessorTable = new diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java index c42b9df..138be15 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java @@ -2158,15 +2158,15 @@ public final class ServerCachingProtos { */ int getImmutableStorageScheme(); - // optional int32 viewIndexType = 22; + // optional int32 viewIndexIdType = 22; /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - boolean hasViewIndexType(); + boolean hasViewIndexIdType(); /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - int getViewIndexType(); + int getViewIndexIdType(); } /** * Protobuf type {@code IndexMaintainer} @@ -2362,7 +2362,7 @@ public final class ServerCachingProtos { } case 176: { bitField0_ |= 0x00010000; - viewIndexType_ = input.readInt32(); + viewIndexIdType_ = input.readInt32(); break; } } @@ -2849,20 +2849,20 @@ public final class ServerCachingProtos { return immutableStorageScheme_; } - // optional int32 viewIndexType = 22; - public static final int VIEWINDEXTYPE_FIELD_NUMBER = 22; - private int viewIndexType_; + // optional int32 viewIndexIdType = 22; + public static final int VIEWINDEXIDTYPE_FIELD_NUMBER = 22; + private int viewIndexIdType_; /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField0_ & 0x00010000) == 0x00010000); } /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } private void initFields() { @@ -2887,7 +2887,7 @@ public final class ServerCachingProtos { indexedColumnInfo_ = java.util.Collections.emptyList(); encodingScheme_ = 0; immutableStorageScheme_ = 0; - viewIndexType_ = 0; + viewIndexIdType_ = 0; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -3049,7 +3049,7 @@ public final class ServerCachingProtos { output.writeInt32(21, immutableStorageScheme_); } if (((bitField0_ & 0x00010000) == 0x00010000)) { - output.writeInt32(22, viewIndexType_); + output.writeInt32(22, viewIndexIdType_); } getUnknownFields().writeTo(output); } @@ -3151,7 +3151,7 @@ public final class ServerCachingProtos { } if (((bitField0_ & 0x00010000) == 0x00010000)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(22, viewIndexType_); + .computeInt32Size(22, viewIndexIdType_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -3266,10 +3266,10 @@ public final class ServerCachingProtos { result = result && (getImmutableStorageScheme() == other.getImmutableStorageScheme()); } - result = result && (hasViewIndexType() == other.hasViewIndexType()); - if (hasViewIndexType()) { - result = result && (getViewIndexType() - == other.getViewIndexType()); + result = result && (hasViewIndexIdType() == other.hasViewIndexIdType()); + if (hasViewIndexIdType()) { + result = result && (getViewIndexIdType() + == other.getViewIndexIdType()); } result = result && getUnknownFields().equals(other.getUnknownFields()); @@ -3368,9 +3368,9 @@ public final class ServerCachingProtos { hash = (37 * hash) + IMMUTABLESTORAGESCHEME_FIELD_NUMBER; hash = (53 * hash) + getImmutableStorageScheme(); } - if (hasViewIndexType()) { - hash = (37 * hash) + VIEWINDEXTYPE_FIELD_NUMBER; - hash = (53 * hash) + getViewIndexType(); + if (hasViewIndexIdType()) { + hash = (37 * hash) + VIEWINDEXIDTYPE_FIELD_NUMBER; + hash = (53 * hash) + getViewIndexIdType(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; @@ -3548,7 +3548,7 @@ public final class ServerCachingProtos { bitField0_ = (bitField0_ & ~0x00080000); immutableStorageScheme_ = 0; bitField0_ = (bitField0_ & ~0x00100000); - viewIndexType_ = 0; + viewIndexIdType_ = 0; bitField0_ = (bitField0_ & ~0x00200000); return this; } @@ -3690,7 +3690,7 @@ public final class ServerCachingProtos { if (((from_bitField0_ & 0x00200000) == 0x00200000)) { to_bitField0_ |= 0x00010000; } - result.viewIndexType_ = viewIndexType_; + result.viewIndexIdType_ = viewIndexIdType_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -3869,8 +3869,8 @@ public final class ServerCachingProtos { if (other.hasImmutableStorageScheme()) { setImmutableStorageScheme(other.getImmutableStorageScheme()); } - if (other.hasViewIndexType()) { - setViewIndexType(other.getViewIndexType()); + if (other.hasViewIndexIdType()) { + setViewIndexIdType(other.getViewIndexIdType()); } this.mergeUnknownFields(other.getUnknownFields()); return this; @@ -5636,35 +5636,35 @@ public final class ServerCachingProtos { return this; } - // optional int32 viewIndexType = 22; - private int viewIndexType_ ; + // optional int32 viewIndexIdType = 22; + private int viewIndexIdType_ ; /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - public boolean hasViewIndexType() { + public boolean hasViewIndexIdType() { return ((bitField0_ & 0x00200000) == 0x00200000); } /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - public int getViewIndexType() { - return viewIndexType_; + public int getViewIndexIdType() { + return viewIndexIdType_; } /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - public Builder setViewIndexType(int value) { + public Builder setViewIndexIdType(int value) { bitField0_ |= 0x00200000; - viewIndexType_ = value; + viewIndexIdType_ = value; onChanged(); return this; } /** - * <code>optional int32 viewIndexType = 22;</code> + * <code>optional int32 viewIndexIdType = 22;</code> */ - public Builder clearViewIndexType() { + public Builder clearViewIndexIdType() { bitField0_ = (bitField0_ & ~0x00200000); - viewIndexType_ = 0; + viewIndexIdType_ = 0; onChanged(); return this; } @@ -8795,7 +8795,7 @@ public final class ServerCachingProtos { "ength\030\003 \002(\005\"4\n\017ColumnReference\022\016\n\006family" + "\030\001 \002(\014\022\021\n\tqualifier\030\002 \002(\014\"4\n\nColumnInfo\022" + "\022\n\nfamilyName\030\001 \001(\t\022\022\n\ncolumnName\030\002 \002(\t\"" + - "\335\005\n\017IndexMaintainer\022\023\n\013saltBuckets\030\001 \002(\005" + + "\337\005\n\017IndexMaintainer\022\023\n\013saltBuckets\030\001 \002(\005" + "\022\025\n\risMultiTenant\030\002 \002(\010\022\023\n\013viewIndexId\030\003" + " \001(\014\022(\n\016indexedColumns\030\004 \003(\0132\020.ColumnRef" + "erence\022 \n\030indexedColumnTypeOrdinal\030\005 \003(\005", @@ -8812,24 +8812,24 @@ public final class ServerCachingProtos { "ed\030\020 \002(\010\022\033\n\023indexRowKeyByteSize\030\021 \002(\005\022\021\n" + "\timmutable\030\022 \002(\010\022&\n\021indexedColumnInfo\030\023 " + "\003(\0132\013.ColumnInfo\022\026\n\016encodingScheme\030\024 \002(\005" + - "\022\036\n\026immutableStorageScheme\030\025 \002(\005\022\025\n\rview" + - "IndexType\030\026 \001(\005\"\370\001\n\025AddServerCacheReques" + - "t\022\020\n\010tenantId\030\001 \001(\014\022\017\n\007cacheId\030\002 \002(\014\022)\n\010" + - "cachePtr\030\003 \002(\0132\027.ImmutableBytesWritable\022" + - ")\n\014cacheFactory\030\004 \002(\0132\023.ServerCacheFacto" + - "ry\022\017\n\007txState\030\005 \001(\014\022\"\n\032hasProtoBufIndexM" + - "aintainer\030\006 \001(\010\022\025\n\rclientVersion\030\007 \001(\005\022\032", - "\n\022usePersistentCache\030\010 \001(\010\"(\n\026AddServerC" + - "acheResponse\022\016\n\006return\030\001 \002(\010\"=\n\030RemoveSe" + - "rverCacheRequest\022\020\n\010tenantId\030\001 \001(\014\022\017\n\007ca" + - "cheId\030\002 \002(\014\"+\n\031RemoveServerCacheResponse" + - "\022\016\n\006return\030\001 \002(\0102\245\001\n\024ServerCachingServic" + - "e\022A\n\016addServerCache\022\026.AddServerCacheRequ" + - "est\032\027.AddServerCacheResponse\022J\n\021removeSe" + - "rverCache\022\031.RemoveServerCacheRequest\032\032.R" + - "emoveServerCacheResponseBG\n(org.apache.p" + - "hoenix.coprocessor.generatedB\023ServerCach", - "ingProtosH\001\210\001\001\240\001\001" + "\022\036\n\026immutableStorageScheme\030\025 \002(\005\022\027\n\017view" + + "IndexIdType\030\026 \001(\005\"\370\001\n\025AddServerCacheRequ" + + "est\022\020\n\010tenantId\030\001 \001(\014\022\017\n\007cacheId\030\002 \002(\014\022)" + + "\n\010cachePtr\030\003 \002(\0132\027.ImmutableBytesWritabl" + + "e\022)\n\014cacheFactory\030\004 \002(\0132\023.ServerCacheFac" + + "tory\022\017\n\007txState\030\005 \001(\014\022\"\n\032hasProtoBufInde" + + "xMaintainer\030\006 \001(\010\022\025\n\rclientVersion\030\007 \001(\005", + "\022\032\n\022usePersistentCache\030\010 \001(\010\"(\n\026AddServe" + + "rCacheResponse\022\016\n\006return\030\001 \002(\010\"=\n\030Remove" + + "ServerCacheRequest\022\020\n\010tenantId\030\001 \001(\014\022\017\n\007" + + "cacheId\030\002 \002(\014\"+\n\031RemoveServerCacheRespon" + + "se\022\016\n\006return\030\001 \002(\0102\245\001\n\024ServerCachingServ" + + "ice\022A\n\016addServerCache\022\026.AddServerCacheRe" + + "quest\032\027.AddServerCacheResponse\022J\n\021remove" + + "ServerCache\022\031.RemoveServerCacheRequest\032\032" + + ".RemoveServerCacheResponseBG\n(org.apache" + + ".phoenix.coprocessor.generatedB\023ServerCa", + "chingProtosH\001\210\001\001\240\001\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -8859,7 +8859,7 @@ public final class ServerCachingProtos { internal_static_IndexMaintainer_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_IndexMaintainer_descriptor, - new java.lang.String[] { "SaltBuckets", "IsMultiTenant", "ViewIndexId", "IndexedColumns", "IndexedColumnTypeOrdinal", "DataTableColRefForCoveredColumns", "IndexTableColRefForCoveredColumns", "IsLocalIndex", "IndexTableName", "RowKeyOrderOptimizable", "DataTableEmptyKeyValueColFamily", "EmptyKeyValueColFamily", "IndexedExpressions", "RowKeyMetadata", "NumDataTableColFamilies", "IndexWalDisabled", "IndexRowKeyByteSize", "Immutable", "IndexedColumnInfo", "EncodingScheme", "Imm [...] + new java.lang.String[] { "SaltBuckets", "IsMultiTenant", "ViewIndexId", "IndexedColumns", "IndexedColumnTypeOrdinal", "DataTableColRefForCoveredColumns", "IndexTableColRefForCoveredColumns", "IsLocalIndex", "IndexTableName", "RowKeyOrderOptimizable", "DataTableEmptyKeyValueColFamily", "EmptyKeyValueColFamily", "IndexedExpressions", "RowKeyMetadata", "NumDataTableColFamilies", "IndexWalDisabled", "IndexRowKeyByteSize", "Immutable", "IndexedColumnInfo", "EncodingScheme", "Imm [...] internal_static_AddServerCacheRequest_descriptor = getDescriptor().getMessageTypes().get(4); internal_static_AddServerCacheRequest_fieldAccessorTable = new 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 d1da5f1..d3d14d8 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 @@ -318,7 +318,7 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> { } private byte[] viewIndexId; - private PDataType viewIndexType; + private PDataType viewIndexIdType; private boolean isMultiTenant; // indexed expressions that are not present in the row key of the data table, the expression can also refer to a regular column private List<Expression> indexedExpressions; @@ -376,8 +376,8 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> { this(dataTable.getRowKeySchema(), dataTable.getBucketNum() != null); this.rowKeyOrderOptimizable = index.rowKeyOrderOptimizable(); this.isMultiTenant = dataTable.isMultiTenant(); - this.viewIndexId = index.getViewIndexId() == null ? null : index.getViewIndexType().toBytes(index.getViewIndexId()); - this.viewIndexType = index.getViewIndexType(); + this.viewIndexId = index.getViewIndexId() == null ? null : index.getviewIndexIdType().toBytes(index.getViewIndexId()); + this.viewIndexIdType = index.getviewIndexIdType(); this.isLocalIndex = index.getIndexType() == IndexType.LOCAL; this.encodingScheme = index.getEncodingScheme(); @@ -829,7 +829,7 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> { @Override public PDataType getDataType() { - return viewIndexType; + return viewIndexIdType; } @Override @@ -1228,7 +1228,7 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> { // Fixed length //Use legacy viewIndexIdType for clients older than 4.10 release viewIndexId = new byte[MetaDataUtil.getLegacyViewIndexIdDataType().getByteSize()]; - viewIndexType = MetaDataUtil.getLegacyViewIndexIdDataType(); + viewIndexIdType = MetaDataUtil.getLegacyViewIndexIdDataType(); input.readFully(viewIndexId); } int nIndexedColumns = Math.abs(encodedIndexedColumnsAndViewId) - 1; @@ -1345,8 +1345,8 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> { maintainer.nIndexSaltBuckets = proto.getSaltBuckets(); maintainer.isMultiTenant = proto.getIsMultiTenant(); maintainer.viewIndexId = proto.hasViewIndexId() ? proto.getViewIndexId().toByteArray() : null; - maintainer.viewIndexType = proto.hasViewIndexType() - ? PDataType.fromTypeId(proto.getViewIndexType()) + maintainer.viewIndexIdType = proto.hasViewIndexIdType() + ? PDataType.fromTypeId(proto.getViewIndexIdType()) : MetaDataUtil.getLegacyViewIndexIdDataType(); List<ServerCachingProtos.ColumnReference> indexedColumnsList = proto.getIndexedColumnsList(); maintainer.indexedColumns = new HashSet<ColumnReference>(indexedColumnsList.size()); @@ -1467,7 +1467,7 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> { builder.setIsMultiTenant(maintainer.isMultiTenant); if (maintainer.viewIndexId != null) { builder.setViewIndexId(ByteStringer.wrap(maintainer.viewIndexId)); - builder.setViewIndexType(maintainer.viewIndexType.getSqlType()); + builder.setViewIndexIdType(maintainer.viewIndexIdType.getSqlType()); } for (ColumnReference colRef : maintainer.indexedColumns) { ServerCachingProtos.ColumnReference.Builder cRefBuilder = ServerCachingProtos.ColumnReference.newBuilder(); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java index 2d0c22c..172c2d6 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java @@ -320,7 +320,7 @@ public class PhoenixIndexFailurePolicy extends DelegateIndexFailurePolicy { for (PTable index : indexes) { if (index.getIndexType() == IndexType.LOCAL) { localIndex = index; - localIndexNames.put(new ImmutableBytesWritable(index.getViewIndexType().toBytes( + localIndexNames.put(new ImmutableBytesWritable(index.getviewIndexIdType().toBytes( index.getViewIndexId())), index.getName().getString()); } } diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateTable.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateTable.java index bf2bc59..34a973f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateTable.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateTable.java @@ -218,8 +218,8 @@ public class DelegateTable implements PTable { } @Override - public PDataType getViewIndexType() { - return delegate.getViewIndexType(); + public PDataType getviewIndexIdType() { + return delegate.getviewIndexIdType(); } @Override @@ -332,4 +332,12 @@ public class DelegateTable implements PTable { public Boolean useStatsForParallelization() { return delegate.useStatsForParallelization(); } + + @Override public boolean hasViewModifiedUpdateCacheFrequency() { + return delegate.hasViewModifiedUpdateCacheFrequency(); + } + + @Override public boolean hasViewModifiedUseStatsForParallelization() { + return delegate.hasViewModifiedUseStatsForParallelization(); + } } diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java index 4b7c9af..67a4928 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java @@ -99,6 +99,7 @@ import static org.apache.phoenix.query.QueryConstants.ENCODED_CQ_COUNTER_INITIAL import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RUN_UPDATE_STATS_ASYNC; +import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_USE_STATS_FOR_PARALLELIZATION; import static org.apache.phoenix.schema.PTable.EncodedCQCounter.NULL_COUNTER; import static org.apache.phoenix.schema.PTable.ImmutableStorageScheme.ONE_CELL_PER_COLUMN; import static org.apache.phoenix.schema.PTable.ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS; @@ -1077,7 +1078,7 @@ public class MetaDataClient { } } - public MutationState createTable(CreateTableStatement statement, byte[][] splits, PTable parent, String viewStatement, ViewType viewType, PDataType viewIndexType, byte[][] viewColumnConstants, BitSet isViewColumnReferenced) throws SQLException { + public MutationState createTable(CreateTableStatement statement, byte[][] splits, PTable parent, String viewStatement, ViewType viewType, PDataType viewIndexIdType, byte[][] viewColumnConstants, BitSet isViewColumnReferenced) throws SQLException { TableName tableName = statement.getTableName(); Map<String,Object> tableProps = Maps.newHashMapWithExpectedSize(statement.getProps().size()); Map<String,Object> commonFamilyProps = Maps.newHashMapWithExpectedSize(statement.getProps().size() + 1); @@ -1086,19 +1087,20 @@ public class MetaDataClient { boolean isAppendOnlySchema = false; long updateCacheFrequency = connection.getQueryServices().getProps().getLong( QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, QueryServicesOptions.DEFAULT_UPDATE_CACHE_FREQUENCY); + Long updateCacheFrequencyProp = (Long) TableProperty.UPDATE_CACHE_FREQUENCY.getValue(tableProps); if (parent==null) { Boolean appendOnlySchemaProp = (Boolean) TableProperty.APPEND_ONLY_SCHEMA.getValue(tableProps); if (appendOnlySchemaProp != null) { isAppendOnlySchema = appendOnlySchemaProp; } - Long updateCacheFrequencyProp = (Long) TableProperty.UPDATE_CACHE_FREQUENCY.getValue(tableProps); if (updateCacheFrequencyProp != null) { updateCacheFrequency = updateCacheFrequencyProp; } } else { isAppendOnlySchema = parent.isAppendOnlySchema(); - updateCacheFrequency = parent.getUpdateCacheFrequency(); + updateCacheFrequency = (updateCacheFrequencyProp != null) ? + updateCacheFrequencyProp : parent.getUpdateCacheFrequency(); } // updateCacheFrequency cannot be set to ALWAYS if isAppendOnlySchema is true if (isAppendOnlySchema && updateCacheFrequency==0) { @@ -1138,7 +1140,7 @@ public class MetaDataClient { true, NamedTableNode.create(statement.getTableName()), statement.getTableType()); } } - table = createTableInternal(statement, splits, parent, viewStatement, viewType, viewIndexType, viewColumnConstants, isViewColumnReferenced, false, null, null, tableProps, commonFamilyProps); + table = createTableInternal(statement, splits, parent, viewStatement, viewType, viewIndexIdType, viewColumnConstants, isViewColumnReferenced, false, null, null, tableProps, commonFamilyProps); if (table == null || table.getType() == PTableType.VIEW /*|| table.isTransactional()*/) { return new MutationState(0, 0, connection); @@ -1986,7 +1988,7 @@ public class MetaDataClient { } private PTable createTableInternal(CreateTableStatement statement, byte[][] splits, - final PTable parent, String viewStatement, ViewType viewType, PDataType viewIndexType, + final PTable parent, String viewStatement, ViewType viewType, PDataType viewIndexIdType, final byte[][] viewColumnConstants, final BitSet isViewColumnReferenced, boolean allocateIndexId, IndexType indexType, Date asyncCreatedDate, Map<String,Object> tableProps, @@ -2680,7 +2682,7 @@ public class MetaDataClient { .setDisableWAL(Boolean.TRUE.equals(disableWAL)) .setMultiTenant(false) .setStoreNulls(false) - .setViewIndexType(viewIndexType) + .setViewIndexIdType(viewIndexIdType) .setIndexType(indexType) .setUpdateCacheFrequency(0) .setNamespaceMapped(isNamespaceMapped) @@ -2999,7 +3001,7 @@ public class MetaDataClient { .setMultiTenant(multiTenant) .setStoreNulls(storeNulls) .setViewType(viewType) - .setViewIndexType(viewIndexType) + .setViewIndexIdType(viewIndexIdType) .setViewIndexId(result.getViewIndexId()) .setIndexType(indexType) .setTransactionProvider(transactionProvider) @@ -3029,6 +3031,13 @@ public class MetaDataClient { .setPhysicalNames(physicalNames == null ? ImmutableList.<PName>of() : ImmutableList.copyOf(physicalNames)) .setColumns(columns.values()) + .setViewModifiedUpdateCacheFrequency(tableType == PTableType.VIEW && + parent != null && + parent.getUpdateCacheFrequency() != updateCacheFrequency) + .setViewModifiedUseStatsForParallelization(tableType == PTableType.VIEW && + parent != null && + parent.useStatsForParallelization() + != useStatsForParallelizationProp) .build(); result = new MetaDataMutationResult(code, result.getMutationTime(), table, true); addTableToCache(result); @@ -4178,7 +4187,7 @@ public class MetaDataClient { .setType(PTableType.INDEX) .setTimeStamp(ts) .setMultiTenant(table.isMultiTenant()) - .setViewIndexType(sharedTableState.getViewIndexType()) + .setViewIndexIdType(sharedTableState.getViewIndexIdType()) .setViewIndexId(sharedTableState.getViewIndexId()) .setNamespaceMapped(table.isNamespaceMapped()) .setAppendOnlySchema(false) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java index 6dfe411..3e22225 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java @@ -736,7 +736,7 @@ public interface PTable extends PMetaDataEntity { ViewType getViewType(); String getViewStatement(); Long getViewIndexId(); - PDataType getViewIndexType(); + PDataType getviewIndexIdType(); PTableKey getKey(); IndexType getIndexType(); @@ -774,7 +774,9 @@ public interface PTable extends PMetaDataEntity { QualifierEncodingScheme getEncodingScheme(); EncodedCQCounter getEncodedCQCounter(); Boolean useStatsForParallelization(); - + boolean hasViewModifiedUpdateCacheFrequency(); + boolean hasViewModifiedUseStatsForParallelization(); + /** * Class to help track encoded column qualifier counters per column family. */ diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java index 7939b97..8b2b4ff 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java @@ -26,6 +26,7 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +import java.util.BitSet; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -101,6 +102,8 @@ import com.google.common.collect.Maps; */ public class PTableImpl implements PTable { private static final Integer NO_SALTING = -1; + private static final int VIEW_MODIFIED_UPDATE_CACHE_FREQUENCY_BIT_SET_POS = 0; + private static final int VIEW_MODIFIED_USE_STATS_FOR_PARALLELIZATION_BIT_SET_POS = 1; private IndexMaintainer indexMaintainer; private ImmutableBytesWritable indexMaintainersPtr; @@ -143,7 +146,7 @@ public class PTableImpl implements PTable { private final boolean storeNulls; private final TransactionFactory.Provider transactionProvider; private final ViewType viewType; - private final PDataType viewIndexType; + private final PDataType viewIndexIdType; private final Long viewIndexId; private final int estimatedSize; private final IndexType indexType; @@ -159,6 +162,7 @@ public class PTableImpl implements PTable { private final QualifierEncodingScheme qualifierEncodingScheme; private final EncodedCQCounter encodedCQCounter; private final Boolean useStatsForParallelization; + private final BitSet viewModifiedPropSet; public static class Builder { private PTableKey key; @@ -197,7 +201,7 @@ public class PTableImpl implements PTable { private boolean storeNulls; private TransactionFactory.Provider transactionProvider; private ViewType viewType; - private PDataType viewIndexType; + private PDataType viewIndexIdType; private Long viewIndexId; private int estimatedSize; private IndexType indexType; @@ -213,6 +217,8 @@ public class PTableImpl implements PTable { private QualifierEncodingScheme qualifierEncodingScheme; private EncodedCQCounter encodedCQCounter; private Boolean useStatsForParallelization; + // Used to denote which properties a view has explicitly modified + private BitSet viewModifiedPropSet = new BitSet(2); // Optionally set columns for the builder, but not for the actual PTable private Collection<PColumn> columns; @@ -407,8 +413,8 @@ public class PTableImpl implements PTable { return this; } - public Builder setViewIndexType(PDataType viewIndexType) { - this.viewIndexType = viewIndexType; + public Builder setViewIndexIdType(PDataType viewIndexIdType) { + this.viewIndexIdType = viewIndexIdType; return this; } @@ -487,6 +493,18 @@ public class PTableImpl implements PTable { return this; } + public Builder setViewModifiedUpdateCacheFrequency(boolean modified) { + this.viewModifiedPropSet.set(VIEW_MODIFIED_UPDATE_CACHE_FREQUENCY_BIT_SET_POS, + modified); + return this; + } + + public Builder setViewModifiedUseStatsForParallelization(boolean modified) { + this.viewModifiedPropSet.set(VIEW_MODIFIED_USE_STATS_FOR_PARALLELIZATION_BIT_SET_POS, + modified); + return this; + } + /** * Note: When set in the builder, we must call {@link Builder#initDerivedAttributes()} * before building the PTable in order to correctly populate other attributes of the PTable @@ -741,7 +759,7 @@ public class PTableImpl implements PTable { this.storeNulls = builder.storeNulls; this.transactionProvider = builder.transactionProvider; this.viewType = builder.viewType; - this.viewIndexType = builder.viewIndexType; + this.viewIndexIdType = builder.viewIndexIdType; this.viewIndexId = builder.viewIndexId; this.estimatedSize = builder.estimatedSize; this.indexType = builder.indexType; @@ -757,6 +775,7 @@ public class PTableImpl implements PTable { this.qualifierEncodingScheme = builder.qualifierEncodingScheme; this.encodedCQCounter = builder.encodedCQCounter; this.useStatsForParallelization = builder.useStatsForParallelization; + this.viewModifiedPropSet = builder.viewModifiedPropSet; } // When cloning table, ignore the salt column as it will be added back in the constructor @@ -791,7 +810,7 @@ public class PTableImpl implements PTable { .setMultiTenant(table.isMultiTenant()) .setStoreNulls(table.getStoreNulls()) .setViewType(table.getViewType()) - .setViewIndexType(table.getViewIndexType()) + .setViewIndexIdType(table.getviewIndexIdType()) .setViewIndexId(table.getViewIndexId()) .setIndexType(table.getIndexType()) .setTransactionProvider(table.getTransactionProvider()) @@ -820,7 +839,10 @@ public class PTableImpl implements PTable { .setParentSchemaName(table.getParentSchemaName()) .setParentTableName(table.getParentTableName()) .setPhysicalNames(table.getPhysicalNames() == null ? - ImmutableList.<PName>of() : ImmutableList.copyOf(table.getPhysicalNames())); + ImmutableList.<PName>of() : ImmutableList.copyOf(table.getPhysicalNames())) + .setViewModifiedUseStatsForParallelization(table + .hasViewModifiedUseStatsForParallelization()) + .setViewModifiedUpdateCacheFrequency(table.hasViewModifiedUpdateCacheFrequency()); } @Override @@ -1442,8 +1464,8 @@ public class PTableImpl implements PTable { } @Override - public PDataType getViewIndexType() { - return viewIndexType; + public PDataType getviewIndexIdType() { + return viewIndexIdType; } @Override @@ -1478,8 +1500,8 @@ public class PTableImpl implements PTable { if (table.hasViewIndexId()) { viewIndexId = table.getViewIndexId(); } - PDataType viewIndexType = table.hasViewIndexType() - ? PDataType.fromTypeId(table.getViewIndexType()) + PDataType viewIndexIdType = table.hasViewIndexIdType() + ? PDataType.fromTypeId(table.getViewIndexIdType()) : MetaDataUtil.getLegacyViewIndexIdDataType(); IndexType indexType = IndexType.getDefault(); if(table.hasIndexType()){ @@ -1602,7 +1624,7 @@ public class PTableImpl implements PTable { .setMultiTenant(multiTenant) .setStoreNulls(storeNulls) .setViewType(viewType) - .setViewIndexType(viewIndexType) + .setViewIndexIdType(viewIndexIdType) .setViewIndexId(viewIndexId) .setIndexType(indexType) .setTransactionProvider(transactionProvider) @@ -1653,7 +1675,7 @@ public class PTableImpl implements PTable { } if(table.getViewIndexId() != null) { builder.setViewIndexId(table.getViewIndexId()); - builder.setViewIndexType(table.getViewIndexType().getSqlType()); + builder.setViewIndexIdType(table.getviewIndexIdType().getSqlType()); } if(table.getIndexType() != null) { builder.setIndexType(ByteStringer.wrap(new byte[]{table.getIndexType().getSerializedValue()})); @@ -1833,6 +1855,14 @@ public class PTableImpl implements PTable { return useStatsForParallelization; } + @Override public boolean hasViewModifiedUpdateCacheFrequency() { + return viewModifiedPropSet.get(VIEW_MODIFIED_UPDATE_CACHE_FREQUENCY_BIT_SET_POS); + } + + @Override public boolean hasViewModifiedUseStatsForParallelization() { + return viewModifiedPropSet.get(VIEW_MODIFIED_USE_STATS_FOR_PARALLELIZATION_BIT_SET_POS); + } + private static final class KVColumnFamilyQualifier { @Nonnull private final String colFamilyName; diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java index 9aa5bd3..0b3248a 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java @@ -33,12 +33,14 @@ import java.util.NavigableMap; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.Tag; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.HConnection; import org.apache.hadoop.hbase.client.HConnectionManager; @@ -258,6 +260,48 @@ public class MetaDataUtil { } } + /** + * Iterates over the cells that are mutated by the put operation for the given column family and + * column qualifier and conditionally modifies those cells to add a tags list. We only add tags + * if the cell value does not match the passed valueArray. If we always want to add tags to + * these cells, we can pass in a null valueArray + * @param somePut Put operation + * @param family column family of the cells + * @param qualifier column qualifier of the cells + * @param valueArray byte array of values or null + * @param tagArray byte array of tags to add to the cells + */ + public static void conditionallyAddTagsToPutCells(Put somePut, byte[] family, byte[] qualifier, + byte[] valueArray, byte[] tagArray) { + NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); + List<Cell> cells = familyCellMap.get(family); + List<Cell> newCells = Lists.newArrayList(); + if (cells != null) { + for (Cell cell : cells) { + if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), + cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0 && + (valueArray == null || !CellUtil.matchingValue(cell, valueArray))) { + final byte[] combinedTags = + ByteUtil.concat(CellUtil.getTagArray(cell), tagArray); + Cell newCell = CellUtil.createCell( + CellUtil.cloneRow(cell), + CellUtil.cloneFamily(cell), + CellUtil.cloneQualifier(cell), + cell.getTimestamp(), + KeyValue.Type.codeToType(cell.getTypeByte()), + CellUtil.cloneValue(cell), + combinedTags); + // Replace existing cell with a cell that has the custom tags list + newCells.add(newCell); + } else { + // Add cell as is + newCells.add(cell); + } + } + familyCellMap.put(family, newCells); + } + } + public static Put cloneDeleteToPutAndAddColumn(Delete delete, byte[] family, byte[] qualifier, byte[] value) { NavigableMap<byte[], List<Cell>> familyCellMap = delete.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); @@ -357,7 +401,7 @@ public class MetaDataUtil { } return 0; } - + public static long getParentSequenceNumber(List<Mutation> tableMetaData) { return getSequenceNumber(getParentTableHeaderRow(tableMetaData)); } diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java b/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java index 485a21f..d934a04 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java @@ -19,11 +19,14 @@ package org.apache.phoenix.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.Tag; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.VersionInfo; @@ -32,14 +35,22 @@ import org.apache.phoenix.hbase.index.util.GenericKeyValueBuilder; import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; import org.apache.phoenix.hbase.index.util.KeyValueBuilder; import org.apache.phoenix.hbase.index.util.VersionUtil; -import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; import org.apache.phoenix.query.HBaseFactoryProvider; import org.apache.phoenix.query.QueryServices; import org.junit.Test; +import java.util.Arrays; + +import static org.apache.hadoop.hbase.HConstants.EMPTY_BYTE_ARRAY; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; public class MetaDataUtilTest { + private static final byte[] ROW = Bytes.toBytes("row"); + private static final byte[] QUALIFIER = Bytes.toBytes("qual"); + private static final byte[] ORIGINAL_VALUE = Bytes.toBytes("generic-value"); + private static final byte[] DUMMY_TAGS = Bytes.toBytes("tags"); + @Test public void testEncode() { assertEquals(VersionUtil.encodeVersion("0.94.5"),VersionUtil.encodeVersion("0.94.5-mapR")); @@ -65,21 +76,63 @@ public class MetaDataUtilTest { @Test public void testMutatingAPut() throws Exception { - String version = VersionInfo.getVersion(); - KeyValueBuilder builder = KeyValueBuilder.get(version); - byte[] row = Bytes.toBytes("row"); - byte[] family = PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; - byte[] qualifier = Bytes.toBytes("qual"); - byte[] value = Bytes.toBytes("generic-value"); - KeyValue kv = builder.buildPut(wrap(row), wrap(family), wrap(qualifier), wrap(value)); - Put put = new Put(row); - KeyValueBuilder.addQuietly(put, builder, kv); + Put put = generateOriginalPut(); byte[] newValue = Bytes.toBytes("new-value"); - Cell cell = put.get(family, qualifier).get(0); - assertEquals(Bytes.toString(value), Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); - MetaDataUtil.mutatePutValue(put, family, qualifier, newValue); - cell = put.get(family, qualifier).get(0); - assertEquals(Bytes.toString(newValue), Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); + Cell cell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); + assertEquals(Bytes.toString(ORIGINAL_VALUE), + Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); + MetaDataUtil.mutatePutValue(put, TABLE_FAMILY_BYTES, QUALIFIER, newValue); + cell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); + assertEquals(Bytes.toString(newValue), + Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); + } + + @Test + public void testTaggingAPutWrongQualifier() throws Exception { + Put put = generateOriginalPut(); + Cell initialCell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); + + // Different qualifier, so no tags should be set + MetaDataUtil.conditionallyAddTagsToPutCells(put, TABLE_FAMILY_BYTES, EMPTY_BYTE_ARRAY, + EMPTY_BYTE_ARRAY, DUMMY_TAGS); + Cell newCell = put.getFamilyCellMap().get(TABLE_FAMILY_BYTES).get(0); + assertEquals(initialCell, newCell); + assertNull(Tag.carryForwardTags(newCell)); + } + + @Test + public void testTaggingAPutUnconditionally() throws Exception { + Put put = generateOriginalPut(); + + // valueArray is null so we always set tags + MetaDataUtil.conditionallyAddTagsToPutCells(put, TABLE_FAMILY_BYTES, QUALIFIER, + null, DUMMY_TAGS); + Cell newCell = put.getFamilyCellMap().get(TABLE_FAMILY_BYTES).get(0); + assertTrue(Arrays.equals(DUMMY_TAGS, CellUtil.getTagArray(newCell))); + } + + @Test + public void testSkipTaggingAPutDueToSameCellValue() throws Exception { + Put put = generateOriginalPut(); + Cell initialCell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); + + // valueArray is set as the value stored in the cell, so we skip tagging the cell + MetaDataUtil.conditionallyAddTagsToPutCells(put, TABLE_FAMILY_BYTES, QUALIFIER, + ORIGINAL_VALUE, DUMMY_TAGS); + Cell newCell = put.getFamilyCellMap().get(TABLE_FAMILY_BYTES).get(0); + assertEquals(initialCell, newCell); + assertNull(Tag.carryForwardTags(newCell)); + } + + @Test + public void testTaggingAPutDueToDifferentCellValue() throws Exception { + Put put = generateOriginalPut(); + + // valueArray is set to a value different than the one in the cell, so we tag the cell + MetaDataUtil.conditionallyAddTagsToPutCells(put, TABLE_FAMILY_BYTES, QUALIFIER, + EMPTY_BYTE_ARRAY, DUMMY_TAGS); + Cell newCell = put.getFamilyCellMap().get(TABLE_FAMILY_BYTES).get(0); + assertTrue(Arrays.equals(DUMMY_TAGS, CellUtil.getTagArray(newCell))); } /** @@ -90,31 +143,28 @@ public class MetaDataUtilTest { public void testGetMutationKeyValue() throws Exception { String version = VersionInfo.getVersion(); KeyValueBuilder builder = KeyValueBuilder.get(version); - byte[] row = Bytes.toBytes("row"); - byte[] family = PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; - byte[] qualifier = Bytes.toBytes("qual"); - byte[] value = Bytes.toBytes("generic-value"); - KeyValue kv = builder.buildPut(wrap(row), wrap(family), wrap(qualifier), wrap(value)); - Put put = new Put(row); + KeyValue kv = builder.buildPut(wrap(ROW), wrap(TABLE_FAMILY_BYTES), wrap(QUALIFIER), + wrap(ORIGINAL_VALUE)); + Put put = new Put(ROW); KeyValueBuilder.addQuietly(put, builder, kv); // read back out the value ImmutableBytesPtr ptr = new ImmutableBytesPtr(); - assertTrue(MetaDataUtil.getMutationValue(put, qualifier, builder, ptr)); + assertTrue(MetaDataUtil.getMutationValue(put, QUALIFIER, builder, ptr)); assertEquals("Value returned doesn't match stored value for " + builder.getClass().getName() + "!", 0, - ByteUtil.BYTES_PTR_COMPARATOR.compare(ptr, wrap(value))); + ByteUtil.BYTES_PTR_COMPARATOR.compare(ptr, wrap(ORIGINAL_VALUE))); // try again, this time with the clientkeyvalue builder if (builder != GenericKeyValueBuilder.INSTANCE) { builder = GenericKeyValueBuilder.INSTANCE; - value = Bytes.toBytes("client-value"); - kv = builder.buildPut(wrap(row), wrap(family), wrap(qualifier), wrap(value)); - put = new Put(row); + byte[] value = Bytes.toBytes("client-value"); + kv = builder.buildPut(wrap(ROW), wrap(TABLE_FAMILY_BYTES), wrap(QUALIFIER), wrap(value)); + put = new Put(ROW); KeyValueBuilder.addQuietly(put, builder, kv); // read back out the value - assertTrue(MetaDataUtil.getMutationValue(put, qualifier, builder, ptr)); + assertTrue(MetaDataUtil.getMutationValue(put, QUALIFIER, builder, ptr)); assertEquals("Value returned doesn't match stored value for " + builder.getClass().getName() + "!", 0, ByteUtil.BYTES_PTR_COMPARATOR.compare(ptr, wrap(value))); @@ -159,5 +209,16 @@ public class MetaDataUtilTest { MetaDataProtocol.PHOENIX_MINOR_VERSION, MetaDataProtocol.PHOENIX_PATCH_NUMBER); assertEquals(expectedPhoenixVersion, phoenixVersion); } + + private Put generateOriginalPut() { + String version = VersionInfo.getVersion(); + KeyValueBuilder builder = KeyValueBuilder.get(version); + KeyValue kv = builder.buildPut(wrap(ROW), wrap(TABLE_FAMILY_BYTES), wrap(QUALIFIER), + wrap(ORIGINAL_VALUE)); + Put put = new Put(ROW); + KeyValueBuilder.addQuietly(put, builder, kv); + return put; + } + } diff --git a/phoenix-protocol/src/main/MetaDataService.proto b/phoenix-protocol/src/main/MetaDataService.proto index f10aa3c..290a65d 100644 --- a/phoenix-protocol/src/main/MetaDataService.proto +++ b/phoenix-protocol/src/main/MetaDataService.proto @@ -61,7 +61,7 @@ message SharedTableState { repeated PColumn columns = 4; repeated bytes physicalNames = 5; required int64 viewIndexId = 6; - optional int32 viewIndexType = 7 [default = 5]; + optional int32 viewIndexIdType = 7 [default = 5]; } message MetaDataResponse { @@ -77,7 +77,7 @@ message MetaDataResponse { optional PSchema schema = 10; optional int64 autoPartitionNum = 11; optional int64 viewIndexId = 12; - optional int32 viewIndexType = 13 [default = 5]; + optional int32 viewIndexIdType = 13 [default = 5]; } message GetTableRequest { diff --git a/phoenix-protocol/src/main/PTable.proto b/phoenix-protocol/src/main/PTable.proto index be771a9..12dde49 100644 --- a/phoenix-protocol/src/main/PTable.proto +++ b/phoenix-protocol/src/main/PTable.proto @@ -103,7 +103,7 @@ message PTable { repeated EncodedCQCounter encodedCQCounters = 36; optional bool useStatsForParallelization = 37; optional int32 transactionProvider = 38; - optional int32 viewIndexType = 39 [default = 5]; + optional int32 viewIndexIdType = 39 [default = 5]; } message EncodedCQCounter { diff --git a/phoenix-protocol/src/main/ServerCachingService.proto b/phoenix-protocol/src/main/ServerCachingService.proto index 0d2d1d2..5891d25 100644 --- a/phoenix-protocol/src/main/ServerCachingService.proto +++ b/phoenix-protocol/src/main/ServerCachingService.proto @@ -62,7 +62,7 @@ message IndexMaintainer { repeated ColumnInfo indexedColumnInfo = 19; required int32 encodingScheme = 20; required int32 immutableStorageScheme = 21; - optional int32 viewIndexType = 22 ; + optional int32 viewIndexIdType = 22 ; } message AddServerCacheRequest {