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


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java:
##########
@@ -400,7 +398,8 @@ public void setUpNewTable(TableConfig tableConfig, 
IdealState idealState,
     List<StreamConfig> streamConfigs = 
IngestionConfigUtils.getStreamConfigs(tableConfig);

Review Comment:
   Since we already have it in `StreamMetadata`, we don't need to compute it 
again. It is quite expensive to construct stream config



##########
pinot-spi/src/main/java/org/apache/pinot/spi/stream/StreamMetadata.java:
##########
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.spi.stream;
+
+import java.util.List;
+
+
+/**
+ * Groups partition metadata for a single stream/topic.
+ *
+ * <p>This replaces the flat {@code List<PartitionGroupMetadata>} pattern 
where partitions from all streams were mixed
+ * together and required partition ID padding to identify stream membership.
+ *
+ * <p>The {@link PartitionGroupMetadata} items within this container use 
Pinot-encoded partition IDs
+ * (i.e., {@code streamIndex * 10000 + streamPartitionId}) to maintain 
backward compatibility with segment names
+ * stored in ZooKeeper.
+ */
+public class StreamMetadata {

Review Comment:
   This is more like a context wrapper class. Should we call it `StreamContext`?



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java:
##########
@@ -1704,12 +1723,12 @@ private boolean isAllInstancesInState(Map<String, 
String> instanceStateMap, Stri
    */
   @VisibleForTesting
   IdealState ensureAllPartitionsConsuming(TableConfig tableConfig, 
List<StreamConfig> streamConfigs,
-      IdealState idealState, List<PartitionGroupMetadata> 
partitionGroupMetadataList, OffsetCriteria offsetCriteria) {
+      IdealState idealState, List<StreamMetadata> streamMetadataList, 
OffsetCriteria offsetCriteria) {
     String realtimeTableName = tableConfig.getTableName();
 
     InstancePartitions instancePartitions = 
getConsumingInstancePartitions(tableConfig);
     int numReplicas = getNumReplicas(tableConfig, instancePartitions);
-    int numPartitions = partitionGroupMetadataList.size();
+    int numPartitions = 
streamMetadataList.stream().mapToInt(StreamMetadata::getNumPartitions).sum();

Review Comment:
   Suggest using old-fashioned loop, which is easier to read and lower overhead



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