Interface RecordSetWriterFactory

All Superinterfaces:
ConfigurableComponent, ControllerService

public interface RecordSetWriterFactory extends 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 Details

    • getSchema

      RecordSchema getSchema(Map<String,String> variables, RecordSchema readSchema) throws SchemaNotFoundException, IOException

      Returns 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 empty
      readSchema - the schema that was read from the incoming FlowFile, or null if there is no input schema
      Returns:
      the Schema that should be used for writing Records
      Throws:
      SchemaNotFoundException - if unable to find the schema
      IOException
    • 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 records
      out - the OutputStream to write to
      flowFile - 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 InputStream
      SchemaNotFoundException
    • createWriter

      RecordSetWriter createWriter(ComponentLog logger, RecordSchema schema, OutputStream out, Map<String,String> variables) throws SchemaNotFoundException, IOException

      Creates 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 records
      out - the OutputStream to write to
      variables - 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 InputStream
      SchemaNotFoundException