T - The type of object to writeWR - The writer results type (e.g., the bundle's output filename, as String)public abstract static class Sink.Writer<T,WR>
extends java.lang.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 |
|---|
Sink.Writer() |
| Modifier and Type | Method and Description |
|---|---|
abstract WR |
close()
Finishes writing the bundle.
|
abstract Sink.WriteOperation<T,WR> |
getWriteOperation()
Returns the write operation this writer belongs to.
|
abstract void |
open(java.lang.String uId)
Performs bundle initialization.
|
abstract void |
write(T value)
Called for each value in the bundle.
|
public abstract void open(java.lang.String uId)
throws java.lang.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.
java.lang.Exceptionpublic abstract void write(T value) throws java.lang.Exception
java.lang.Exceptionpublic abstract WR close() throws java.lang.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<WR>, com.google.cloud.dataflow.sdk.options.PipelineOptions) will use the writer result to identify
successful writes. See Sink for more information about bundle ids.
java.lang.Exceptionpublic abstract Sink.WriteOperation<T,WR> getWriteOperation()