Interface RecordReaderFactory
- All Superinterfaces:
ConfigurableComponent
,ControllerService
A Controller Service that is responsible for creating a RecordReader
.
-
Method Summary
Modifier and TypeMethodDescriptioncreateRecordReader
(Map<String, String> variables, InputStream in, long inputLength, ComponentLog logger) Create a RecordReader instance to read records from specified InputStream.default RecordReader
createRecordReader
(FlowFile flowFile, InputStream in, ComponentLog logger) Create a RecordReader instance to read records from specified InputStream.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
-
createRecordReader
default RecordReader createRecordReader(FlowFile flowFile, InputStream in, ComponentLog logger) throws MalformedRecordException, IOException, SchemaNotFoundException Create a RecordReader instance to read records from specified InputStream. This method callscreateRecordReader(Map, InputStream, long, ComponentLog)
with Attributes of the specified FlowFile.- Parameters:
flowFile
- Attributes of this FlowFile are used to resolve Record Schema via Expression Language dynamically. This can be null.in
- InputStream containing Records.logger
- A logger bound to a component- Returns:
- Created RecordReader instance
- Throws:
MalformedRecordException
IOException
SchemaNotFoundException
-
createRecordReader
RecordReader createRecordReader(Map<String, String> variables, InputStream in, long inputLength, ComponentLog logger) throws MalformedRecordException, IOException, SchemaNotFoundExceptionCreate a RecordReader instance to read records from specified InputStream.
Many Record Readers will need to read from the Input Stream in order to ascertain the appropriate Schema, and then re-read some of the data in order to read the Records. As a result, it is common for Readers to use
mark
/reset
, so this should be considered when providing an InputStream. TheInputStream
that is provided bySessionProcess.read
/ProcessSession.write
does provide the ability to use mark/reset and does so in a way that allows any number of bytes to be read before resetting without requiring that data be buffered. Therefore, it is recommended that when providing an InputStream fromProcessSession
that the InputStream not be wrapped in a BufferedInputStream. However, if the stream is coming from elsewhere, it may be necessary.- Parameters:
variables
- A map containing variables which is used to resolve the Record Schema dynamically via Expression Language. This can be null or empty.in
- InputStream containing Records.inputLength
- A hint about the length of the content to read from the InputStream. This value is specified in bytes and a negative value indicates an unknown or unbound size. Some reader implementations must be able to seek to the end of the InputStream and will require knowing the length. Other implementations may be ignore this hint and may read the entire InputStream.logger
- A logger bound to a component- Returns:
- Created RecordReader instance
- Throws:
MalformedRecordException
IOException
SchemaNotFoundException
-