Class RecordSqlWriter
java.lang.Object
org.apache.nifi.processors.standard.sql.RecordSqlWriter
- All Implemented Interfaces:
SqlWriter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ResultSetRecordSetprivate final intprivate Stringprivate final JdbcCommon.AvroConversionOptionsprivate final RecordSetWriterFactoryprivate final AtomicReference<WriteResult> private RecordSchema -
Constructor Summary
ConstructorsConstructorDescriptionRecordSqlWriter(RecordSetWriterFactory recordSetWriterFactory, JdbcCommon.AvroConversionOptions options, int maxRowsPerFlowFile, Map<String, String> originalAttributes) -
Method Summary
Modifier and TypeMethodDescriptionReturns a map of attribute key/value pairs to be added to any outgoing flow file(s).Returns the MIME type of the output format.voidupdateCounters(org.apache.nifi.processor.ProcessSession session) Updates any session counters as a result of processing result sets.voidwriteEmptyResultSet(OutputStream outputStream, org.apache.nifi.logging.ComponentLog logger) Writes an empty result set to the output stream.longwriteResultSet(ResultSet resultSet, OutputStream outputStream, org.apache.nifi.logging.ComponentLog logger, JdbcCommon.ResultSetRowCallback callback) Writes the given result set out to the given output stream, possibly applying a callback as each row is processed.
-
Field Details
-
recordSetWriterFactory
-
writeResultRef
-
options
-
maxRowsPerFlowFile
private final int maxRowsPerFlowFile -
originalAttributes
-
fullRecordSet
-
writeSchema
-
mimeType
-
-
Constructor Details
-
RecordSqlWriter
public RecordSqlWriter(RecordSetWriterFactory recordSetWriterFactory, JdbcCommon.AvroConversionOptions options, int maxRowsPerFlowFile, Map<String, String> originalAttributes)
-
-
Method Details
-
writeResultSet
public long writeResultSet(ResultSet resultSet, OutputStream outputStream, org.apache.nifi.logging.ComponentLog logger, JdbcCommon.ResultSetRowCallback callback) throws Exception Description copied from interface:SqlWriterWrites the given result set out to the given output stream, possibly applying a callback as each row is processed.- Specified by:
writeResultSetin interfaceSqlWriter- Parameters:
resultSet- the ResultSet to be writtenoutputStream- the OutputStream to write the result set tologger- a common logger that can be used to log messages during writecallback- a MaxValueResultSetRowCollector that may be called as each row in the ResultSet is processed- Returns:
- the number of rows written to the output stream
- Throws:
Exception- if any errors occur during the writing of the result set to the output stream
-
getAttributesToAdd
Description copied from interface:SqlWriterReturns a map of attribute key/value pairs to be added to any outgoing flow file(s). The default implementation is to return an empty map.- Specified by:
getAttributesToAddin interfaceSqlWriter- Returns:
- a map of attribute key/value pairs
-
updateCounters
public void updateCounters(org.apache.nifi.processor.ProcessSession session) Description copied from interface:SqlWriterUpdates any session counters as a result of processing result sets. The default implementation is empty, no counters will be updated.- Specified by:
updateCountersin interfaceSqlWriter- Parameters:
session- the session upon which to update counters
-
writeEmptyResultSet
public void writeEmptyResultSet(OutputStream outputStream, org.apache.nifi.logging.ComponentLog logger) throws IOException Description copied from interface:SqlWriterWrites an empty result set to the output stream. In some cases a ResultSet might not have any viable rows, but will throw an error or behave unexpectedly if rows are attempted to be retrieved. This method indicates the implementation should write whatever output is appropriate for a result set with no rows.- Specified by:
writeEmptyResultSetin interfaceSqlWriter- Parameters:
outputStream- the OutputStream to write the empty result set tologger- a common logger that can be used to log messages during write- Throws:
IOException- if any errors occur during the writing of an empty result set to the output stream
-
getMimeType
Description copied from interface:SqlWriterReturns the MIME type of the output format. This can be used in FlowFile attributes or to perform format-specific processing as necessary.- Specified by:
getMimeTypein interfaceSqlWriter- Returns:
- the MIME type string of the output format.
-