public abstract static class TextIO.Write extends PTransform<PCollection<java.lang.String>,PDone>
TextIO.write()
.name
Constructor and Description |
---|
Write() |
Modifier and Type | Method and Description |
---|---|
PDone |
expand(PCollection<java.lang.String> input)
Override this method to specify how this
PTransform should be expanded
on the given InputT . |
protected Coder<java.lang.Void> |
getDefaultOutputCoder()
Returns the default
Coder to use for the output of this
single-output PTransform . |
void |
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.
|
TextIO.Write |
to(ResourceId filenamePrefix)
Writes to text files with prefix from the given resource.
|
TextIO.Write |
to(java.lang.String filenamePrefix)
Writes to text files with the given prefix.
|
TextIO.Write |
to(ValueProvider<java.lang.String> outputPrefix)
Like
to(String) . |
TextIO.Write |
toResource(ValueProvider<ResourceId> filenamePrefix)
Like
to(ResourceId) . |
TextIO.Write |
withFilenamePolicy(FileBasedSink.FilenamePolicy filenamePolicy)
Configures the
FileBasedSink.FilenamePolicy that will be used to name written files. |
TextIO.Write |
withFooter(java.lang.String footer)
Adds a footer string to each file.
|
TextIO.Write |
withHeader(java.lang.String header)
Adds a header string to each file.
|
TextIO.Write |
withNumShards(int numShards)
Configures the number of output shards produced overall (when using unwindowed writes) or
per-window (when using windowed writes).
|
TextIO.Write |
withoutSharding()
Forces a single file as output and empty shard name template.
|
TextIO.Write |
withShardNameTemplate(java.lang.String shardTemplate)
Uses the given
ShardNameTemplate for naming output files. |
TextIO.Write |
withSuffix(java.lang.String filenameSuffix)
Configures the filename suffix for written files.
|
TextIO.Write |
withWindowedWrites() |
TextIO.Write |
withWritableByteChannelFactory(FileBasedSink.WritableByteChannelFactory writableByteChannelFactory)
Returns a transform for writing to text files like this one but that has the given
FileBasedSink.WritableByteChannelFactory to be used by the FileBasedSink during output. |
getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, toString, validate
public TextIO.Write to(java.lang.String filenamePrefix)
prefix
can reference any
FileSystem
on the classpath.
The name of the output files will be determined by the FileBasedSink.FilenamePolicy
used.
By default, a DefaultFilenamePolicy
will be used built using the specified prefix
to define the base output directory and file prefix, a shard identifier (see
withNumShards(int)
), and a common suffix (if supplied using
withSuffix(String)
).
This default policy can be overridden using #withFilenamePolicy(FilenamePolicy)
,
in which case withShardNameTemplate(String)
and withSuffix(String)
should
not be set.
@Experimental(value=FILESYSTEM) public TextIO.Write to(ResourceId filenamePrefix)
The name of the output files will be determined by the FileBasedSink.FilenamePolicy
used.
By default, a DefaultFilenamePolicy
will be used built using the specified prefix
to define the base output directory and file prefix, a shard identifier (see
withNumShards(int)
), and a common suffix (if supplied using
withSuffix(String)
).
This default policy can be overridden using #withFilenamePolicy(FilenamePolicy)
,
in which case withShardNameTemplate(String)
and withSuffix(String)
should
not be set.
public TextIO.Write to(ValueProvider<java.lang.String> outputPrefix)
to(String)
.@Experimental(value=FILESYSTEM) public TextIO.Write toResource(ValueProvider<ResourceId> filenamePrefix)
to(ResourceId)
.public TextIO.Write withShardNameTemplate(java.lang.String shardTemplate)
ShardNameTemplate
for naming output files. This option may only be
used when #withFilenamePolicy(FilenamePolicy)
has not been configured.
See DefaultFilenamePolicy
for how the prefix, shard name template, and suffix are
used.
public TextIO.Write withSuffix(java.lang.String filenameSuffix)
#withFilenamePolicy(FilenamePolicy)
has not been configured.
See DefaultFilenamePolicy
for how the prefix, shard name template, and suffix are
used.
public TextIO.Write withFilenamePolicy(FileBasedSink.FilenamePolicy filenamePolicy)
FileBasedSink.FilenamePolicy
that will be used to name written files.public TextIO.Write withNumShards(int numShards)
For unwindowed writes, constraining the number of shards is likely to reduce the performance of a pipeline. Setting this value is not recommended unless you require a specific number of output files.
numShards
- the number of shards to use, or 0 to let the system decide.public TextIO.Write withoutSharding()
For unwindowed writes, constraining the number of shards is likely to reduce the performance of a pipeline. Setting this value is not recommended unless you require a specific number of output files.
This is equivalent to .withNumShards(1).withShardNameTemplate("")
public TextIO.Write withHeader(@Nullable java.lang.String header)
A null
value will clear any previously configured header.
public TextIO.Write withFooter(@Nullable java.lang.String footer)
A null
value will clear any previously configured footer.
public TextIO.Write withWritableByteChannelFactory(FileBasedSink.WritableByteChannelFactory writableByteChannelFactory)
FileBasedSink.WritableByteChannelFactory
to be used by the FileBasedSink
during output.
The default is value is FileBasedSink.CompressionType.UNCOMPRESSED
.
A null
value will reset the value to the default value mentioned above.
public TextIO.Write withWindowedWrites()
public PDone expand(PCollection<java.lang.String> input)
PTransform
PTransform
should be expanded
on the given InputT
.
NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to the InputT
using the apply
method.
Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
expand
in class PTransform<PCollection<java.lang.String>,PDone>
public void populateDisplayData(DisplayData.Builder builder)
PTransform
populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect
display data via DisplayData.from(HasDisplayData)
. Implementations may call
super.populateDisplayData(builder)
in order to register display data in the current
namespace, but should otherwise use subcomponent.populateDisplayData(builder)
to use
the namespace of the subcomponent.
By default, does not register any display data. Implementors may override this method to provide their own display data.
populateDisplayData
in interface HasDisplayData
populateDisplayData
in class PTransform<PCollection<java.lang.String>,PDone>
builder
- The builder to populate with display data.HasDisplayData
protected Coder<java.lang.Void> getDefaultOutputCoder()
PTransform
Coder
to use for the output of this
single-output PTransform
.
By default, always throws
getDefaultOutputCoder
in class PTransform<PCollection<java.lang.String>,PDone>