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.
AbstractParser, BatchedColumnReader, Processor
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private int | |
| private final int | |
| private final ColumnSplitter |
| Access | Constructor and Description |
|---|---|
| public | AbstractBatchedColumnProcessor(int
the number of rows to process in each batch. rowsPerBatch)Constructs a batched column processor configured to invoke the |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | batchProcessed(int
the number of rows processed in the current batch. This corresponds to the number of elements of each list of each column. rowsInThisBatch)Redeclares com. getColumnValuesAsList(),
getColumnValuesAsMapOfIndexes() and getColumnValuesAsMapOfNames().
|
| public int | getBatchesProcessed()
Implements com. |
| public List | getColumn(String
the name of the column in the input. columnName)Implements com. |
| public List | getColumn(int
the position of the column in the input (0-based). columnIndex)Implements com. |
| public final List | getColumnValuesAsList()
Implements com. |
| public final Map | getColumnValuesAsMapOfIndexes()
Implements com. |
| public final Map | getColumnValuesAsMapOfNames()
Implements com. |
| public final String[] | getHeaders()
Implements com. |
| public int | getRowsPerBatch()
Implements com. |
| public void | processEnded(T
A contextual object with information and controls over the state of the parsing process context)Implements com. |
| public void | processStarted(T
A contextual object with information and controls over the current state of the parsing process context)Implements com. |
| public final void | putColumnValuesInMapOfIndexes(Map<Integer, List<String>>
the map to hold the values of each column map)Implements com. |
| public final void | putColumnValuesInMapOfNames(Map<String, List<String>>
the map to hold the values of each column map)Implements com. |
| public void | rowProcessed(String[]
the data extracted by the parser for an individual record. Note that:
row, T
A contextual object with information and controls over the current state of the parsing process context)Implements com. |
| batchCount | back to summary |
|---|---|
| private int batchCount | |
| batchesProcessed | back to summary |
|---|---|
| private int batchesProcessed | |
| rowsPerBatch | back to summary |
|---|---|
| private final int rowsPerBatch | |
| splitter | back to summary |
|---|---|
| private final ColumnSplitter<String> splitter | |
| AbstractBatchedColumnProcessor | back to summary |
|---|---|
| public AbstractBatchedColumnProcessor(int rowsPerBatch) Constructs a batched column processor configured to invoke the
| |
| batchProcessed | back to summary |
|---|---|
| public abstract void batchProcessed(int rowsInThisBatch) Redeclares com. Doc from com. Callback to the user, where the lists with values parsed for all columns can be accessed using the methods
| |
| getBatchesProcessed | back to summary |
|---|---|
| public int getBatchesProcessed() Implements com. Doc from com. Returns the number of batches already processed
| |
| getColumn | back to summary |
|---|---|
| public List Implements com. Doc from com. Returns the values of a given column. | |
| getColumn | back to summary |
|---|---|
| public List Implements com. Doc from com. Returns the values of a given column. | |
| getColumnValuesAsList | back to summary |
|---|---|
| public final List Implements com. Doc from com. Returns the values processed for each column | |
| getColumnValuesAsMapOfIndexes | back to summary |
|---|---|
| public final Map Implements com. Doc from com. Returns a map of column indexes and their respective list of values parsed from the input. | |
| getColumnValuesAsMapOfNames | back to summary |
|---|---|
| public final Map Implements com. Doc from com. Returns a map of column names and their respective list of values parsed from the input. | |
| getHeaders | back to summary |
|---|---|
| public final String[] getHeaders() Implements com. Doc from com. Returns the column headers. This can be either the headers defined in | |
| getRowsPerBatch | back to summary |
|---|---|
| public int getRowsPerBatch() Implements com. Doc from com. Returns the number of rows processed in each batch
| |
| processEnded | back to summary |
|---|---|
| public void processEnded(T context) Implements com. Doc from com. This 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
| |
| processStarted | back to summary |
|---|---|
| public void processStarted(T context) Implements com. Doc from com. This method will by invoked by the parser once, when it is ready to start processing the input.
| |
| putColumnValuesInMapOfIndexes | back to summary |
|---|---|
| public final void putColumnValuesInMapOfIndexes(Map<Integer, List<String>> map) Implements com. Doc from com. Fills a given map associating each column index to its list of values | |
| putColumnValuesInMapOfNames | back to summary |
|---|---|
| public final void putColumnValuesInMapOfNames(Map<String, List<String>> map) Implements com. Doc from com. Fills a given map associating each column name to its list o values | |
| rowProcessed | back to summary |
|---|---|
| public void rowProcessed(String[] row, T context) Implements com. Doc from com. Invoked by the parser after all values of a valid record have been processed.
| |