@NotThreadSafe public class PartitionedFileWriter extends Object implements AutoCloseable
PartitionedFile. Data is written region
by region. Before writing a new region, the method startNewRegion(boolean)
must be called. After writing all data, the method finish() must be
called to close all opened files and return the target PartitionedFile.| 构造器和说明 |
|---|
PartitionedFileWriter(int numSubpartitions,
int maxIndexBufferSize,
String basePath) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
PartitionedFile |
finish()
Finishes writing the
PartitionedFile which closes the file channel and returns the
corresponding PartitionedFile. |
void |
releaseQuietly()
Used to close and delete the failed
PartitionedFile when any exception occurs. |
void |
startNewRegion(boolean isBroadcastRegion)
Persists the region index of the current data region and starts a new region to write.
|
void |
writeBuffers(List<BufferWithChannel> bufferWithChannels)
Writes a list of
Buffers to this PartitionedFile. |
public PartitionedFileWriter(int numSubpartitions,
int maxIndexBufferSize,
String basePath)
throws IOException
IOExceptionpublic void startNewRegion(boolean isBroadcastRegion)
throws IOException
Note: The caller is responsible for releasing the failed PartitionedFile if any
exception occurs.
isBroadcastRegion - Whether it's a broadcast region. See isBroadcastRegion.IOExceptionpublic void writeBuffers(List<BufferWithChannel> bufferWithChannels) throws IOException
Buffers to this PartitionedFile. It guarantees that after
the return of this method, the target buffers can be released. In a data region, all data of
the same subpartition must be written together.
Note: The caller is responsible for recycling the target buffers and releasing the failed
PartitionedFile if any exception occurs.
IOExceptionpublic PartitionedFile finish() throws IOException
PartitionedFile which closes the file channel and returns the
corresponding PartitionedFile.
Note: The caller is responsible for releasing the failed PartitionedFile if any
exception occurs.
IOExceptionpublic void releaseQuietly()
PartitionedFile when any exception occurs.public void close()
throws IOException
close 在接口中 AutoCloseableIOExceptionCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.