[
https://issues.apache.org/jira/browse/PHOENIX-6227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17437602#comment-17437602
]
ASF GitHub Bot commented on PHOENIX-6227:
-----------------------------------------
gjacoby126 commented on a change in pull request #1341:
URL: https://github.com/apache/phoenix/pull/1341#discussion_r741438765
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1148,115 +1235,203 @@ private PTable getTable(RegionScanner scanner, long
clientTimeStamp, long tableT
transactionProviderKv.getValueOffset(),
SortOrder.getDefault()));
}
+ builder.setTransactionProvider(transactionProviderKv != null ||
transactionalKv != null
+ ? transactionProvider : oldTable != null ?
oldTable.getTransactionProvider() : null);
+
Cell viewTypeKv = tableKeyValues[VIEW_TYPE_INDEX];
ViewType viewType = viewTypeKv == null ? null :
ViewType.fromSerializedValue(viewTypeKv.getValueArray()[viewTypeKv.getValueOffset()]);
- PDataType viewIndexIdType = getViewIndexIdType(tableKeyValues);
+ builder.setViewType(viewType != null ? viewType : oldTable != null ?
oldTable.getViewType() : null);
+
+ PDataType viewIndexIdType = oldTable != null ?
oldTable.getviewIndexIdType() :
+ getViewIndexIdType(tableKeyValues);
+ builder.setViewIndexIdType(viewIndexIdType);
+
Long viewIndexId = getViewIndexId(tableKeyValues, viewIndexIdType);
+ builder.setViewIndexId(viewIndexId != null ? viewIndexId : oldTable !=
null ? oldTable.getViewIndexId() : null);
+
Cell indexTypeKv = tableKeyValues[INDEX_TYPE_INDEX];
IndexType indexType = indexTypeKv == null ? null :
IndexType.fromSerializedValue(indexTypeKv.getValueArray()[indexTypeKv.getValueOffset()]);
+ builder.setIndexType(indexType != null ? indexType : oldTable != null
? oldTable.getIndexType() : null);
+
Cell baseColumnCountKv = tableKeyValues[BASE_COLUMN_COUNT_INDEX];
int baseColumnCount = baseColumnCountKv == null ? 0 :
PInteger.INSTANCE.getCodec().decodeInt(baseColumnCountKv.getValueArray(),
baseColumnCountKv.getValueOffset(), SortOrder.getDefault());
+ builder.setBaseColumnCount(baseColumnCountKv != null ? baseColumnCount
: oldTable != null ? oldTable.getBaseColumnCount() : 0);
+
Cell rowKeyOrderOptimizableKv =
tableKeyValues[ROW_KEY_ORDER_OPTIMIZABLE_INDEX];
- boolean rowKeyOrderOptimizable = rowKeyOrderOptimizableKv == null ?
false :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(rowKeyOrderOptimizableKv.getValueArray(),
rowKeyOrderOptimizableKv.getValueOffset(),
rowKeyOrderOptimizableKv.getValueLength()));
+ boolean rowKeyOrderOptimizable = rowKeyOrderOptimizableKv != null &&
Boolean.TRUE.equals(
+
PBoolean.INSTANCE.toObject(rowKeyOrderOptimizableKv.getValueArray(),
+ rowKeyOrderOptimizableKv.getValueOffset(),
+ rowKeyOrderOptimizableKv.getValueLength()));
+ builder.setRowKeyOrderOptimizable(rowKeyOrderOptimizableKv != null ?
rowKeyOrderOptimizable :
+ oldTable != null && oldTable.rowKeyOrderOptimizable());
+
Cell updateCacheFrequencyKv =
tableKeyValues[UPDATE_CACHE_FREQUENCY_INDEX];
long updateCacheFrequency = updateCacheFrequencyKv == null ? 0 :
PLong.INSTANCE.getCodec().decodeLong(updateCacheFrequencyKv.getValueArray(),
updateCacheFrequencyKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setUpdateCacheFrequency(updateCacheFrequencyKv != null ?
updateCacheFrequency : oldTable != null ? oldTable.getUpdateCacheFrequency() :
0);
// 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);
+
builder.setViewModifiedUpdateCacheFrequency(!Bytes.equals(tagUpdateCacheFreq,
+ HConstants.EMPTY_BYTE_ARRAY) ? viewModifiedUpdateCacheFrequency :
+ oldTable != null &&
oldTable.hasViewModifiedUpdateCacheFrequency());
+
Cell indexDisableTimestampKv = tableKeyValues[INDEX_DISABLE_TIMESTAMP];
long indexDisableTimestamp = indexDisableTimestampKv == null ? 0L :
PLong.INSTANCE.getCodec().decodeLong(indexDisableTimestampKv.getValueArray(),
indexDisableTimestampKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setIndexDisableTimestamp(indexDisableTimestampKv != null ?
+ indexDisableTimestamp : oldTable != null ?
oldTable.getIndexDisableTimestamp() : 0L);
+
Cell isNamespaceMappedKv = tableKeyValues[IS_NAMESPACE_MAPPED_INDEX];
- boolean isNamespaceMapped = isNamespaceMappedKv == null ? false
- :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(isNamespaceMappedKv.getValueArray(),
+ boolean isNamespaceMapped = isNamespaceMappedKv != null &&
Boolean.TRUE.equals(
+ PBoolean.INSTANCE.toObject(isNamespaceMappedKv.getValueArray(),
isNamespaceMappedKv.getValueOffset(),
isNamespaceMappedKv.getValueLength()));
+ builder.setNamespaceMapped(isNamespaceMappedKv != null ?
isNamespaceMapped :
+ oldTable != null && oldTable.isNamespaceMapped());
+
Cell autoPartitionSeqKv = tableKeyValues[AUTO_PARTITION_SEQ_INDEX];
String autoPartitionSeq = autoPartitionSeqKv != null ? (String)
PVarchar.INSTANCE.toObject(autoPartitionSeqKv.getValueArray(),
autoPartitionSeqKv.getValueOffset(),
autoPartitionSeqKv.getValueLength()) : null;
+ builder.setAutoPartitionSeqName(autoPartitionSeq != null
+ ? autoPartitionSeq : oldTable != null ?
oldTable.getAutoPartitionSeqName() : null);
+
Cell isAppendOnlySchemaKv = tableKeyValues[APPEND_ONLY_SCHEMA_INDEX];
- boolean isAppendOnlySchema = isAppendOnlySchemaKv == null ? false
- :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(isAppendOnlySchemaKv.getValueArray(),
+ boolean isAppendOnlySchema = isAppendOnlySchemaKv != null &&
Boolean.TRUE.equals(
+ PBoolean.INSTANCE.toObject(isAppendOnlySchemaKv.getValueArray(),
isAppendOnlySchemaKv.getValueOffset(),
isAppendOnlySchemaKv.getValueLength()));
+ builder.setAppendOnlySchema(isAppendOnlySchemaKv != null ?
isAppendOnlySchema :
+ oldTable != null && oldTable.isAppendOnlySchema());
+
Cell storageSchemeKv = tableKeyValues[STORAGE_SCHEME_INDEX];
//TODO: change this once we start having other values for storage
schemes
ImmutableStorageScheme storageScheme = storageSchemeKv == null ?
ImmutableStorageScheme.ONE_CELL_PER_COLUMN : ImmutableStorageScheme
.fromSerializedValue((byte)
PTinyint.INSTANCE.toObject(storageSchemeKv.getValueArray(),
storageSchemeKv.getValueOffset(),
storageSchemeKv.getValueLength()));
+ builder.setImmutableStorageScheme(storageSchemeKv != null ?
storageScheme :
+ oldTable != null ? oldTable.getImmutableStorageScheme() :
ImmutableStorageScheme.ONE_CELL_PER_COLUMN);
+
Cell encodingSchemeKv =
tableKeyValues[QUALIFIER_ENCODING_SCHEME_INDEX];
QualifierEncodingScheme encodingScheme = encodingSchemeKv == null ?
QualifierEncodingScheme.NON_ENCODED_QUALIFIERS : QualifierEncodingScheme
.fromSerializedValue((byte)
PTinyint.INSTANCE.toObject(encodingSchemeKv.getValueArray(),
encodingSchemeKv.getValueOffset(),
encodingSchemeKv.getValueLength()));
+ builder.setQualifierEncodingScheme(encodingSchemeKv != null ?
encodingScheme :
+ oldTable != null ? oldTable.getEncodingScheme() :
QualifierEncodingScheme.NON_ENCODED_QUALIFIERS);
+
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()));
+ Boolean useStatsForParallelization = useStatsForParallelizationKv ==
null ? null :
+
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(useStatsForParallelizationKv.getValueArray(),
useStatsForParallelizationKv.getValueOffset(),
useStatsForParallelizationKv.getValueLength()));
+ builder.setUseStatsForParallelization(useStatsForParallelization !=
null ?
+ useStatsForParallelization : oldTable != null ?
oldTable.useStatsForParallelization() : null);
Cell phoenixTTLKv = tableKeyValues[PHOENIX_TTL_INDEX];
long phoenixTTL = phoenixTTLKv == null ? PHOENIX_TTL_NOT_DEFINED :
PLong.INSTANCE.getCodec().decodeLong(phoenixTTLKv.getValueArray(),
phoenixTTLKv.getValueOffset(), SortOrder.getDefault());
+ builder.setPhoenixTTL(phoenixTTLKv != null ? phoenixTTL :
+ oldTable != null ? oldTable.getPhoenixTTL() :
PHOENIX_TTL_NOT_DEFINED);
Cell phoenixTTLHWMKv = tableKeyValues[PHOENIX_TTL_HWM_INDEX];
long phoenixTTLHWM = phoenixTTLHWMKv == null ? MIN_PHOENIX_TTL_HWM :
PLong.INSTANCE.getCodec().decodeLong(phoenixTTLHWMKv.getValueArray(),
phoenixTTLHWMKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setPhoenixTTLHighWaterMark(phoenixTTLHWMKv != null ?
phoenixTTLHWM :
+ oldTable != null ? oldTable.getPhoenixTTLHighWaterMark() :
MIN_PHOENIX_TTL_HWM);
// Check the cell tag to see whether the view has modified this
property
final byte[] tagPhoenixTTL = (phoenixTTLKv == null) ?
HConstants.EMPTY_BYTE_ARRAY :
CellUtil.getTagArray(phoenixTTLKv);
boolean viewModifiedPhoenixTTL = (PTableType.VIEW.equals(tableType)) &&
Bytes.contains(tagPhoenixTTL, VIEW_MODIFIED_PROPERTY_BYTES);
+ builder.setViewModifiedPhoenixTTL(oldTable != null ?
+ oldTable.hasViewModifiedPhoenixTTL() || viewModifiedPhoenixTTL :
viewModifiedPhoenixTTL);
Cell lastDDLTimestampKv = tableKeyValues[LAST_DDL_TIMESTAMP_INDEX];
Long lastDDLTimestamp = lastDDLTimestampKv == null ?
null :
PLong.INSTANCE.getCodec().decodeLong(lastDDLTimestampKv.getValueArray(),
lastDDLTimestampKv.getValueOffset(), SortOrder.getDefault());
+ builder.setLastDDLTimestamp(lastDDLTimestampKv != null ?
lastDDLTimestamp :
+ oldTable != null ? oldTable.getLastDDLTimestamp() : null);
Cell changeDetectionEnabledKv =
tableKeyValues[CHANGE_DETECTION_ENABLED_INDEX];
boolean isChangeDetectionEnabled = changeDetectionEnabledKv != null
&&
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(changeDetectionEnabledKv.getValueArray(),
changeDetectionEnabledKv.getValueOffset(),
changeDetectionEnabledKv.getValueLength()));
+ builder.setIsChangeDetectionEnabled(changeDetectionEnabledKv != null ?
+ isChangeDetectionEnabled : oldTable != null &&
oldTable.isChangeDetectionEnabled());
Cell schemaVersionKv = tableKeyValues[SCHEMA_VERSION_INDEX];
String schemaVersion = schemaVersionKv != null ? (String)
PVarchar.INSTANCE.toObject(
schemaVersionKv.getValueArray(),
schemaVersionKv.getValueOffset(), schemaVersionKv.getValueLength())
: null;
+ builder.setSchemaVersion(schemaVersion != null ?
+ schemaVersion : oldTable != null ? oldTable.getSchemaVersion() :
null);
+
+ Cell externalSchemaIdKv = tableKeyValues[EXTERNAL_SCHEMA_ID_INDEX];
+ String externalSchemaId = externalSchemaIdKv != null ?
+ (String)
PVarchar.INSTANCE.toObject(externalSchemaIdKv.getValueArray(),
+ externalSchemaIdKv.getValueOffset(),
externalSchemaIdKv.getValueLength())
+ : null;
+ builder.setExternalSchemaId(externalSchemaId != null ?
externalSchemaId :
+ oldTable != null ? oldTable.getExternalSchemaId() : null);
// 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);
+
builder.setViewModifiedUseStatsForParallelization(viewModifiedUseStatsForParallelization
||
+ (oldTable != null &&
oldTable.hasViewModifiedUseStatsForParallelization()));
+ boolean setPhysicalName = false;
List<PColumn> columns =
Lists.newArrayListWithExpectedSize(columnCount);
List<PTable> indexes = Lists.newArrayList();
List<PName> physicalTables = Lists.newArrayList();
PName parentTableName = tableType == INDEX ? dataTableName : null;
PName parentSchemaName = tableType == INDEX ? schemaName : null;
PName parentLogicalName = null;
- EncodedCQCounter cqCounter =
- (!EncodedColumnsUtil.usesEncodedColumnNames(encodingScheme) ||
tableType == PTableType.VIEW) ? PTable.EncodedCQCounter.NULL_COUNTER
- : new EncodedCQCounter();
+ EncodedCQCounter cqCounter = null;
+ if (oldTable != null) {
+ cqCounter = oldTable.getEncodedCQCounter();
+ } else {
+ cqCounter =
(!EncodedColumnsUtil.usesEncodedColumnNames(encodingScheme) || tableType ==
PTableType.VIEW) ?
+ PTable.EncodedCQCounter.NULL_COUNTER :
+ new EncodedCQCounter();
+ }
+
+ if (timeStamp == HConstants.LATEST_TIMESTAMP) {
+ timeStamp = lastDDLTimestamp != null ? lastDDLTimestamp :
clientTimeStamp;
+ }
+ builder.setTimeStamp(timeStamp);
+
+
boolean isRegularView = (tableType == PTableType.VIEW && viewType !=
ViewType.MAPPED);
- while (true) {
- results.clear();
- scanner.next(results);
- if (results.isEmpty()) {
- break;
- }
- Cell colKv = results.get(LINK_TYPE_INDEX);
+ for (List<Cell> columnCellList : allColumnCellList) {
+
+ Cell colKv = columnCellList.get(LINK_TYPE_INDEX);
int colKeyLength = colKv.getRowLength();
+
PName colName = newPName(colKv.getRowArray(), colKv.getRowOffset()
+ offset, colKeyLength - offset);
+ if (colName == null && !schemaName.getString().equals("SYSTEM")) {
+ int foo = 1;
Review comment:
oops, sorry, that's scaffolding code to set a breakpoint. Need to remove
that.
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java
##########
@@ -82,7 +79,66 @@ private static void verifyNewColumns(ResultSet rs, String
... values) throws SQL
assertFalse(rs.next());
assertEquals(values.length, i - 1);
}
-
+
+ @Test
+ public void testCreateAndAlterViewsWithChangeDetectionEnabled() throws
Exception {
+ String tenantId = "TE_" + generateUniqueName();
+ String schemaName = "S_" + generateUniqueName();
+ String tableName = "T_" + generateUniqueName();
+ String globalViewName = "GV_" + generateUniqueName();
+ String tenantViewName = "TV_" + generateUniqueName();
+ String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
+ String fullGlobalViewName = SchemaUtil.getTableName(schemaName,
globalViewName);
+ String fullTenantViewName = SchemaUtil.getTableName(schemaName,
tenantViewName);
+
+ PTable globalView = null;
+ PTable alteredGlobalView = null;
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ String ddl = "CREATE TABLE " + fullTableName +
+ " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2
bigint NOT NULL," +
+ " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " +
+ "MULTI_TENANT=true, CHANGE_DETECTION_ENABLED=true";
+ conn.createStatement().execute(ddl);
+ PTable table = PhoenixRuntime.getTableNoCache(conn, fullTableName);
+ assertTrue(table.isChangeDetectionEnabled());
+ AlterTableIT.verifySchemaExport(table,
getUtility().getConfiguration());
+
+ String globalViewDdl = "CREATE VIEW " + fullGlobalViewName +
Review comment:
It's not inherited (and should never be true for indexes)
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java
##########
@@ -82,7 +79,66 @@ private static void verifyNewColumns(ResultSet rs, String
... values) throws SQL
assertFalse(rs.next());
assertEquals(values.length, i - 1);
}
-
+
+ @Test
+ public void testCreateAndAlterViewsWithChangeDetectionEnabled() throws
Exception {
+ String tenantId = "TE_" + generateUniqueName();
+ String schemaName = "S_" + generateUniqueName();
+ String tableName = "T_" + generateUniqueName();
+ String globalViewName = "GV_" + generateUniqueName();
+ String tenantViewName = "TV_" + generateUniqueName();
+ String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
+ String fullGlobalViewName = SchemaUtil.getTableName(schemaName,
globalViewName);
+ String fullTenantViewName = SchemaUtil.getTableName(schemaName,
tenantViewName);
+
+ PTable globalView = null;
+ PTable alteredGlobalView = null;
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ String ddl = "CREATE TABLE " + fullTableName +
+ " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2
bigint NOT NULL," +
+ " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " +
+ "MULTI_TENANT=true, CHANGE_DETECTION_ENABLED=true";
+ conn.createStatement().execute(ddl);
+ PTable table = PhoenixRuntime.getTableNoCache(conn, fullTableName);
+ assertTrue(table.isChangeDetectionEnabled());
+ AlterTableIT.verifySchemaExport(table,
getUtility().getConfiguration());
+
+ String globalViewDdl = "CREATE VIEW " + fullGlobalViewName +
+ " (id2 CHAR(12) NOT NULL PRIMARY KEY, col3 BIGINT NULL) " +
+ " AS SELECT * FROM " + fullTableName + "
CHANGE_DETECTION_ENABLED=true";
+
+ conn.createStatement().execute(globalViewDdl);
+ globalView = PhoenixRuntime.getTableNoCache(conn,
fullGlobalViewName);
+ assertTrue(globalView.isChangeDetectionEnabled());
+ // base column count doesn't get set properly
+ PTableImpl.Builder builder =
PTableImpl.builderFromExisting(globalView);
+ builder.setBaseColumnCount(table.getColumns().size());
+ globalView = builder.setColumns(globalView.getColumns()).build();
+ AlterTableIT.verifySchemaExport(globalView,
getUtility().getConfiguration());
+
+ String alterViewDdl = "ALTER VIEW " + fullGlobalViewName + " ADD
id3 VARCHAR(12) NULL "
Review comment:
You can, and I will add tests.
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/schema/export/SchemaRegistryRepositoryFactory.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.schema.export;
+
+import org.apache.hadoop.conf.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public final class SchemaRegistryRepositoryFactory {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(SchemaRegistryRepository.class);
+ private static SchemaRegistryRepository exporter;
+
+ public synchronized static SchemaRegistryRepository
getSchemaRegistryRepository(Configuration conf)
+ throws IOException {
+ if (exporter != null) {
+ return exporter;
+ }
+ try {
+ String className =
conf.get(SchemaRegistryRepository.SCHEMA_REGISTRY_IMPL_KEY);
+ if (className == null) {
+ exporter = new DefaultSchemaRegistryRepository();
Review comment:
The factory can't close it because the exporter hasn't been used yet.
But good point that someone has to close it. Will add a method to close the
factory and have the coproc call it during stop()
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/schema/export/SchemaRegistryRepositoryFactory.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.schema.export;
+
+import org.apache.hadoop.conf.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public final class SchemaRegistryRepositoryFactory {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(SchemaRegistryRepository.class);
+ private static SchemaRegistryRepository exporter;
+
+ public synchronized static SchemaRegistryRepository
getSchemaRegistryRepository(Configuration conf)
+ throws IOException {
+ if (exporter != null) {
+ return exporter;
+ }
+ try {
+ String className =
conf.get(SchemaRegistryRepository.SCHEMA_REGISTRY_IMPL_KEY);
+ if (className == null) {
+ exporter = new DefaultSchemaRegistryRepository();
Review comment:
The factory can't close it because the exporter hasn't been used yet.
But good point that someone has to close it. Will add a method to close the
factory (which will close any cached repo) and have the coproc call it during
stop()
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1148,115 +1235,203 @@ private PTable getTable(RegionScanner scanner, long
clientTimeStamp, long tableT
transactionProviderKv.getValueOffset(),
SortOrder.getDefault()));
}
+ builder.setTransactionProvider(transactionProviderKv != null ||
transactionalKv != null
+ ? transactionProvider : oldTable != null ?
oldTable.getTransactionProvider() : null);
+
Cell viewTypeKv = tableKeyValues[VIEW_TYPE_INDEX];
ViewType viewType = viewTypeKv == null ? null :
ViewType.fromSerializedValue(viewTypeKv.getValueArray()[viewTypeKv.getValueOffset()]);
- PDataType viewIndexIdType = getViewIndexIdType(tableKeyValues);
+ builder.setViewType(viewType != null ? viewType : oldTable != null ?
oldTable.getViewType() : null);
+
+ PDataType viewIndexIdType = oldTable != null ?
oldTable.getviewIndexIdType() :
+ getViewIndexIdType(tableKeyValues);
+ builder.setViewIndexIdType(viewIndexIdType);
+
Long viewIndexId = getViewIndexId(tableKeyValues, viewIndexIdType);
+ builder.setViewIndexId(viewIndexId != null ? viewIndexId : oldTable !=
null ? oldTable.getViewIndexId() : null);
+
Cell indexTypeKv = tableKeyValues[INDEX_TYPE_INDEX];
IndexType indexType = indexTypeKv == null ? null :
IndexType.fromSerializedValue(indexTypeKv.getValueArray()[indexTypeKv.getValueOffset()]);
+ builder.setIndexType(indexType != null ? indexType : oldTable != null
? oldTable.getIndexType() : null);
+
Cell baseColumnCountKv = tableKeyValues[BASE_COLUMN_COUNT_INDEX];
int baseColumnCount = baseColumnCountKv == null ? 0 :
PInteger.INSTANCE.getCodec().decodeInt(baseColumnCountKv.getValueArray(),
baseColumnCountKv.getValueOffset(), SortOrder.getDefault());
+ builder.setBaseColumnCount(baseColumnCountKv != null ? baseColumnCount
: oldTable != null ? oldTable.getBaseColumnCount() : 0);
+
Cell rowKeyOrderOptimizableKv =
tableKeyValues[ROW_KEY_ORDER_OPTIMIZABLE_INDEX];
- boolean rowKeyOrderOptimizable = rowKeyOrderOptimizableKv == null ?
false :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(rowKeyOrderOptimizableKv.getValueArray(),
rowKeyOrderOptimizableKv.getValueOffset(),
rowKeyOrderOptimizableKv.getValueLength()));
+ boolean rowKeyOrderOptimizable = rowKeyOrderOptimizableKv != null &&
Boolean.TRUE.equals(
+
PBoolean.INSTANCE.toObject(rowKeyOrderOptimizableKv.getValueArray(),
+ rowKeyOrderOptimizableKv.getValueOffset(),
+ rowKeyOrderOptimizableKv.getValueLength()));
+ builder.setRowKeyOrderOptimizable(rowKeyOrderOptimizableKv != null ?
rowKeyOrderOptimizable :
+ oldTable != null && oldTable.rowKeyOrderOptimizable());
+
Cell updateCacheFrequencyKv =
tableKeyValues[UPDATE_CACHE_FREQUENCY_INDEX];
long updateCacheFrequency = updateCacheFrequencyKv == null ? 0 :
PLong.INSTANCE.getCodec().decodeLong(updateCacheFrequencyKv.getValueArray(),
updateCacheFrequencyKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setUpdateCacheFrequency(updateCacheFrequencyKv != null ?
updateCacheFrequency : oldTable != null ? oldTable.getUpdateCacheFrequency() :
0);
// 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);
+
builder.setViewModifiedUpdateCacheFrequency(!Bytes.equals(tagUpdateCacheFreq,
+ HConstants.EMPTY_BYTE_ARRAY) ? viewModifiedUpdateCacheFrequency :
+ oldTable != null &&
oldTable.hasViewModifiedUpdateCacheFrequency());
+
Cell indexDisableTimestampKv = tableKeyValues[INDEX_DISABLE_TIMESTAMP];
long indexDisableTimestamp = indexDisableTimestampKv == null ? 0L :
PLong.INSTANCE.getCodec().decodeLong(indexDisableTimestampKv.getValueArray(),
indexDisableTimestampKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setIndexDisableTimestamp(indexDisableTimestampKv != null ?
+ indexDisableTimestamp : oldTable != null ?
oldTable.getIndexDisableTimestamp() : 0L);
+
Cell isNamespaceMappedKv = tableKeyValues[IS_NAMESPACE_MAPPED_INDEX];
- boolean isNamespaceMapped = isNamespaceMappedKv == null ? false
- :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(isNamespaceMappedKv.getValueArray(),
+ boolean isNamespaceMapped = isNamespaceMappedKv != null &&
Boolean.TRUE.equals(
+ PBoolean.INSTANCE.toObject(isNamespaceMappedKv.getValueArray(),
isNamespaceMappedKv.getValueOffset(),
isNamespaceMappedKv.getValueLength()));
+ builder.setNamespaceMapped(isNamespaceMappedKv != null ?
isNamespaceMapped :
+ oldTable != null && oldTable.isNamespaceMapped());
+
Cell autoPartitionSeqKv = tableKeyValues[AUTO_PARTITION_SEQ_INDEX];
String autoPartitionSeq = autoPartitionSeqKv != null ? (String)
PVarchar.INSTANCE.toObject(autoPartitionSeqKv.getValueArray(),
autoPartitionSeqKv.getValueOffset(),
autoPartitionSeqKv.getValueLength()) : null;
+ builder.setAutoPartitionSeqName(autoPartitionSeq != null
+ ? autoPartitionSeq : oldTable != null ?
oldTable.getAutoPartitionSeqName() : null);
+
Cell isAppendOnlySchemaKv = tableKeyValues[APPEND_ONLY_SCHEMA_INDEX];
- boolean isAppendOnlySchema = isAppendOnlySchemaKv == null ? false
- :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(isAppendOnlySchemaKv.getValueArray(),
+ boolean isAppendOnlySchema = isAppendOnlySchemaKv != null &&
Boolean.TRUE.equals(
+ PBoolean.INSTANCE.toObject(isAppendOnlySchemaKv.getValueArray(),
isAppendOnlySchemaKv.getValueOffset(),
isAppendOnlySchemaKv.getValueLength()));
+ builder.setAppendOnlySchema(isAppendOnlySchemaKv != null ?
isAppendOnlySchema :
+ oldTable != null && oldTable.isAppendOnlySchema());
+
Cell storageSchemeKv = tableKeyValues[STORAGE_SCHEME_INDEX];
//TODO: change this once we start having other values for storage
schemes
ImmutableStorageScheme storageScheme = storageSchemeKv == null ?
ImmutableStorageScheme.ONE_CELL_PER_COLUMN : ImmutableStorageScheme
.fromSerializedValue((byte)
PTinyint.INSTANCE.toObject(storageSchemeKv.getValueArray(),
storageSchemeKv.getValueOffset(),
storageSchemeKv.getValueLength()));
+ builder.setImmutableStorageScheme(storageSchemeKv != null ?
storageScheme :
+ oldTable != null ? oldTable.getImmutableStorageScheme() :
ImmutableStorageScheme.ONE_CELL_PER_COLUMN);
+
Cell encodingSchemeKv =
tableKeyValues[QUALIFIER_ENCODING_SCHEME_INDEX];
QualifierEncodingScheme encodingScheme = encodingSchemeKv == null ?
QualifierEncodingScheme.NON_ENCODED_QUALIFIERS : QualifierEncodingScheme
.fromSerializedValue((byte)
PTinyint.INSTANCE.toObject(encodingSchemeKv.getValueArray(),
encodingSchemeKv.getValueOffset(),
encodingSchemeKv.getValueLength()));
+ builder.setQualifierEncodingScheme(encodingSchemeKv != null ?
encodingScheme :
+ oldTable != null ? oldTable.getEncodingScheme() :
QualifierEncodingScheme.NON_ENCODED_QUALIFIERS);
+
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()));
+ Boolean useStatsForParallelization = useStatsForParallelizationKv ==
null ? null :
+
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(useStatsForParallelizationKv.getValueArray(),
useStatsForParallelizationKv.getValueOffset(),
useStatsForParallelizationKv.getValueLength()));
+ builder.setUseStatsForParallelization(useStatsForParallelization !=
null ?
+ useStatsForParallelization : oldTable != null ?
oldTable.useStatsForParallelization() : null);
Cell phoenixTTLKv = tableKeyValues[PHOENIX_TTL_INDEX];
long phoenixTTL = phoenixTTLKv == null ? PHOENIX_TTL_NOT_DEFINED :
PLong.INSTANCE.getCodec().decodeLong(phoenixTTLKv.getValueArray(),
phoenixTTLKv.getValueOffset(), SortOrder.getDefault());
+ builder.setPhoenixTTL(phoenixTTLKv != null ? phoenixTTL :
+ oldTable != null ? oldTable.getPhoenixTTL() :
PHOENIX_TTL_NOT_DEFINED);
Cell phoenixTTLHWMKv = tableKeyValues[PHOENIX_TTL_HWM_INDEX];
long phoenixTTLHWM = phoenixTTLHWMKv == null ? MIN_PHOENIX_TTL_HWM :
PLong.INSTANCE.getCodec().decodeLong(phoenixTTLHWMKv.getValueArray(),
phoenixTTLHWMKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setPhoenixTTLHighWaterMark(phoenixTTLHWMKv != null ?
phoenixTTLHWM :
+ oldTable != null ? oldTable.getPhoenixTTLHighWaterMark() :
MIN_PHOENIX_TTL_HWM);
// Check the cell tag to see whether the view has modified this
property
final byte[] tagPhoenixTTL = (phoenixTTLKv == null) ?
HConstants.EMPTY_BYTE_ARRAY :
CellUtil.getTagArray(phoenixTTLKv);
boolean viewModifiedPhoenixTTL = (PTableType.VIEW.equals(tableType)) &&
Bytes.contains(tagPhoenixTTL, VIEW_MODIFIED_PROPERTY_BYTES);
+ builder.setViewModifiedPhoenixTTL(oldTable != null ?
+ oldTable.hasViewModifiedPhoenixTTL() || viewModifiedPhoenixTTL :
viewModifiedPhoenixTTL);
Cell lastDDLTimestampKv = tableKeyValues[LAST_DDL_TIMESTAMP_INDEX];
Long lastDDLTimestamp = lastDDLTimestampKv == null ?
null :
PLong.INSTANCE.getCodec().decodeLong(lastDDLTimestampKv.getValueArray(),
lastDDLTimestampKv.getValueOffset(), SortOrder.getDefault());
+ builder.setLastDDLTimestamp(lastDDLTimestampKv != null ?
lastDDLTimestamp :
+ oldTable != null ? oldTable.getLastDDLTimestamp() : null);
Cell changeDetectionEnabledKv =
tableKeyValues[CHANGE_DETECTION_ENABLED_INDEX];
boolean isChangeDetectionEnabled = changeDetectionEnabledKv != null
&&
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(changeDetectionEnabledKv.getValueArray(),
changeDetectionEnabledKv.getValueOffset(),
changeDetectionEnabledKv.getValueLength()));
+ builder.setIsChangeDetectionEnabled(changeDetectionEnabledKv != null ?
+ isChangeDetectionEnabled : oldTable != null &&
oldTable.isChangeDetectionEnabled());
Cell schemaVersionKv = tableKeyValues[SCHEMA_VERSION_INDEX];
String schemaVersion = schemaVersionKv != null ? (String)
PVarchar.INSTANCE.toObject(
schemaVersionKv.getValueArray(),
schemaVersionKv.getValueOffset(), schemaVersionKv.getValueLength())
: null;
+ builder.setSchemaVersion(schemaVersion != null ?
+ schemaVersion : oldTable != null ? oldTable.getSchemaVersion() :
null);
+
+ Cell externalSchemaIdKv = tableKeyValues[EXTERNAL_SCHEMA_ID_INDEX];
+ String externalSchemaId = externalSchemaIdKv != null ?
+ (String)
PVarchar.INSTANCE.toObject(externalSchemaIdKv.getValueArray(),
+ externalSchemaIdKv.getValueOffset(),
externalSchemaIdKv.getValueLength())
+ : null;
+ builder.setExternalSchemaId(externalSchemaId != null ?
externalSchemaId :
+ oldTable != null ? oldTable.getExternalSchemaId() : null);
// 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);
+
builder.setViewModifiedUseStatsForParallelization(viewModifiedUseStatsForParallelization
||
+ (oldTable != null &&
oldTable.hasViewModifiedUseStatsForParallelization()));
+ boolean setPhysicalName = false;
Review comment:
Could you explain more about how that would be a problem? Note that
oldTable is only not-null when getTableFromCells is called during schema
registry export during an ALTER when we're trying to create a PTable that
merges in the Cells from the ALTER statement + the existing PTable. This is
just trying to say that if we didn't already figure out the physical name from
any PHYSICAL linking rows passed in as Cells, grab it from the previous
(pre-ALTER) version of the PTable we got from the client.
In the schema-registry export during CREATE case, oldTable is null and we
should populate everything from the Cells we're passed in.
In all other cases (we call this during a getTable() cache refresh) it
should work the same as it's always worked.
That said, I found the physicalNames/physicalTable/parentName APIs a bit
confusing so if I've missed something please let me know. (And of course this
will probably have to be tweaked some when your transform work gets merged in
later.)
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1148,115 +1235,203 @@ private PTable getTable(RegionScanner scanner, long
clientTimeStamp, long tableT
transactionProviderKv.getValueOffset(),
SortOrder.getDefault()));
}
+ builder.setTransactionProvider(transactionProviderKv != null ||
transactionalKv != null
+ ? transactionProvider : oldTable != null ?
oldTable.getTransactionProvider() : null);
+
Cell viewTypeKv = tableKeyValues[VIEW_TYPE_INDEX];
ViewType viewType = viewTypeKv == null ? null :
ViewType.fromSerializedValue(viewTypeKv.getValueArray()[viewTypeKv.getValueOffset()]);
- PDataType viewIndexIdType = getViewIndexIdType(tableKeyValues);
+ builder.setViewType(viewType != null ? viewType : oldTable != null ?
oldTable.getViewType() : null);
+
+ PDataType viewIndexIdType = oldTable != null ?
oldTable.getviewIndexIdType() :
+ getViewIndexIdType(tableKeyValues);
+ builder.setViewIndexIdType(viewIndexIdType);
+
Long viewIndexId = getViewIndexId(tableKeyValues, viewIndexIdType);
+ builder.setViewIndexId(viewIndexId != null ? viewIndexId : oldTable !=
null ? oldTable.getViewIndexId() : null);
+
Cell indexTypeKv = tableKeyValues[INDEX_TYPE_INDEX];
IndexType indexType = indexTypeKv == null ? null :
IndexType.fromSerializedValue(indexTypeKv.getValueArray()[indexTypeKv.getValueOffset()]);
+ builder.setIndexType(indexType != null ? indexType : oldTable != null
? oldTable.getIndexType() : null);
+
Cell baseColumnCountKv = tableKeyValues[BASE_COLUMN_COUNT_INDEX];
int baseColumnCount = baseColumnCountKv == null ? 0 :
PInteger.INSTANCE.getCodec().decodeInt(baseColumnCountKv.getValueArray(),
baseColumnCountKv.getValueOffset(), SortOrder.getDefault());
+ builder.setBaseColumnCount(baseColumnCountKv != null ? baseColumnCount
: oldTable != null ? oldTable.getBaseColumnCount() : 0);
+
Cell rowKeyOrderOptimizableKv =
tableKeyValues[ROW_KEY_ORDER_OPTIMIZABLE_INDEX];
- boolean rowKeyOrderOptimizable = rowKeyOrderOptimizableKv == null ?
false :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(rowKeyOrderOptimizableKv.getValueArray(),
rowKeyOrderOptimizableKv.getValueOffset(),
rowKeyOrderOptimizableKv.getValueLength()));
+ boolean rowKeyOrderOptimizable = rowKeyOrderOptimizableKv != null &&
Boolean.TRUE.equals(
+
PBoolean.INSTANCE.toObject(rowKeyOrderOptimizableKv.getValueArray(),
+ rowKeyOrderOptimizableKv.getValueOffset(),
+ rowKeyOrderOptimizableKv.getValueLength()));
+ builder.setRowKeyOrderOptimizable(rowKeyOrderOptimizableKv != null ?
rowKeyOrderOptimizable :
+ oldTable != null && oldTable.rowKeyOrderOptimizable());
+
Cell updateCacheFrequencyKv =
tableKeyValues[UPDATE_CACHE_FREQUENCY_INDEX];
long updateCacheFrequency = updateCacheFrequencyKv == null ? 0 :
PLong.INSTANCE.getCodec().decodeLong(updateCacheFrequencyKv.getValueArray(),
updateCacheFrequencyKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setUpdateCacheFrequency(updateCacheFrequencyKv != null ?
updateCacheFrequency : oldTable != null ? oldTable.getUpdateCacheFrequency() :
0);
// 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);
+
builder.setViewModifiedUpdateCacheFrequency(!Bytes.equals(tagUpdateCacheFreq,
+ HConstants.EMPTY_BYTE_ARRAY) ? viewModifiedUpdateCacheFrequency :
+ oldTable != null &&
oldTable.hasViewModifiedUpdateCacheFrequency());
+
Cell indexDisableTimestampKv = tableKeyValues[INDEX_DISABLE_TIMESTAMP];
long indexDisableTimestamp = indexDisableTimestampKv == null ? 0L :
PLong.INSTANCE.getCodec().decodeLong(indexDisableTimestampKv.getValueArray(),
indexDisableTimestampKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setIndexDisableTimestamp(indexDisableTimestampKv != null ?
+ indexDisableTimestamp : oldTable != null ?
oldTable.getIndexDisableTimestamp() : 0L);
+
Cell isNamespaceMappedKv = tableKeyValues[IS_NAMESPACE_MAPPED_INDEX];
- boolean isNamespaceMapped = isNamespaceMappedKv == null ? false
- :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(isNamespaceMappedKv.getValueArray(),
+ boolean isNamespaceMapped = isNamespaceMappedKv != null &&
Boolean.TRUE.equals(
+ PBoolean.INSTANCE.toObject(isNamespaceMappedKv.getValueArray(),
isNamespaceMappedKv.getValueOffset(),
isNamespaceMappedKv.getValueLength()));
+ builder.setNamespaceMapped(isNamespaceMappedKv != null ?
isNamespaceMapped :
+ oldTable != null && oldTable.isNamespaceMapped());
+
Cell autoPartitionSeqKv = tableKeyValues[AUTO_PARTITION_SEQ_INDEX];
String autoPartitionSeq = autoPartitionSeqKv != null ? (String)
PVarchar.INSTANCE.toObject(autoPartitionSeqKv.getValueArray(),
autoPartitionSeqKv.getValueOffset(),
autoPartitionSeqKv.getValueLength()) : null;
+ builder.setAutoPartitionSeqName(autoPartitionSeq != null
+ ? autoPartitionSeq : oldTable != null ?
oldTable.getAutoPartitionSeqName() : null);
+
Cell isAppendOnlySchemaKv = tableKeyValues[APPEND_ONLY_SCHEMA_INDEX];
- boolean isAppendOnlySchema = isAppendOnlySchemaKv == null ? false
- :
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(isAppendOnlySchemaKv.getValueArray(),
+ boolean isAppendOnlySchema = isAppendOnlySchemaKv != null &&
Boolean.TRUE.equals(
+ PBoolean.INSTANCE.toObject(isAppendOnlySchemaKv.getValueArray(),
isAppendOnlySchemaKv.getValueOffset(),
isAppendOnlySchemaKv.getValueLength()));
+ builder.setAppendOnlySchema(isAppendOnlySchemaKv != null ?
isAppendOnlySchema :
+ oldTable != null && oldTable.isAppendOnlySchema());
+
Cell storageSchemeKv = tableKeyValues[STORAGE_SCHEME_INDEX];
//TODO: change this once we start having other values for storage
schemes
ImmutableStorageScheme storageScheme = storageSchemeKv == null ?
ImmutableStorageScheme.ONE_CELL_PER_COLUMN : ImmutableStorageScheme
.fromSerializedValue((byte)
PTinyint.INSTANCE.toObject(storageSchemeKv.getValueArray(),
storageSchemeKv.getValueOffset(),
storageSchemeKv.getValueLength()));
+ builder.setImmutableStorageScheme(storageSchemeKv != null ?
storageScheme :
+ oldTable != null ? oldTable.getImmutableStorageScheme() :
ImmutableStorageScheme.ONE_CELL_PER_COLUMN);
+
Cell encodingSchemeKv =
tableKeyValues[QUALIFIER_ENCODING_SCHEME_INDEX];
QualifierEncodingScheme encodingScheme = encodingSchemeKv == null ?
QualifierEncodingScheme.NON_ENCODED_QUALIFIERS : QualifierEncodingScheme
.fromSerializedValue((byte)
PTinyint.INSTANCE.toObject(encodingSchemeKv.getValueArray(),
encodingSchemeKv.getValueOffset(),
encodingSchemeKv.getValueLength()));
+ builder.setQualifierEncodingScheme(encodingSchemeKv != null ?
encodingScheme :
+ oldTable != null ? oldTable.getEncodingScheme() :
QualifierEncodingScheme.NON_ENCODED_QUALIFIERS);
+
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()));
+ Boolean useStatsForParallelization = useStatsForParallelizationKv ==
null ? null :
+
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(useStatsForParallelizationKv.getValueArray(),
useStatsForParallelizationKv.getValueOffset(),
useStatsForParallelizationKv.getValueLength()));
+ builder.setUseStatsForParallelization(useStatsForParallelization !=
null ?
+ useStatsForParallelization : oldTable != null ?
oldTable.useStatsForParallelization() : null);
Cell phoenixTTLKv = tableKeyValues[PHOENIX_TTL_INDEX];
long phoenixTTL = phoenixTTLKv == null ? PHOENIX_TTL_NOT_DEFINED :
PLong.INSTANCE.getCodec().decodeLong(phoenixTTLKv.getValueArray(),
phoenixTTLKv.getValueOffset(), SortOrder.getDefault());
+ builder.setPhoenixTTL(phoenixTTLKv != null ? phoenixTTL :
+ oldTable != null ? oldTable.getPhoenixTTL() :
PHOENIX_TTL_NOT_DEFINED);
Cell phoenixTTLHWMKv = tableKeyValues[PHOENIX_TTL_HWM_INDEX];
long phoenixTTLHWM = phoenixTTLHWMKv == null ? MIN_PHOENIX_TTL_HWM :
PLong.INSTANCE.getCodec().decodeLong(phoenixTTLHWMKv.getValueArray(),
phoenixTTLHWMKv.getValueOffset(),
SortOrder.getDefault());
+ builder.setPhoenixTTLHighWaterMark(phoenixTTLHWMKv != null ?
phoenixTTLHWM :
+ oldTable != null ? oldTable.getPhoenixTTLHighWaterMark() :
MIN_PHOENIX_TTL_HWM);
// Check the cell tag to see whether the view has modified this
property
final byte[] tagPhoenixTTL = (phoenixTTLKv == null) ?
HConstants.EMPTY_BYTE_ARRAY :
CellUtil.getTagArray(phoenixTTLKv);
boolean viewModifiedPhoenixTTL = (PTableType.VIEW.equals(tableType)) &&
Bytes.contains(tagPhoenixTTL, VIEW_MODIFIED_PROPERTY_BYTES);
+ builder.setViewModifiedPhoenixTTL(oldTable != null ?
+ oldTable.hasViewModifiedPhoenixTTL() || viewModifiedPhoenixTTL :
viewModifiedPhoenixTTL);
Cell lastDDLTimestampKv = tableKeyValues[LAST_DDL_TIMESTAMP_INDEX];
Long lastDDLTimestamp = lastDDLTimestampKv == null ?
null :
PLong.INSTANCE.getCodec().decodeLong(lastDDLTimestampKv.getValueArray(),
lastDDLTimestampKv.getValueOffset(), SortOrder.getDefault());
+ builder.setLastDDLTimestamp(lastDDLTimestampKv != null ?
lastDDLTimestamp :
+ oldTable != null ? oldTable.getLastDDLTimestamp() : null);
Cell changeDetectionEnabledKv =
tableKeyValues[CHANGE_DETECTION_ENABLED_INDEX];
boolean isChangeDetectionEnabled = changeDetectionEnabledKv != null
&&
Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(changeDetectionEnabledKv.getValueArray(),
changeDetectionEnabledKv.getValueOffset(),
changeDetectionEnabledKv.getValueLength()));
+ builder.setIsChangeDetectionEnabled(changeDetectionEnabledKv != null ?
+ isChangeDetectionEnabled : oldTable != null &&
oldTable.isChangeDetectionEnabled());
Cell schemaVersionKv = tableKeyValues[SCHEMA_VERSION_INDEX];
String schemaVersion = schemaVersionKv != null ? (String)
PVarchar.INSTANCE.toObject(
schemaVersionKv.getValueArray(),
schemaVersionKv.getValueOffset(), schemaVersionKv.getValueLength())
: null;
+ builder.setSchemaVersion(schemaVersion != null ?
+ schemaVersion : oldTable != null ? oldTable.getSchemaVersion() :
null);
+
+ Cell externalSchemaIdKv = tableKeyValues[EXTERNAL_SCHEMA_ID_INDEX];
+ String externalSchemaId = externalSchemaIdKv != null ?
+ (String)
PVarchar.INSTANCE.toObject(externalSchemaIdKv.getValueArray(),
+ externalSchemaIdKv.getValueOffset(),
externalSchemaIdKv.getValueLength())
+ : null;
+ builder.setExternalSchemaId(externalSchemaId != null ?
externalSchemaId :
+ oldTable != null ? oldTable.getExternalSchemaId() : null);
// 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);
+
builder.setViewModifiedUseStatsForParallelization(viewModifiedUseStatsForParallelization
||
+ (oldTable != null &&
oldTable.hasViewModifiedUseStatsForParallelization()));
+ boolean setPhysicalName = false;
Review comment:
@gokceni Could you explain more about how that would be a problem? Note
that oldTable is only not-null when getTableFromCells is called during schema
registry export during an ALTER when we're trying to create a PTable that
merges in the Cells from the ALTER statement + the existing PTable. This is
just trying to say that if we didn't already figure out the physical name from
any PHYSICAL linking rows passed in as Cells, grab it from the previous
(pre-ALTER) version of the PTable we got from the client.
In the schema-registry export during CREATE case, oldTable is null and we
should populate everything from the Cells we're passed in.
In all other cases (we call this during a getTable() cache refresh) it
should work the same as it's always worked.
That said, I found the physicalNames/physicalTable/parentName APIs a bit
confusing so if I've missed something please let me know. (And of course this
will probably have to be tweaked some when your transform work gets merged in
later.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
> Option for DDL changes to export to external schema repository
> --------------------------------------------------------------
>
> Key: PHOENIX-6227
> URL: https://issues.apache.org/jira/browse/PHOENIX-6227
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Geoffrey Jacoby
> Assignee: Geoffrey Jacoby
> Priority: Major
> Fix For: 4.17.0, 5.2.0
>
>
> When a user creates or drops a table or view, or adds/removes a column from
> one, there should be the option for Phoenix to notify an external schema
> repository. This should be a configurable plugin so that core Phoenix is not
> coupled to any particular repository implementation.
> This will also store a schema id generated by the external schema registry in
> a new field in System.Catalog so that a future JIRA can switch to using the
> schema id in change detection WAL annotations. Because of this this JIRA will
> not be able to be backported to 5.1.x or 4.16.x
--
This message was sent by Atlassian Jira
(v8.3.4#803005)