codenohup commented on code in PR #2820:
URL: https://github.com/apache/celeborn/pull/2820#discussion_r1816142267


##########
worker/src/main/java/org/apache/celeborn/service/deploy/worker/storage/segment/SegmentMapPartitionDataReader.java:
##########
@@ -0,0 +1,330 @@
+/*
+ * 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.celeborn.service.deploy.worker.storage.segment;
+
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+
+import javax.annotation.concurrent.GuardedBy;
+
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.celeborn.common.meta.DiskFileInfo;
+import org.apache.celeborn.common.network.protocol.ReadData;
+import org.apache.celeborn.common.network.protocol.RequestMessage;
+import org.apache.celeborn.common.network.protocol.SubPartitionReadData;
+import org.apache.celeborn.service.deploy.worker.memory.BufferRecycler;
+import org.apache.celeborn.service.deploy.worker.memory.RecyclableBuffer;
+import 
org.apache.celeborn.service.deploy.worker.memory.RecyclableSegmentIdBuffer;
+import 
org.apache.celeborn.service.deploy.worker.storage.MapPartitionDataReader;
+
+public class SegmentMapPartitionDataReader extends MapPartitionDataReader {
+
+  public static final Logger logger = 
LoggerFactory.getLogger(SegmentMapPartitionDataReader.class);
+
+  // The Flink EndOfSegment buffer data type, which has been written
+  // to the buffer header, is in the 16th bit(starting from 0).
+  private static final int END_OF_SEGMENT_BUFFER_DATA_TYPE = 7;
+
+  private final int startPartitionIndex;
+
+  private final int endPartitionIndex;
+
+  private final boolean requireSubpartitionId;
+
+  @GuardedBy("lock")
+  private final Deque<Integer> backlogs = new LinkedList<>();
+
+  @GuardedBy("lock")
+  // subpartitionId -> segmentId, current required segmentId by client per 
subpartition
+  private Map<Integer, Integer> subPartitionRequiredSegmentIds = new 
HashMap<>();
+
+  @GuardedBy("lock")
+  private boolean hasUpdateSegmentId = false;
+
+  @GuardedBy("lock")
+  // subpartitionId -> segmentId, segmentId of current reading buffer per 
subpartition
+  private Map<Integer, Integer> subPartitionLastSegmentIds = new HashMap<>();
+
+  @GuardedBy("lock")
+  // subpartitionId -> buffer index, current reading buffer index per 
subpartition
+  private Map<Integer, Integer> subPartitionNextBufferIndex = new HashMap<>();
+
+  public SegmentMapPartitionDataReader(
+      int startPartitionIndex,
+      int endPartitionIndex,
+      DiskFileInfo fileInfo,
+      long streamId,
+      Channel associatedChannel,
+      Runnable recycleStream,
+      boolean requireSubpartitionId) {

Review Comment:
   > is requireSubpartitionId always true for SegmentMapPartitionDataReader?
   
   Yes, you are correct, the `requireSubpartitionId` may be unnecessary in 
`OpenStream` message and SegmentMapPartitionDataReader, as the Worker can 
distinguish shuffle type and determine whether it is segment granularity 
visible.
   
   Thanks for your feedback, I will remove the requireSubpartitionId in 
`OpenStream` and `SegmentMapPartitionDataReader `.



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

Reply via email to