T - The type of object to writeWriteT - The writer results type (e.g., the bundle's output filename, as String)public abstract static class Sink.Writer<T,WriteT> extends Object
open(java.lang.String) is
called before writing begins and close() is called after all elements in the
bundle have been written. write(T) writes an element to the sink.
Note that any access to static members or methods of a Writer must be thread-safe, as multiple instances of a Writer may be instantiated in different threads on the same worker.
See Sink for more detailed documentation about the process of writing to a Sink.
| Constructor and Description |
|---|
Writer() |
| Modifier and Type | Method and Description |
|---|---|
abstract WriteT |
close()
Finishes writing the bundle.
|
abstract Sink.WriteOperation<T,WriteT> |
getWriteOperation()
Returns the write operation this writer belongs to.
|
abstract void |
open(String uId)
Performs bundle initialization.
|
abstract void |
write(T value)
Called for each value in the bundle.
|
public abstract void open(String uId) throws Exception
write(T).
The unique id that is given to open should be used to ensure that the writer's output does
not interfere with the output of other Writers, as a bundle may be executed many times for
fault tolerance. See Sink for more information about bundle ids.
Exceptionpublic abstract void write(T value) throws Exception
Exceptionpublic abstract WriteT close() throws Exception
Returns a writer result that will be used in the Sink.WriteOperation's
finalization. The result should contain some way to identify the output of this bundle (using
the bundle id). Sink.WriteOperation.finalize(java.lang.Iterable<WriteT>, org.apache.beam.sdk.options.PipelineOptions) will use the writer result to identify
successful writes. See Sink for more information about bundle ids.
Exceptionpublic abstract Sink.WriteOperation<T,WriteT> getWriteOperation()