K
- The type of key written.V
- The type of value written.@PublicEvolving public class SequenceFileWriter<K extends org.apache.hadoop.io.Writable,V extends org.apache.hadoop.io.Writable> extends Object implements BulkWriter<Tuple2<K,V>>
BulkWriter
implementation that wraps a SequenceFile.Writer
.BulkWriter.Factory<T>
Modifier and Type | Method and Description |
---|---|
void |
addElement(Tuple2<K,V> element)
Adds an element to the encoder.
|
void |
finish()
Finishes the writing.
|
void |
flush()
Flushes all intermediate buffered data to the output stream.
|
public void addElement(Tuple2<K,V> element) throws IOException
BulkWriter
It may be that adding this element fills up an internal buffer and causes the encoding and flushing of a batch of internally buffered elements.
addElement
in interface BulkWriter<Tuple2<K extends org.apache.hadoop.io.Writable,V extends org.apache.hadoop.io.Writable>>
element
- The element to add.IOException
- Thrown, if the element cannot be added to the encoder,
or if the output stream throws an exception.public void flush() throws IOException
BulkWriter
flush
in interface BulkWriter<Tuple2<K extends org.apache.hadoop.io.Writable,V extends org.apache.hadoop.io.Writable>>
IOException
- Thrown if the encoder cannot be flushed, or if the output
stream throws an exception.public void finish() throws IOException
BulkWriter
The writer is not expected to handle any more records via BulkWriter.addElement(Object)
after
this method is called.
Important: This method MUST NOT close the stream that the writer writes to. Closing the stream is expected to happen through the invoker of this method afterwards.
finish
in interface BulkWriter<Tuple2<K extends org.apache.hadoop.io.Writable,V extends org.apache.hadoop.io.Writable>>
IOException
- Thrown if the finalization fails.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.