T
- The type of the elements that are being written by the sink.public class StringWriter<T> extends Object implements Writer<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 |
---|---|
void |
close()
Closes the
Writer . |
Writer<T> |
duplicate()
Duplicates the
Writer . |
void |
flush()
Flushes out any internally held data.
|
void |
open(org.apache.hadoop.fs.FSDataOutputStream outStream)
Initializes the
Writer for a newly opened bucket file. |
void |
write(T element)
Writes one element to the bucket file.
|
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)
public void open(org.apache.hadoop.fs.FSDataOutputStream outStream) throws IOException
Writer
Writer
for a newly opened bucket file.
Any internal per-bucket initialization should be performed here.open
in interface Writer<T>
outStream
- The FSDataOutputStream
for the newly opened file.IOException
public void flush() throws IOException
Writer
flush
in interface Writer<T>
IOException
public void close() throws IOException
Writer
Writer
. This must not close the FSDataOutputStream
that
was handed in in the Writer.open(org.apache.hadoop.fs.FSDataOutputStream)
method. Only internally held state should be
closed.close
in interface Writer<T>
IOException
public void write(T element) throws IOException
Writer
write
in interface Writer<T>
IOException
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.