T
- The type of the elements that are being written by the sink.public class StringWriter<T> extends StreamWriterBase<T>
Writer
that uses toString()
on the input elements and writes them to
the output bucket file separated by newline.Modifier | Constructor and Description |
---|---|
|
StringWriter()
Creates a new
StringWriter that uses "UTF-8" charset to convert
strings to bytes. |
|
StringWriter(String charsetName)
Creates a new
StringWriter that uses the given charset to convert
strings to bytes. |
protected |
StringWriter(StringWriter<T> other) |
Modifier and Type | Method and Description |
---|---|
StringWriter<T> |
duplicate()
Duplicates the
Writer . |
void |
open(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
Initializes the
Writer for a newly opened bucket file. |
void |
write(T element)
Writes one element to the bucket file.
|
close, flush, getPos, getStream, isSyncOnFlush, setSyncOnFlush
public StringWriter()
StringWriter
that uses "UTF-8"
charset to convert
strings to bytes.public StringWriter(String charsetName)
StringWriter
that uses the given charset to convert
strings to bytes.charsetName
- Name of the charset to be used, must be valid input for Charset.forName(charsetName)
protected StringWriter(StringWriter<T> other)
public void open(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException
Writer
Writer
for a newly opened bucket file.
Any internal per-bucket initialization should be performed here.open
in interface Writer<T>
open
in class StreamWriterBase<T>
fs
- The FileSystem
containing the newly opened file.path
- The Path
of the newly opened file.IOException
public void write(T element) throws IOException
Writer
IOException
public StringWriter<T> duplicate()
Writer
Writer
. This is used to get one Writer
for each
parallel instance of the sink.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.