Class AbstractBatchedColumnProcessor<T extends Context>
java.lang.Object
com.univocity.parsers.common.processor.core.AbstractBatchedColumnProcessor<T>
- All Implemented Interfaces:
Processor<T>
- Direct Known Subclasses:
BatchedColumnProcessor
public abstract class AbstractBatchedColumnProcessor<T extends Context>
extends Object
implements Processor<T>
A
Processor implementation that stores values of columns in batches. Use this implementation in favor of AbstractColumnProcessor
when processing large inputs to avoid running out of memory.
Values parsed in each row will be split into columns of Strings. Each column has its own list of values.
During the execution of the process, the batchProcessed(int) method will be invoked after a given number of rows has been processed.
The user can access the lists with values parsed for all columns using the methods getColumnValuesAsList(),
getColumnValuesAsMapOfIndexes() and getColumnValuesAsMapOfNames().
After batchProcessed(int) is invoked, all values will be discarded and the next batch of column values will be accumulated.
This process will repeat until there's no more rows in the input.
- Author:
- Univocity Software Pty Ltd - parsers@univocity.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractBatchedColumnProcessor(int rowsPerBatch) Constructs a batched column processor configured to invoke thebatchesProcessedmethod after a given number of rows has been processed. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidbatchProcessed(int rowsInThisBatch) intgetColumn(int columnIndex) final String[]intvoidprocessEnded(T context) This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.voidprocessStarted(T context) This method will by invoked by the parser once, when it is ready to start processing the input.final voidfinal voidputColumnValuesInMapOfNames(Map<String, List<String>> map) voidrowProcessed(String[] row, T context) Invoked by the parser after all values of a valid record have been processed.
-
Constructor Details
-
AbstractBatchedColumnProcessor
public AbstractBatchedColumnProcessor(int rowsPerBatch) Constructs a batched column processor configured to invoke thebatchesProcessedmethod after a given number of rows has been processed.- Parameters:
rowsPerBatch- the number of rows to process in each batch.
-
-
Method Details
-
processStarted
Description copied from interface:ProcessorThis method will by invoked by the parser once, when it is ready to start processing the input.- Specified by:
processStartedin interfaceProcessor<T extends Context>- Parameters:
context- A contextual object with information and controls over the current state of the parsing process
-
rowProcessed
Description copied from interface:ProcessorInvoked by the parser after all values of a valid record have been processed.- Specified by:
rowProcessedin interfaceProcessor<T extends Context>- Parameters:
row- the data extracted by the parser for an individual record. Note that:- it will never by null.
- it will never be empty unless explicitly configured using
CommonSettings.setSkipEmptyLines(boolean) - it won't contain lines identified by the parser as comments. To disable comment processing set
Format.setComment(char)to '\0'
context- A contextual object with information and controls over the current state of the parsing process
-
processEnded
Description copied from interface:ProcessorThis method will by invoked by the parser once, after the parsing process stopped and all resources were closed.It will always be called by the parser: in case of errors, if the end of the input us reached, or if the user stopped the process manually using
Context.stop().- Specified by:
processEndedin interfaceProcessor<T extends Context>- Parameters:
context- A contextual object with information and controls over the state of the parsing process
-
getHeaders
-
getColumnValuesAsList
-
putColumnValuesInMapOfNames
-
putColumnValuesInMapOfIndexes
-
getColumnValuesAsMapOfNames
-
getColumnValuesAsMapOfIndexes
-
getColumn
-
getColumn
-
getRowsPerBatch
public int getRowsPerBatch() -
getBatchesProcessed
public int getBatchesProcessed() -
batchProcessed
public abstract void batchProcessed(int rowsInThisBatch)
-