Jackie-Jiang commented on code in PR #8584:
URL: https://github.com/apache/pinot/pull/8584#discussion_r874240901


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -2048,6 +2034,39 @@ public void assignTableSegment(String tableNameWithType, 
String segmentName) {
     }
   }
 
+  private Map<InstancePartitionsType, InstancePartitions> 
fetchOrComputeInstancePartitions(String tableNameWithType,
+      TableConfig tableConfig) {
+    boolean isOfflineTable = 
!TableNameBuilder.isRealtimeTableResource(tableNameWithType);
+    boolean isUpsertTable = !isOfflineTable && tableConfig.getUpsertMode() != 
UpsertConfig.Mode.NONE;
+    InstancePartitionsType instancePartitionsType = null;
+    if (isOfflineTable) {
+      instancePartitionsType = InstancePartitionsType.OFFLINE;
+    } else if (isUpsertTable) {
+      // In an upsert enabled LLC realtime table, all segments of the same 
partition are collocated on the same server
+      // -- consuming or completed. So it is fine to use CONSUMING as the 
InstancePartitionsType.
+      instancePartitionsType = InstancePartitionsType.CONSUMING;
+    }
+    if (isOfflineTable || isUpsertTable) {
+      return Collections.singletonMap(instancePartitionsType, 
InstancePartitionsUtils
+          .fetchOrComputeInstancePartitions(_helixZkManager, tableConfig, 
instancePartitionsType));
+    }

Review Comment:
   (minor) slightly more readable to me
   ```suggestion
       if (TableNameBuilder.isOfflineTableResource(tableNameWithType) {
         return Collections.singletonMap(InstancePartitionsType.OFFLINE, 
InstancePartitionsUtils
             .fetchOrComputeInstancePartitions(_helixZkManager, tableConfig, 
InstancePartitionsType.OFFLINE));
       }
       if (tableConfig.getUpsertMode() != UpsertConfig.Mode.NONE) {
         // In an upsert enabled LLC realtime table, all segments of the same 
partition are collocated on the same server
         // -- consuming or completed. So it is fine to use CONSUMING as the 
InstancePartitionsType.
         return Collections.singletonMap(InstancePartitionsType.CONSUMING, 
InstancePartitionsUtils
             .fetchOrComputeInstancePartitions(_helixZkManager, tableConfig, 
InstancePartitionsType.CONSUMING));
       }
   ```



##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java:
##########
@@ -369,8 +369,10 @@ public void addSegment(ImmutableSegment immutableSegment) {
 
   private void handleUpsert(ImmutableSegmentImpl immutableSegment) {
     String segmentName = immutableSegment.getSegmentName();
-    int partitionGroupId = SegmentUtils
+    Integer partitionGroupId = SegmentUtils
         .getRealtimeSegmentPartitionId(segmentName, _tableNameWithType, 
_helixManager, _primaryKeyColumns.get(0));
+    Preconditions.checkNotNull(
+        String.format("PartitionGroupId is not available for segment '%s' 
(upsert-enabled table)", segmentName));

Review Comment:
   (minor) Also include the table name



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

Reply via email to