Interface RecordSetWriterFactory
- All Superinterfaces:
ConfigurableComponent
,ControllerService
A Controller Service that is responsible for creating a RecordSetWriter
.
A writer is created with a RecordSchema and an OutputStream that the writer will write to.
The schema can be retrieved by getSchema(Map, RecordSchema)
method, based on a Map containing variables,
and a RecordSchema which is read from the incoming FlowFile.
For most processors those make use of Record Writers also make use of Record Readers, and the schema for the output is often determined
by either reading the schema from referencing attributes or the content of the input FlowFile.
In this case, if a RecordSchema is known and already available when calling getSchema(Map, RecordSchema)
method,
the schema should be specified so that it can be reused.
-
Method Summary
Modifier and TypeMethodDescriptioncreateWriter
(ComponentLog logger, RecordSchema schema, OutputStream out, Map<String, String> variables) Creates a new RecordSetWriter that is capable of writing record contents to an OutputStream.default RecordSetWriter
createWriter
(ComponentLog logger, RecordSchema schema, OutputStream out, FlowFile flowFile) Creates a new RecordSetWriter that is capable of writing record contents to an OutputStream.getSchema
(Map<String, String> variables, RecordSchema readSchema) Returns the Schema that will be used for writing Records.Methods inherited from interface org.apache.nifi.components.ConfigurableComponent
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
Methods inherited from interface org.apache.nifi.controller.ControllerService
initialize, isStateful, migrateProperties
-
Method Details
-
getSchema
RecordSchema getSchema(Map<String, String> variables, RecordSchema readSchema) throws SchemaNotFoundException, IOExceptionReturns the Schema that will be used for writing Records. The given variables are intended to be used for determining the schema that should be used when writing records.
- Parameters:
variables
- the variables which is used to resolve Record Schema via Expression Language, can be null or emptyreadSchema
- the schema that was read from the incoming FlowFile, ornull
if there is no input schema- Returns:
- the Schema that should be used for writing Records
- Throws:
SchemaNotFoundException
- if unable to find the schemaIOException
-
createWriter
default RecordSetWriter createWriter(ComponentLog logger, RecordSchema schema, OutputStream out, FlowFile flowFile) throws SchemaNotFoundException, IOException Creates a new RecordSetWriter that is capable of writing record contents to an OutputStream. The method accepts a FlowFile whose attributes can be used to resolve properties specified via Expression Language.
- Parameters:
logger
- the logger to use when logging information. This is passed in, rather than using the logger of the Controller Service because it allows messages to be logged for the component that is calling this Controller Service.schema
- the schema that will be used for writing recordsout
- the OutputStream to write toflowFile
- the FlowFile whose attributes are used to resolve properties specified via Expression Language- Returns:
- a RecordSetWriter that can write record sets to an OutputStream
- Throws:
IOException
- if unable to read from the given InputStreamSchemaNotFoundException
-
createWriter
RecordSetWriter createWriter(ComponentLog logger, RecordSchema schema, OutputStream out, Map<String, String> variables) throws SchemaNotFoundException, IOExceptionCreates a new RecordSetWriter that is capable of writing record contents to an OutputStream. The method accepts a variables map that can be used to resolve properties specified via Expression Language.
- Parameters:
logger
- the logger to use when logging information. This is passed in, rather than using the logger of the Controller Service because it allows messages to be logged for the component that is calling this Controller Service.schema
- the schema that will be used for writing recordsout
- the OutputStream to write tovariables
- the variables which are used to resolve properties specified via Expression Language- Returns:
- a RecordSetWriter that can write record sets to an OutputStream
- Throws:
IOException
- if unable to read from the given InputStreamSchemaNotFoundException
-