Skip to content

Commit

Permalink
Use own ByteBufferOutputStream rather than Kryo's
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshRosen committed May 10, 2015
1 parent 67d25ba commit fd4bb9e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.unsafe;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;

class ByteBufferOutputStream extends OutputStream {

private final ByteBuffer byteBuffer;

public ByteBufferOutputStream(ByteBuffer byteBuffer) {
this.byteBuffer = byteBuffer;
}

@Override
public void write(int b) throws IOException {
byteBuffer.put((byte) b);
}

@Override
public void write(byte[] b) throws IOException {
byteBuffer.put(b);
}

@Override
public void write(byte[] b, int off, int len) throws IOException {
byteBuffer.put(b, off, len);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* spill files. Instead, this merging is performed in {@link UnsafeShuffleWriter}, which uses a
* specialized merge procedure that avoids extra serialization/deserialization.
*/
public final class UnsafeShuffleExternalSorter {
final class UnsafeShuffleExternalSorter {

private final Logger logger = LoggerFactory.getLogger(UnsafeShuffleExternalSorter.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.apache.spark.util.collection.Sorter;

public final class UnsafeShuffleSorter {
final class UnsafeShuffleSorter {

private final Sorter<PackedRecordPointer, long[]> sorter;
private static final class SortComparator implements Comparator<PackedRecordPointer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import scala.reflect.ClassTag;
import scala.reflect.ClassTag$;

import com.esotericsoftware.kryo.io.ByteBufferOutputStream;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.io.ByteStreams;
import com.google.common.io.Closeables;
Expand Down Expand Up @@ -75,7 +74,6 @@ public class UnsafeShuffleWriter<K, V> extends ShuffleWriter<K, V> {
private UnsafeShuffleExternalSorter sorter = null;
private byte[] serArray = null;
private ByteBuffer serByteBuffer;
// TODO: we should not depend on this class from Kryo; copy its source or find an alternative
private SerializationStream serOutputStream;

/**
Expand Down

0 comments on commit fd4bb9e

Please sign in to comment.