Copilot commented on code in PR #62083:
URL: https://github.com/apache/doris/pull/62083#discussion_r3031339545


##########
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java:
##########
@@ -68,7 +68,7 @@ public class CloudReplica extends Replica implements 
GsonPostProcessable {
     @SerializedName(value = "indexId")
     private long indexId = -1;
     @SerializedName(value = "idx")
-    private long idx = -1;
+    private int idx = -1;
     // last time to get tablet stats

Review Comment:
   Changing `idx`’s persisted type (`long` -> `int`) relies on Gson coercion 
for old images and on the new narrowing behavior in constructors. Please 
add/extend a unit test that deserializes a legacy JSON payload where `idx` is 
encoded as a JSON number (previously treated as `long`) and asserts the loaded 
`CloudReplica#getIdx()` value is preserved (and that out-of-range values fail 
in a controlled way if applicable).



##########
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java:
##########
@@ -116,7 +116,7 @@ public CloudReplica(long replicaId, Long backendId, 
ReplicaState state, long ver
         this.tableId = tableId;
         this.partitionId = partitionId;
         this.indexId = indexId;
-        this.idx = idx;
+        this.idx = (int) idx;

Review Comment:
   The constructor narrows `idx` from `long` to `int` via a plain cast. If a 
caller ever passes a value outside the `int` range, this will silently wrap and 
can change BE hashing/placement behavior. Consider using `Math.toIntExact(idx)` 
(optionally allowing `-1` sentinel) or an explicit range check that throws a 
clear exception when out of range.
   ```suggestion
           this.idx = Math.toIntExact(idx);
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to