@NotThreadSafe public class PartitionedFileWriter extends Object implements AutoCloseable
PartitionedFile
. Data is written region
by region. Before writing a new region, the method startNewRegion()
must be called. After writing all data, the method finish()
must be
called to close all opened files and return the target PartitionedFile
.Constructor and Description |
---|
PartitionedFileWriter(int numSubpartitions,
int maxIndexBufferSize,
String basePath) |
Modifier and Type | Method and Description |
---|---|
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()
Persists the region index of the current data region and starts a new region to write.
|
void |
writeBuffer(Buffer target,
int targetSubpartition)
Writes a
Buffer of the given subpartition to the this PartitionedFile . |
public PartitionedFileWriter(int numSubpartitions, int maxIndexBufferSize, String basePath) throws IOException
IOException
public void startNewRegion() throws IOException
Note: The caller is responsible for releasing the failed PartitionedFile
if any
exception occurs.
IOException
public void writeBuffer(Buffer target, int targetSubpartition) throws IOException
Buffer
of the given subpartition to the this PartitionedFile
. In a
data region, all data of the same subpartition must be written together.
Note: The caller is responsible for recycling the target buffer and releasing the failed
PartitionedFile
if any exception occurs.
IOException
public 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.
IOException
public void releaseQuietly()
PartitionedFile
when any exception occurs.public void close() throws IOException
close
in interface AutoCloseable
IOException
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.