jerryshao commented on a change in pull request #25007: [SPARK-28209][CORE][SHUFFLE] Proposed new shuffle writer API URL: https://github.com/apache/spark/pull/25007#discussion_r304243823
########## File path: core/src/main/java/org/apache/spark/shuffle/api/ShuffleMapOutputWriter.java ########## @@ -0,0 +1,65 @@ +/* + * 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.shuffle.api; + +import java.io.IOException; + +import org.apache.spark.annotation.Private; + +/** + * :: Experimental :: + * A top-level writer that returns child writers for persisting the output of a map task, + * and then commits all of the writes as one atomic operation. + * + * @since 3.0.0 + */ +@Private +public interface ShuffleMapOutputWriter { + + /** + * Creates a writer that can open an output stream to persist bytes for a given chunk of + * a map task. + * <p> + * The chunk corresponds to bytes in a partition that all share the same reduce id, hence + * the given argument. This will not be called twice for the same partition identifier. + * The partition identifier will be in the range of precisely 0 (inclusive) to numPartitions + * (exclusive), where numPartitions was provided upon the creation of this map output writer via + * {@link ShuffleWriteSupport#createMapOutputWriter(int, int, long, int)}. + */ + ShufflePartitionWriter getPartitionWriter(int partitionId) throws IOException; + + /** + * Commits the writes done by all partition writers returned by all calls to this object's + * {@link #getPartitionWriter(int)}. + * <p> + * This should ensure that the writes conducted by this module's partition writers are + * available to downstream reduce tasks. If this method throws any exception, this module's + * {@link #abort(Throwable)} method will be invoked before propagating the exception. + * <p> + * This can also close any resources and clean up temporary state if necessary. + */ + void commitAllPartitions() throws IOException; Review comment: @gczsjdy any reason to return `Optional<MapShuffleLocations>`? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
