Copilot commented on code in PR #16720:
URL: https://github.com/apache/iotdb/pull/16720#discussion_r2509176041


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/table/AddTableColumnProcedure.java:
##########
@@ -123,7 +134,53 @@ protected void columnCheck(final ConfigNodeProcedureEnv 
env) {
   @Override
   protected void preRelease(final ConfigNodeProcedureEnv env) {
     super.preRelease(env);
-    setNextState(AddTableColumnState.ADD_COLUMN);
+  }
+
+  private void checkObject(
+      final ConfigNodeProcedureEnv env, final String database, final String 
tableName) {
+    final Map<TConsensusGroupId, TRegionReplicaSet> relatedRegionGroup =
+        
env.getConfigManager().getRelatedSchemaRegionGroup4TableModel(database);
+
+    if (!relatedRegionGroup.isEmpty()) {
+      new TableRegionTaskExecutor<>(
+              "check deviceId for object",
+              env,
+              relatedRegionGroup,
+              CnToDnAsyncRequestType.CHECK_DEVICE_ID_FOR_OBJECT,
+              ((dataNodeLocation, consensusGroupIdList) ->
+                  new TCheckDeviceIdForObjectReq(new 
ArrayList<>(consensusGroupIdList), tableName)),
+              ((tConsensusGroupId, tDataNodeLocations, failureMap) -> {
+                final String message = parseStatus(failureMap.values());
+                // Shall not be SUCCESS here
+                return Objects.nonNull(message)
+                    ? new IoTDBRuntimeException(
+                        message, TSStatusCode.SEMANTIC_ERROR.getStatusCode())
+                    : null;
+              }))
+          .execute();
+    }
+  }
+
+  // Success: ""
+  // All semantic: return last one
+  // Non-semantic error: return null
+  private String parseStatus(final Iterable<TSStatus> statuses) {
+    String message = "";
+    for (final TSStatus status : statuses) {
+      if (status.getCode() == TSStatusCode.SEMANTIC_ERROR.getStatusCode()) {
+        message = status.getMessage();

Review Comment:
   Initializing 'message' to empty string and then reassigning it in the loop 
is inefficient. Consider initializing to null and using Objects.isNull() 
checks, or restructure to return early when a semantic error is found, to avoid 
unnecessary string assignments.



-- 
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]

Reply via email to