You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "mridulm (via GitHub)" <gi...@apache.org> on 2025/08/24 19:49:52 UTC
Re: [PR] [SPARK-53351][CORE] Use consistent string type blockId for block data access in external block handler [spark]
mridulm commented on code in PR #52095:
URL: https://github.com/apache/spark/pull/52095#discussion_r2296783497
##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/BlockStoreClient.java:
##########
@@ -69,15 +69,13 @@ public Cause diagnoseCorruption(
String host,
int port,
String execId,
- int shuffleId,
- long mapId,
- int reduceId,
+ String blockId,
long checksum,
String algorithm) {
try {
TransportClient client = clientFactory.createClient(host, port);
ByteBuffer response = client.sendRpcSync(
- new DiagnoseCorruption(appId, execId, shuffleId, mapId, reduceId, checksum, algorithm)
+ new DiagnoseCorruption(appId, execId, blockId, checksum, algorithm)
Review Comment:
Why are we going from explicit types to an opaque string ?
This will make it more unmaintainable as code evolves.
##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/BlockIdUtils.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.spark.network.shuffle;
+
+import org.apache.spark.network.shuffle.checksum.ShuffleChecksumHelper;
+
+public class BlockIdUtils {
+ public static final String SHUFFLE_BLOCK_PREFIX = "shuffle_";
+ public static final String SHUFFLE_CHUNK_PREFIX = "shuffleChunk_";
+ public static final String RDD_BLOCK_PREFIX = "rdd_";
+ private static final String NOOP_REDUCE_ID = "0";
+
+ public static Boolean isRddBlock(String blockId) {
+ if (blockId.startsWith(RDD_BLOCK_PREFIX)) return true;
+ return false;
+ }
+
+ public static Boolean isShuffleBlock(String blockId) {
+ if (blockId.startsWith(SHUFFLE_BLOCK_PREFIX)) return true;
+ return false;
+ }
+
+ public static Boolean isShuffleChunk(String blockId) {
+ // Shuffle chunk block is not supported by Aether, and we don't need to check for wrapped
+ // Aether blocks.
Review Comment:
What is `Aether` ?
##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalBlockHandler.java:
##########
@@ -383,26 +384,29 @@ private class ManagedBufferIterator implements Iterator<ManagedBuffer> {
String appId = msg.appId;
String execId = msg.execId;
String[] blockIds = msg.blockIds;
+ size = blockIds.length;
String[] blockId0Parts = blockIds[0].split("_");
- if (blockId0Parts.length == 4 && blockId0Parts[0].equals(SHUFFLE_BLOCK_ID)) {
- final int shuffleId = Integer.parseInt(blockId0Parts[1]);
- final int[] mapIdAndReduceIds = shuffleMapIdAndReduceIds(blockIds, shuffleId);
- size = mapIdAndReduceIds.length;
- blockDataForIndexFn = index -> blockManager.getBlockData(appId, execId, shuffleId,
- mapIdAndReduceIds[index], mapIdAndReduceIds[index + 1]);
- } else if (blockId0Parts.length == 5 && blockId0Parts[0].equals(SHUFFLE_CHUNK_ID)) {
+ if (isShuffleBlock(blockIds[0])) {
+ blockDataForIndexFn = index -> {
+ if (!isShuffleBlock(blockIds[index])) {
+ throw new IllegalArgumentException("Unexpected block id format: " + blockIds[index]);
+ }
+ return blockManager.getBlockData(appId, execId, blockIds[index]);
+ };
+ } else if (blockId0Parts.length == 5 && isShuffleChunk(blockIds[0])) {
final int shuffleId = Integer.parseInt(blockId0Parts[1]);
final int shuffleMergeId = Integer.parseInt(blockId0Parts[2]);
final int[] reduceIdAndChunkIds = shuffleReduceIdAndChunkIds(blockIds, shuffleId,
shuffleMergeId);
- size = reduceIdAndChunkIds.length;
blockDataForIndexFn = index -> mergeManager.getMergedBlockData(msg.appId, shuffleId,
- shuffleMergeId, reduceIdAndChunkIds[index], reduceIdAndChunkIds[index + 1]);
- } else if (blockId0Parts.length == 3 && blockId0Parts[0].equals("rdd")) {
- final int[] rddAndSplitIds = rddAndSplitIds(blockIds);
- size = rddAndSplitIds.length;
- blockDataForIndexFn = index -> blockManager.getRddBlockData(appId, execId,
- rddAndSplitIds[index], rddAndSplitIds[index + 1]);
+ shuffleMergeId, reduceIdAndChunkIds[2 * index], reduceIdAndChunkIds[2 * index + 1]);
Review Comment:
Based on a quick look, this should be `reduceIdAndChunkIds[index], reduceIdAndChunkIds[index + 1]` instead ?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org