Jackie-Jiang commented on code in PR #15817: URL: https://github.com/apache/pinot/pull/15817#discussion_r2116859577
########## pinot-common/src/main/java/org/apache/pinot/common/utils/SegmentUtils.java: ########## @@ -97,6 +105,162 @@ private static Integer getRealtimeSegmentPartitionId(SegmentZKMetadata segmentZK return null; } + /** + * Return the partitionId for an OFFLINE or COMPLETED instance partitions of a REALTIME table with relocation enabled + * The partitionId will be calculated as: + * <ul> + * <li> + * 1. If numPartitions = 1, return partitionId = 0 + * </li> + * <li> + * 2. Otherwise, fallback to either the OFFLINE or REALTIME partitionId calculation logic + * </li> + * </ul> + */ + public static int getOfflineOrCompletedPartitionId(String segmentName, String tableName, TableType tableType, + HelixManager helixManager, int numPartitions, @Nullable String partitionColumn) { + int partitionId; + if (numPartitions == 1) { + partitionId = 0; + } else { + // Uniformly spray the segment partitions over the instance partitions + if (tableType == TableType.OFFLINE) { + partitionId = SegmentUtils + .getOfflineSegmentPartitionId(segmentName, tableName, helixManager, partitionColumn); + } else { + partitionId = SegmentUtils + .getRealtimeSegmentPartitionIdOrDefault(segmentName, tableName, helixManager, partitionColumn); + } + } + return partitionId; Review Comment: We need to `% numPartitions` here because the returned partition id must be smaller than the passed in `numPartitions` -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org