public abstract class AbstractRecordSetWriter extends Object implements RecordSetWriter
Modifier and Type | Field and Description |
---|---|
private boolean |
activeRecordSet |
private OutputStream |
out |
private int |
recordCount |
Constructor and Description |
---|
AbstractRecordSetWriter(OutputStream out) |
Modifier and Type | Method and Description |
---|---|
void |
beginRecordSet()
Begins a new RecordSet
|
void |
close() |
WriteResult |
finishRecordSet()
Finishes the currently active RecordSet and returns a WriteResult that includes information about what was written
|
void |
flush()
Flushes any buffered data to the underlying stream
|
protected OutputStream |
getOutputStream() |
protected int |
getRecordCount() |
protected int |
incrementRecordCount() |
protected boolean |
isActiveRecordSet() |
protected void |
onBeginRecordSet()
Method that is called as a result of
beginRecordSet() being called. |
protected Map<String,String> |
onFinishRecordSet()
Method that is called by
finishRecordSet() when a RecordSet is finished. |
WriteResult |
write(Record record)
Writes the given record to the underlying stream
|
WriteResult |
write(RecordSet recordSet)
Writes the given result set to the given output stream
|
protected abstract Map<String,String> |
writeRecord(Record record) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMimeType
private final OutputStream out
private int recordCount
private boolean activeRecordSet
public AbstractRecordSetWriter(OutputStream out)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void flush() throws IOException
RecordWriter
flush
in interface RecordWriter
IOException
- if unable to write to the underlying streampublic WriteResult write(RecordSet recordSet) throws IOException
RecordSetWriter
write
in interface RecordSetWriter
recordSet
- the record set to serializeIOException
- if unable to write to the given OutputStreampublic final WriteResult write(Record record) throws IOException
RecordWriter
write
in interface RecordWriter
record
- the record to writeIOException
- if unable to write to the underlying streamprotected OutputStream getOutputStream()
protected final int getRecordCount()
protected final boolean isActiveRecordSet()
public final void beginRecordSet() throws IOException
RecordSetWriter
beginRecordSet
in interface RecordSetWriter
IOException
- if unable to write to the underlying OutputStreampublic final WriteResult finishRecordSet() throws IOException
RecordSetWriter
finishRecordSet
in interface RecordSetWriter
IOException
- if unable to write to the given OutputStreamprotected int incrementRecordCount()
protected void onBeginRecordSet() throws IOException
beginRecordSet()
being called. This gives subclasses
the chance to react to a new RecordSet beginning but prevents the subclass from changing how this
implementation maintains its internal state. By default, this method does nothing.IOException
- if unable to write the necessary data for a new RecordSetprotected Map<String,String> onFinishRecordSet() throws IOException
finishRecordSet()
when a RecordSet is finished. This gives subclasses
the chance to react to a RecordSet being completed but prevents the subclass from changing how this
implementation maintains its internal state.IOException
protected abstract Map<String,String> writeRecord(Record record) throws IOException
IOException
Copyright © 2021 Apache NiFi Project. All rights reserved.