public abstract class IOManager extends Object implements AutoCloseable
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
LOG |
Modifier | Constructor and Description |
---|---|
protected |
IOManager(String[] tempDirs)
Constructs a new IOManager.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Removes all temporary files.
|
BlockChannelReader<MemorySegment> |
createBlockChannelReader(FileIOChannel.ID channelID)
Creates a block channel reader that reads blocks from the given channel.
|
abstract BlockChannelReader<MemorySegment> |
createBlockChannelReader(FileIOChannel.ID channelID,
LinkedBlockingQueue<MemorySegment> returnQueue)
Creates a block channel reader that reads blocks from the given channel.
|
BlockChannelWriter<MemorySegment> |
createBlockChannelWriter(FileIOChannel.ID channelID)
Creates a block channel writer that writes to the given channel.
|
abstract BlockChannelWriter<MemorySegment> |
createBlockChannelWriter(FileIOChannel.ID channelID,
LinkedBlockingQueue<MemorySegment> returnQueue)
Creates a block channel writer that writes to the given channel.
|
abstract BlockChannelWriterWithCallback<MemorySegment> |
createBlockChannelWriter(FileIOChannel.ID channelID,
RequestDoneCallback<MemorySegment> callback)
Creates a block channel writer that writes to the given channel.
|
abstract BufferFileReader |
createBufferFileReader(FileIOChannel.ID channelID,
RequestDoneCallback<Buffer> callback) |
abstract BufferFileSegmentReader |
createBufferFileSegmentReader(FileIOChannel.ID channelID,
RequestDoneCallback<FileSegment> callback) |
abstract BufferFileWriter |
createBufferFileWriter(FileIOChannel.ID channelID) |
abstract BulkBlockChannelReader |
createBulkBlockChannelReader(FileIOChannel.ID channelID,
List<MemorySegment> targetSegments,
int numBlocks)
Creates a block channel reader that reads all blocks from the given channel directly in one
bulk.
|
FileIOChannel.ID |
createChannel()
Creates a new
FileIOChannel.ID in one of the temp directories. |
FileIOChannel.Enumerator |
createChannelEnumerator()
Creates a new
FileIOChannel.Enumerator , spreading the channels in a round-robin fashion across the
temporary file directories. |
static void |
deleteChannel(FileIOChannel.ID channel)
Deletes the file underlying the given channel.
|
File[] |
getSpillingDirectories()
Gets the directories that the I/O manager spills to.
|
String[] |
getSpillingDirectoriesPaths()
Gets the directories that the I/O manager spills to, as path strings.
|
protected IOManager(String[] tempDirs)
tempDirs
- The basic directories for files underlying anonymous channels.public void close() throws Exception
close
in interface AutoCloseable
Exception
public FileIOChannel.ID createChannel()
FileIOChannel.ID
in one of the temp directories. Multiple invocations of this method
spread the channels evenly across the different directories.public FileIOChannel.Enumerator createChannelEnumerator()
FileIOChannel.Enumerator
, spreading the channels in a round-robin fashion across the
temporary file directories.public static void deleteChannel(FileIOChannel.ID channel)
channel
- The channel to be deleted.public File[] getSpillingDirectories()
public String[] getSpillingDirectoriesPaths()
public BlockChannelWriter<MemorySegment> createBlockChannelWriter(FileIOChannel.ID channelID) throws IOException
channelID
- The descriptor for the channel to write to.IOException
- Thrown, if the channel for the writer could not be opened.public abstract BlockChannelWriter<MemorySegment> createBlockChannelWriter(FileIOChannel.ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) throws IOException
channelID
- The descriptor for the channel to write to.returnQueue
- The queue to put the written buffers into.IOException
- Thrown, if the channel for the writer could not be opened.public abstract BlockChannelWriterWithCallback<MemorySegment> createBlockChannelWriter(FileIOChannel.ID channelID, RequestDoneCallback<MemorySegment> callback) throws IOException
channelID
- The descriptor for the channel to write to.callback
- The callback to be called forIOException
- Thrown, if the channel for the writer could not be opened.public BlockChannelReader<MemorySegment> createBlockChannelReader(FileIOChannel.ID channelID) throws IOException
channelID
- The descriptor for the channel to write to.IOException
- Thrown, if the channel for the reader could not be opened.public abstract BlockChannelReader<MemorySegment> createBlockChannelReader(FileIOChannel.ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) throws IOException
channelID
- The descriptor for the channel to write to.returnQueue
- The queue to put the full buffers into.IOException
- Thrown, if the channel for the reader could not be opened.public abstract BufferFileWriter createBufferFileWriter(FileIOChannel.ID channelID) throws IOException
IOException
public abstract BufferFileReader createBufferFileReader(FileIOChannel.ID channelID, RequestDoneCallback<Buffer> callback) throws IOException
IOException
public abstract BufferFileSegmentReader createBufferFileSegmentReader(FileIOChannel.ID channelID, RequestDoneCallback<FileSegment> callback) throws IOException
IOException
public abstract BulkBlockChannelReader createBulkBlockChannelReader(FileIOChannel.ID channelID, List<MemorySegment> targetSegments, int numBlocks) throws IOException
If a channel is not to be read in one bulk, but in multiple smaller batches, a BlockChannelReader
should be used.
channelID
- The descriptor for the channel to write to.targetSegments
- The list to take the segments from into which to read the data.numBlocks
- The number of blocks in the channel to read.IOException
- Thrown, if the channel for the reader could not be opened.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.