gaoyajun02 commented on code in PR #3261: URL: https://github.com/apache/celeborn/pull/3261#discussion_r2104331470
########## client/src/main/scala/org/apache/celeborn/client/commit/PartitionCompletenessValidator.scala: ########## @@ -0,0 +1,253 @@ +/* + * 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.client.commit + +import java.util +import java.util.{Comparator, Map} +import java.util.function.{BiFunction, Consumer} + +import com.google.common.base.Preconditions.{checkArgument, checkState} +import org.roaringbitmap.RoaringBitmap + +import org.apache.celeborn.common.CommitMetadata +import org.apache.celeborn.common.internal.Logging +import org.apache.celeborn.common.util.JavaUtils + +class PartitionCompletenessValidator extends Logging { + + private val actualCommitMetadataForReducer = { + JavaUtils.newConcurrentHashMap[Int, java.util.TreeMap[(Int, Int), CommitMetadata]]() + } + private val totalSubPartitionsProcessed = JavaUtils.newConcurrentHashMap[Int, RoaringBitmap]() + private val currentCommitMetadataForReducer = + JavaUtils.newConcurrentHashMap[Int, CommitMetadata]() + private val currentTotalMapRangeSumForReducer = JavaUtils.newConcurrentHashMap[Int, Int]() + private val comparator: java.util.Comparator[(Int, Int)] = new Comparator[(Int, Int)] { + override def compare(o1: (Int, Int), o2: (Int, Int)): Int = { + val comparator = Integer.compare(o1._1, o2._1) + if (comparator != 0) + comparator + else + Integer.compare(o1._2, o2._2) + } + } + + def validateSubPartition( + partitionId: Int, + startMapIndex: Int, + endMapIndex: Int, + actualCommitMetadata: CommitMetadata, + expectedCommitMetadata: CommitMetadata, + expectedTotalMapperCountForParent: Int, + skewPartitionHandlingWithoutMapRange: Boolean): (Boolean, String) = { + if (skewPartitionHandlingWithoutMapRange) { + totalSubPartitionsProcessed.synchronized { + var bitmap: RoaringBitmap = null + if (totalSubPartitionsProcessed.containsKey(partitionId)) { + bitmap = totalSubPartitionsProcessed.get(partitionId) + } else { + bitmap = new RoaringBitmap(); + totalSubPartitionsProcessed.put(partitionId, bitmap) + } + bitmap.add(endMapIndex) Review Comment: I'm trying to understand - we need to maintain each sub-partition and its checksum to support: 1) Retry scenarios: When processing the same sub-partition again, verify if the checksums match 2) Verify if all sub-partitions have been processed, then perform final partition-level consistency validation This flow should be the same for both chunk range and map range, with the only difference being in how key completeness is validated. If this understanding is correct, I have two questions: 1) The chunk range implementation is missing checksum validation for retry scenarios 2) Should we unify these branches and make their data structures reusable between both cases? ########## client/src/main/scala/org/apache/celeborn/client/LifecycleManager.scala: ########## @@ -487,6 +521,31 @@ class LifecycleManager(val appUniqueId: String, val conf: CelebornConf) extends } } + private def handleReducerPartitionEnd( + context: RpcCallContext, + shuffleId: Int, + partitionId: Int, + startMapIndex: Int, + endMapIndex: Int, + crc32: Int, + bytesWritten: Long): Unit = { + val (isValid, errorMessage) = commitManager.finishPartition( + shuffleId, + partitionId, + startMapIndex, + endMapIndex, + new CommitMetadata(crc32, bytesWritten)) + var response: PbReducerPartitionEndResponse = null + if (isValid) { + response = + PbReducerPartitionEndResponse.newBuilder().setStatus(StatusCode.SUCCESS.getValue).build(); + } else { Review Comment: Unnecessary semicolons can be removed from Scala code -- 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]
