jt2594838 commented on code in PR #16672: URL: https://github.com/apache/iotdb/pull/16672#discussion_r2485185788
########## iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterEncodingCompressorProcedure.java: ########## @@ -0,0 +1,329 @@ +/* + * 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.iotdb.confignode.procedure.impl.schema; + +import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.commons.exception.MetadataException; +import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.commons.path.PathPatternTree; +import org.apache.iotdb.commons.utils.SerializeUtils; +import org.apache.iotdb.commons.utils.TestOnly; +import org.apache.iotdb.confignode.client.async.CnToDnAsyncRequestType; +import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeAlterEncodingCompressorPlan; +import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; +import org.apache.iotdb.confignode.manager.ClusterManager; +import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; +import org.apache.iotdb.confignode.procedure.exception.ProcedureException; +import org.apache.iotdb.confignode.procedure.impl.StateMachineProcedure; +import org.apache.iotdb.confignode.procedure.state.AlterEncodingCompressorState; +import org.apache.iotdb.confignode.procedure.store.ProcedureType; +import org.apache.iotdb.consensus.exception.ConsensusException; +import org.apache.iotdb.db.exception.metadata.PathNotExistException; +import org.apache.iotdb.mpp.rpc.thrift.TAlterEncodingCompressorReq; +import org.apache.iotdb.pipe.api.exception.PipeException; +import org.apache.iotdb.rpc.TSStatusCode; + +import org.apache.tsfile.utils.ReadWriteIOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.apache.iotdb.confignode.procedure.impl.schema.DeleteTimeSeriesProcedure.invalidateCache; +import static org.apache.iotdb.confignode.procedure.impl.schema.DeleteTimeSeriesProcedure.preparePatternTreeBytesData; + +public class AlterEncodingCompressorProcedure + extends StateMachineProcedure<ConfigNodeProcedureEnv, AlterEncodingCompressorState> { + private static final Logger LOGGER = LoggerFactory.getLogger(AlterEncodingCompressorState.class); + private String queryId; + private PathPatternTree patternTree; + private boolean ifExists; + private byte encoding; + private byte compressor; + private boolean mayAlterAudit; + + private transient ByteBuffer patternTreeBytes; + private transient String requestMessage; + + public AlterEncodingCompressorProcedure(final boolean isGeneratedByPipe) { + super(isGeneratedByPipe); + } + + public AlterEncodingCompressorProcedure( + final boolean isGeneratedByPipe, + final String queryId, + final PathPatternTree pathPatternTree, + final boolean ifExists, + final byte encoding, + final byte compressor, + final boolean mayAlterAudit) { + super(isGeneratedByPipe); + this.queryId = queryId; + setPatternTree(pathPatternTree); + this.ifExists = ifExists; + this.encoding = encoding; + this.compressor = compressor; + this.mayAlterAudit = mayAlterAudit; + } + + public String getQueryId() { + return queryId; + } + + @TestOnly + public PathPatternTree getPatternTree() { + return patternTree; + } + + public void setPatternTree(final PathPatternTree patternTree) { + this.patternTree = patternTree; + requestMessage = patternTree.getAllPathPatterns().toString(); + patternTreeBytes = preparePatternTreeBytesData(patternTree); + } + + @Override + protected Flow executeFromState( + final ConfigNodeProcedureEnv env, final AlterEncodingCompressorState state) + throws InterruptedException { + final long startTime = System.currentTimeMillis(); + try { + switch (state) { + case ALTER_SCHEMA_REGION: + LOGGER.info( + "Alter encoding {} & compressor {} in schema region for timeSeries {}", + SerializeUtils.deserializeEncodingNullable(encoding), + SerializeUtils.deserializeCompressorNullable(compressor), + requestMessage); Review Comment: Surround with `isInfoEnabled` ########## iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/PathPatternTree.java: ########## @@ -113,6 +121,11 @@ public void appendPathPattern(PartialPath pathPattern) { pathPatternList.removeIf(pathPattern::include); pathPatternList.add(pathPattern); } + if (isReload) { + // Currently no need to construct here, cause the usage if "getAllPathPatterns" after it. + // Future calls may chan this considering their own use Review Comment: Hard to understand. Try to rephrase them in a clearer way. ########## iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4: ########## @@ -177,6 +177,10 @@ alterClause | UPSERT aliasClause? tagClause? attributeClause? ; +alterEncodingCompressor + : ALTER TIMESERIES (IF EXISTS)? (IF PERMITTED)? prefixPath (COMMA prefixPath)* SET attributePair (COMMA attributePair)* + ; Review Comment: Add some tests regarding invalid attribute keys. -- 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]
