Class StreamingJsonArrayFileReader<T>
java.lang.Object
com.broadleafcommerce.datafeed.service.publisher.file.support.StreamingJsonArrayFileReader<T>
- Type Parameters:
T
- the POJO type to deserialize each array element into
Useful for reading through a file which is just a JSON array of objects (ex: typically what is in
DataFeedProcessExecution.getQueriedDataFileLocation()
when using
AbstractJsonArrayDataFeedCollector
). This utility allows consumers to read elements from
such a file in a streaming fashion (to avoid loading everything into memory at once).
This is not intended to be a bean, and is expected to be manually instantiated and used to process a specific file.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThe POJO type to deserialize each element into.A callback that will do work on a batch of read elements.protected Path
The JSON array file to process.protected int
The number of elements to load into memory and transform at a time.protected com.fasterxml.jackson.databind.ObjectMapper
TheObjectMapper
to use for deserialization.void
read()
-
Constructor Details
-
StreamingJsonArrayFileReader
-
-
Method Details
-
read
- Throws:
IOException
- if something went wrong
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()TheObjectMapper
to use for deserialization. -
getDeserializedElementType
The POJO type to deserialize each element into. -
getMaxElementsToReadInBatch
protected int getMaxElementsToReadInBatch()The number of elements to load into memory and transform at a time. -
getElementBatchHandler
A callback that will do work on a batch of read elements. -
getFileToProcess
The JSON array file to process.
-