T - the type of values written to the sink.public abstract class FileBasedSink<T> extends Sink<T>
Sink for file-based output. An implementation of FileBasedSink writes file-based
output and defines the format of output files (how values are written, headers/footers, MIME
type, etc.).
At pipeline construction time, the methods of FileBasedSink are called to validate the sink
and to create a Sink.WriteOperation that manages the process of writing to the sink.
The process of writing to file-based sink is as follows:
Supported file systems are those registered with IOChannelUtils.
| Modifier and Type | Class and Description |
|---|---|
static class |
FileBasedSink.FileBasedWriteOperation<T>
Abstract
Sink.WriteOperation that manages the process of writing to a
FileBasedSink. |
static class |
FileBasedSink.FileBasedWriter<T>
Abstract
Sink.Writer that writes a bundle to a FileBasedSink. |
Sink.WriteOperation<T,WR>, Sink.Writer<T,WR>| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
baseOutputFilename
Base filename for final output files.
|
protected java.lang.String |
extension
The extension to be used for the final output files.
|
protected java.lang.String |
fileNamingTemplate
Naming template for output files.
|
| Constructor and Description |
|---|
FileBasedSink(java.lang.String baseOutputFilename,
java.lang.String extension)
Construct a FileBasedSink with the given base output filename and extension.
|
FileBasedSink(java.lang.String baseOutputFilename,
java.lang.String extension,
java.lang.String fileNamingTemplate)
Construct a FileBasedSink with the given base output filename, extension, and file naming
template.
|
| Modifier and Type | Method and Description |
|---|---|
abstract FileBasedSink.FileBasedWriteOperation<T> |
createWriteOperation(PipelineOptions options)
Return a subclass of
FileBasedSink.FileBasedWriteOperation that will manage the write
to the sink. |
void |
validate(PipelineOptions options)
Perform pipeline-construction-time validation.
|
protected final java.lang.String baseOutputFilename
protected final java.lang.String extension
protected final java.lang.String fileNamingTemplate
ShardNameTemplate for a description of
possible naming templates. Default is ShardNameTemplate.INDEX_OF_MAX.public FileBasedSink(java.lang.String baseOutputFilename,
java.lang.String extension)
public FileBasedSink(java.lang.String baseOutputFilename,
java.lang.String extension,
java.lang.String fileNamingTemplate)
See ShardNameTemplate for a description of file naming templates.
public void validate(PipelineOptions options)
Preconditions in the implementation of this method.public abstract FileBasedSink.FileBasedWriteOperation<T> createWriteOperation(PipelineOptions options)
FileBasedSink.FileBasedWriteOperation that will manage the write
to the sink.createWriteOperation in class Sink<T>