Copilot commented on code in PR #19251:
URL: https://github.com/apache/pinot/pull/19251#discussion_r3778958824
##########
pinot-common/src/main/java/org/apache/pinot/common/protocols/SegmentCompletionProtocol.java:
##########
@@ -150,6 +151,52 @@ public enum ControllerResponseStatus {
// (like size reaching close to its limit or number of col values for a col
is about to overflow int max)
public static final String REASON_INDEX_CAPACITY_THRESHOLD_BREACHED =
"indexCapacityThresholdBreached";
+ public enum ReasonCode {
+ ROW_LIMIT(REASON_ROW_LIMIT),
+ TIME_LIMIT(REASON_TIME_LIMIT),
+ END_OF_PARTITION_GROUP(REASON_END_OF_PARTITION_GROUP),
+ FORCE_COMMIT_MESSAGE_RECEIVED(REASON_FORCE_COMMIT_MESSAGE_RECEIVED),
+
INDEX_CAPACITY_THRESHOLD_BREACHED(REASON_INDEX_CAPACITY_THRESHOLD_BREACHED);
+
+ private final String _reason;
+
+ ReasonCode(String reason) {
+ _reason = reason;
+ }
+
+ public String getReason() {
+ return _reason;
+ }
+
+ public boolean shouldPickWinnerImmediately() {
+ return this == ROW_LIMIT || this == END_OF_PARTITION_GROUP;
+ }
+
+ public static ReasonCode fromCode(String reasonCode) {
Review Comment:
This parser intentionally returns `null` for absent or unknown codes, but
its public signature is unannotated under the repository's non-null-by-default
convention. Mark the return `@Nullable` so callers and null-analysis tools can
handle unknown future codes correctly.
This issue also appears in the following locations of the same file:
- line 187
- line 405
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -335,7 +335,7 @@ public void deleteSegmentFile() {
private long _consumeStartTime = -1;
private long _lastLogTime = 0;
private int _lastConsumedCount = 0;
- private String _stopReason = null;
+ private SegmentCompletionProtocol.ReasonCode _stopReasonCode = null;
Review Comment:
Renaming this field leaves
`RealtimeSegmentDataManagerTest.FakeRealtimeSegmentDataManager` reflecting
`getDeclaredField("_stopReason")` and casting it to `String` (lines 1406–1424).
Constructing the fake now throws `NoSuchFieldException`, so the existing
pinot-core test suite will fail before exercising this behavior. Update that
test helper and its assertions to use `_stopReasonCode`/`ReasonCode`.
--
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]