Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.spark.io;

import org.apache.spark.storage.StorageUtils;
import org.apache.spark.unsafe.Platform;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -47,7 +48,7 @@ public final class NioBufferedFileInputStream extends InputStream {
private final FileChannel fileChannel;

public NioBufferedFileInputStream(File file, int bufferSizeInBytes) throws IOException {
byteBuffer = ByteBuffer.allocateDirect(bufferSizeInBytes);
byteBuffer = Platform.allocateDirectBuffer(bufferSizeInBytes);
fileChannel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
byteBuffer.flip();
this.cleanable = CLEANER.register(this, new ResourceCleaner(fileChannel, byteBuffer));
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/org/apache/spark/storage/DiskStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.apache.spark.internal.LogKeys._
import org.apache.spark.network.buffer.ManagedBuffer
import org.apache.spark.network.util.{AbstractFileRegion, JavaUtils}
import org.apache.spark.security.CryptoStreamUtils
import org.apache.spark.unsafe.Platform
import org.apache.spark.unsafe.array.ByteArrayMethods
import org.apache.spark.util.Utils
import org.apache.spark.util.io.ChunkedByteBuffer
Expand Down Expand Up @@ -324,7 +325,7 @@ private class ReadableChannelFileRegion(source: ReadableByteChannel, blockSize:

private var _transferred = 0L

private val buffer = ByteBuffer.allocateDirect(64 * 1024)
private val buffer = Platform.allocateDirectBuffer(64 * 1024)
buffer.flip()

override def count(): Long = blockSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private[spark] class DirectByteBufferOutputStream(capacity: Int) extends OutputS
if (newCapacity < minCapacity) newCapacity = minCapacity
val oldBuffer = buffer
oldBuffer.flip()
val newBuffer = ByteBuffer.allocateDirect(newCapacity)
val newBuffer = Platform.allocateDirectBuffer(newCapacity)
newBuffer.put(oldBuffer)
StorageUtils.dispose(oldBuffer)
buffer = newBuffer
Expand Down