waitinfuture commented on code in PR #2300:
URL: https://github.com/apache/celeborn/pull/2300#discussion_r1607541288
##########
common/src/main/java/org/apache/celeborn/common/meta/ReduceFileMeta.java:
##########
@@ -54,13 +75,13 @@ public synchronized int getNumChunks() {
}
}
- public void setSorted() {
- synchronized (sorted) {
- sorted.set(true);
+ public void setModified() {
Review Comment:
Since it's only called after sorting, so IMO it's better to keep the
variable as `sorted`.
##########
common/src/main/java/org/apache/celeborn/common/meta/ReduceFileMeta.java:
##########
@@ -39,7 +50,17 @@ public synchronized List<Long> getChunkOffsets() {
}
public synchronized void addChunkOffset(long offset) {
- chunkOffsets.add(offset);
+ nextBoundary = offset + chunkSize;
+ // keep compatible with reduce partition data writer's force update chunk
offset logic
+ if (!chunkOffsets.contains(offset)) {
Review Comment:
Just check the last element instead of calling `contains`
##########
common/src/main/java/org/apache/celeborn/common/network/buffer/ChunkBuffers.java:
##########
@@ -44,19 +42,15 @@ public FileManagedBuffers(DiskFileInfo fileInfo,
TransportConf conf) {
} else {
offsets = new long[] {0};
}
- this.conf = conf;
}
- public int numChunks() {
- return numChunks;
- }
-
- public ManagedBuffer chunk(int chunkIndex, int offset, int len) {
- // offset of the beginning of the chunk in the file
+ public Tuple2<Long, Long> getChunkOffsetLength(int chunkIndex, int offset,
int len) {
final long chunkOffset = offsets[chunkIndex];
final long chunkLength = offsets[chunkIndex + 1] - chunkOffset;
assert offset < chunkLength;
long length = Math.min(chunkLength - offset, len);
- return new FileSegmentManagedBuffer(conf, file, chunkOffset + offset,
length);
+ return new Tuple2<>(chunkOffset, length);
Review Comment:
return `(chunkOffset + offset, length)` and avoid adding offset in caller
##########
common/src/main/java/org/apache/celeborn/common/protocol/StorageInfo.java:
##########
@@ -129,6 +129,15 @@ public String toString() {
+ '}';
}
+ public boolean memoryAvailable() {
+ return memoryAvailable(availableStorageTypes);
+ }
+
+ public static boolean memoryAvailable(int availableStorageTypes) {
Review Comment:
No need to define this method, just use the upper one.
##########
common/src/main/java/org/apache/celeborn/common/network/buffer/FileChunkBuffers.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.common.network.buffer;
+
+import java.io.File;
+
+import scala.Tuple2;
+
+import org.apache.celeborn.common.meta.DiskFileInfo;
+import org.apache.celeborn.common.meta.ReduceFileMeta;
+import org.apache.celeborn.common.network.util.TransportConf;
+
+public class FileChunkBuffers extends ChunkBuffers {
+ private final File file;
+ private final TransportConf conf;
+
+ public FileChunkBuffers(DiskFileInfo fileInfo, TransportConf conf) {
+ super((ReduceFileMeta) fileInfo.getFileMeta());
Review Comment:
Since `getReduceFileMeta` is defined inside `FileInfo`, we should avoid
writing `(ReduceFileMeta) fileInfo.getFileMeta()` anymore. Please check other
places.
##########
common/src/main/java/org/apache/celeborn/common/util/ShuffleBlockInfoUtils.java:
##########
@@ -90,4 +119,23 @@ public static Map<Integer, List<ShuffleBlockInfo>>
parseShuffleBlockInfosFromByt
}
return indexMap;
}
+
+ public static void sliceSortedBufferByMapRange(
+ int startMapIndex,
+ int endMapIndex,
+ Map<Integer, List<ShuffleBlockInfo>> indexMap,
+ CompositeByteBuf sortedByteBuf,
+ CompositeByteBuf targetByteBuf) {
+ for (int i = startMapIndex; i < endMapIndex; i++) {
+ List<ShuffleBlockInfo> blockInfos = indexMap.get(i);
+ if (blockInfos != null) {
+ for (ShuffleBlockInfo blockInfo : blockInfos) {
Review Comment:
Just calculate start and end, then slice once from sortedByteBuf. Check
contiguous during calculation.
--
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]