Skip to content

Commit

Permalink
[SPARK-25299] Introduce the new shuffle writer API (#5) (#520)
Browse files Browse the repository at this point in the history
Introduces the new Shuffle Writer API. Ported from bloomberg#5.
  • Loading branch information
mccheah authored and bulldozer-bot[bot] committed Mar 20, 2019
1 parent ddc9905 commit 6a8fe15
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 0 deletions.
31 changes: 31 additions & 0 deletions core/src/main/java/org/apache/spark/api/shuffle/ShuffleDataIO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.api.shuffle;

import org.apache.spark.annotation.Experimental;

/**
* :: Experimental ::
* An interface for launching Shuffle related components
*
* @since 3.0.0
*/
@Experimental
public interface ShuffleDataIO {
ShuffleExecutorComponents executor();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.api.shuffle;

import org.apache.spark.annotation.Experimental;

/**
* :: Experimental ::
* An interface for building shuffle support for Executors
*
* @since 3.0.0
*/
@Experimental
public interface ShuffleExecutorComponents {
void intitializeExecutor(String appId, String execId);

ShuffleWriteSupport writes();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.api.shuffle;

import java.io.IOException;

import org.apache.spark.annotation.Experimental;

/**
* :: Experimental ::
* An interface for creating and managing shuffle partition writers
*
* @since 3.0.0
*/
@Experimental
public interface ShuffleMapOutputWriter {
ShufflePartitionWriter getNextPartitionWriter() throws IOException;

void commitAllPartitions() throws IOException;

void abort(Throwable error) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.api.shuffle;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.channels.Channels;
import java.nio.channels.WritableByteChannel;

import org.apache.http.annotation.Experimental;

/**
* :: Experimental ::
* An interface for giving streams / channels for shuffle writes
*
* @since 3.0.0
*/
@Experimental
public interface ShufflePartitionWriter {
OutputStream openStream() throws IOException;

long getLength();

default WritableByteChannel openChannel() throws IOException {
return Channels.newChannel(openStream());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.api.shuffle;

import java.io.IOException;

import org.apache.http.annotation.Experimental;

/**
* :: Experimental ::
* An interface for deploying a shuffle map output writer
*
* @since 3.0.0
*/
@Experimental
public interface ShuffleWriteSupport {
ShuffleMapOutputWriter createMapOutputWriter(
String appId,
int shuffleId,
int mapId,
int numPartitions) throws IOException;
}

0 comments on commit 6a8fe15

Please sign in to comment.