Github user jaanai0 commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/355#discussion_r220899258
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
---
@@ -4588,4 +4423,113 @@ private TableName getParentPhysicalTableName(PTable
table) {
table.getTableName(), table.isNamespaceMapped())
.getBytes());
}
+
+ private class TableBuilder {
+ private Region region;
+ private byte[] tableKey;
+ private Integer clientVersion;
+
+ public TableBuilder setRegion(Region region) {
+ this.region = region;
+ return this;
+ }
+
+ public TableBuilder setTableKey(byte[] tableKey) {
+ this.tableKey = tableKey;
+ return this;
+ }
+
+ public TableBuilder setClientVersion(Integer clientVersion) {
+ this.clientVersion = clientVersion;
+ return this;
+ }
+
+ public PTable run() throws Exception {
+ Preconditions.checkNotNull(region);
+ Preconditions.checkNotNull(tableKey);
+ Preconditions.checkNotNull(clientVersion);
+ ImmutableBytesPtr cacheKey = new ImmutableBytesPtr(tableKey);
+ return buildTable(tableKey, cacheKey, region,
HConstants.LATEST_TIMESTAMP, clientVersion,
+ false, false, null);
+ }
+ }
+
+
+ /**
+ * Indexes table and View will not be modify when the parent tables
are modified, so modify has a simple logic in server side.
+ * @param controller
+ * @param request
+ * @param done
+ */
+ @Override
+ public void modifyColumn(RpcController controller, final
MetaDataProtos.ModifyColumnRequest request,
+ RpcCallback<MetaDataResponse> done) {
+ try {
+ final List<Mutation> metaData =
ProtobufUtil.getMutations(request);
+ final TableBuilder tableBuilder = new TableBuilder();
+ MetaDataMutationResult result =
mutateColumn(MutatateColumnType.MODIFY_COLUMN, metaData, new ColumnMutator() {
+
+ @Override
+ public MetaDataMutationResult updateMutation(PTable table,
byte[][] rowKeyMetaData,
+ List<Mutation> tableMetadata, Region region,
+ List<ImmutableBytesPtr> invalidateList,
List<RowLock> locks,
+ long clientTimeStamp) throws IOException,
SQLException {
+
+ Preconditions.checkArgument(rowKeyMetaData.length ==
5);
+ byte[] tenantId =
rowKeyMetaData[PhoenixDatabaseMetaData.TENANT_ID_INDEX];
+ byte[] schemaName =
rowKeyMetaData[PhoenixDatabaseMetaData.SCHEMA_NAME_INDEX];
+ byte[] tableName =
rowKeyMetaData[PhoenixDatabaseMetaData.TABLE_NAME_INDEX];
+ byte[] key = SchemaUtil.getTableKey(tenantId,
schemaName, tableName);
+
+ PColumn column = null;
+ try {
+ for (Mutation m : metaData) {
+
+ byte[][] rkmd = new byte[5][];
+ int pkCount = getVarChars(m.getRow(), rkmd);
+
+ // Checking this put is for modifying a column
+ if (pkCount < COLUMN_NAME_INDEX || !(m
instanceof Put)
+ ||
rkmd[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX] == null) {
+ continue;
+ }
+
+ if
(rkmd[PhoenixDatabaseMetaData.FAMILY_NAME_INDEX] != null) {
+ PColumnFamily family =
table.getColumnFamily(rkmd[PhoenixDatabaseMetaData.FAMILY_NAME_INDEX]);
+ column =
family.getPColumnForColumnNameBytes(rkmd[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX]);
+ } else {
+ column = table.getPKColumn(new
String(rkmd[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX]));
+ }
+ }
+
+ // After PHOENIX-3534, we don't store parent table
column metadata along with the child metadata,
+ // so we don't need to propagate changes to the
child views.
+
+ // Since the row key is not nullable fixed length,
the data type has been translated to variable
+ // length when index tables were created, So we
will not process data type of index tables.
--- End diff --
Yes
---