Interface RecordReader

All Superinterfaces:
AutoCloseable, Closeable

public interface RecordReader extends Closeable

A RowRecordReader is responsible for parsing data and returning a record at a time in order to allow the caller to iterate over the records individually.

PLEASE NOTE: This interface is still considered 'unstable' and may change in a non-backward-compatible manner between minor or incremental releases of NiFi.

  • Method Summary

    Modifier and Type
    Method
    Description
    default RecordSet
     
     
    default Record
    Returns the next record in the stream or null if no more records are available.
    nextRecord(boolean coerceTypes, boolean dropUnknownFields)
    Reads the next record from the underlying stream.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • nextRecord

      default Record nextRecord() throws IOException, MalformedRecordException
      Returns the next record in the stream or null if no more records are available. Types will be coerced and any unknown fields will be dropped.
      Returns:
      the next record in the stream or null if no more records are available.
      Throws:
      IOException - if unable to read from the underlying data
      MalformedRecordException - if an unrecoverable failure occurs when trying to parse a record
      SchemaValidationException - if a Record contains a field that violates the schema and cannot be coerced into the appropriate field type.
    • nextRecord

      Record nextRecord(boolean coerceTypes, boolean dropUnknownFields) throws IOException, MalformedRecordException
      Reads the next record from the underlying stream. If type coercion is enabled, then any field in the Record whose type does not match the schema will be coerced to the correct type and a MalformedRecordException will be thrown if unable to coerce the data into the correct type. If type coercion is disabled, then no type coercion will occur. As a result, calling Record.getValue(org.apache.nifi.serialization.record.RecordField) may return any type of Object, such as a String or another Record, even though the schema indicates that the field must be an integer.
      Parameters:
      coerceTypes - whether or not fields in the Record should be validated against the schema and coerced when necessary
      dropUnknownFields - if true, any field that is found in the data that is not present in the schema will be dropped. If false, those fields will still be part of the Record (though their type cannot be coerced, since the schema does not provide a type for it).
      Returns:
      the next record in the stream or null if no more records are available
      Throws:
      IOException - if unable to read from the underlying data
      MalformedRecordException - if an unrecoverable failure occurs when trying to parse a record, or a Record contains a field that violates the schema and cannot be coerced into the appropriate field type.
      SchemaValidationException - if a Record contains a field that violates the schema and cannot be coerced into the appropriate field type and schema enforcement is enabled
    • getSchema

      Returns:
      a RecordSchema that is appropriate for the records in the stream
      Throws:
      MalformedRecordException - if an unrecoverable failure occurs when trying to parse the underlying data
    • createRecordSet

      default RecordSet createRecordSet()
      Returns:
      a RecordSet that returns the records in this Record Reader in a streaming fashion