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.| 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. |
| Modifier and Type | Method and Description |
|---|---|
Writer<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, hflushOrSyncpublic 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)public void open(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
throws IOException
WriterWriter 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.IOExceptionpublic void write(T element) throws IOException
WriterIOExceptionCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.