You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/04/30 02:36:25 UTC

[GitHub] [pinot] sajjad-moradi commented on a diff in pull request #8584: Enable uploading segments to realtime tables

sajjad-moradi commented on code in PR #8584:
URL: https://github.com/apache/pinot/pull/8584#discussion_r862282194


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/assignment/segment/RealtimeSegmentAssignment.java:
##########
@@ -368,12 +364,19 @@ private List<String> assignCompletedSegment(String segmentName, Map<String, Map<
       // Replica-group based assignment
 
       // Uniformly spray the segment partitions over the instance partitions
-      int segmentPartitionId =
-          SegmentUtils.getRealtimeSegmentPartitionId(segmentName, _realtimeTableName, _helixManager, _partitionColumn);
-      int numPartitions = instancePartitions.getNumPartitions();
-      int partitionGroupId = segmentPartitionId % numPartitions;
-      return SegmentAssignmentUtils
-          .assignSegmentWithReplicaGroup(currentAssignment, instancePartitions, partitionGroupId);
+      int partitionId = getPartitionGroupId(segmentName) % instancePartitions.getNumPartitions();
+      return SegmentAssignmentUtils.assignSegmentWithReplicaGroup(currentAssignment, instancePartitions, partitionId);
+    }
+  }
+
+  private int getPartitionGroupId(String segmentName) {
+    Integer segmentPartitionId =
+        SegmentUtils.getRealtimeSegmentPartitionId(segmentName, _realtimeTableName, _helixManager, _partitionColumn);
+    if (segmentPartitionId == null) {
+      // This case is for the uploaded segments for which there's no partition information
+      // Choose a random, but consistent, partition id
+      segmentPartitionId = Math.abs(segmentName.hashCode());

Review Comment:
   Good catch. I'll update with an upper bound.



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org