|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.common.processor.core.AbstractConcurrentProcessor<T>
public abstract class AbstractConcurrentProcessor<T extends Context>
A Processor implementation to perform row processing tasks in parallel. The ConcurrentRowProcessor
wraps another Processor, and collects rows read from the input.
The actual row processing is performed in by wrapped Processor in a separate thread.
Note: by default the Context object passed on to the wrapped Processor will not reflect the
state of the parser at the time the row as generated, but the current state of the parser instead. You can enable the
contextCopyingEnabled flag to generate copies of the Context at the time each row was generated.
AbstractParser,
Processor| Constructor Summary | |
|---|---|
AbstractConcurrentProcessor(Processor<T> processor)
Creates a non-blocking AbstractConcurrentProcessor, to perform processing of rows parsed from the input in a separate thread. |
|
AbstractConcurrentProcessor(Processor<T> processor,
int limit)
Creates a blocking ConcurrentProcessor, to perform processing of rows parsed from the input in a separate thread. |
|
| Method Summary | |
|---|---|
protected abstract T |
copyContext(T context)
|
protected long |
getRowCount()
|
boolean |
isContextCopyingEnabled()
Indicates whether this processor should persist the Context object that is sent to the wrapped Processor
given in the constructor of this class, so all methods of Context reflect the parser state at the time
each row was parsed. |
void |
processEnded(T context)
This method will by invoked by the parser once, after the parsing process stopped and all resources were closed. |
void |
processStarted(T context)
This method will by invoked by the parser once, when it is ready to start processing the input. |
void |
rowProcessed(String[] row,
T context)
Invoked by the parser after all values of a valid record have been processed. |
void |
setContextCopyingEnabled(boolean contextCopyingEnabled)
Configures this processor to persist the Context object that is sent to the wrapped Processor
given in the constructor of this class, so all methods of Context reflect the parser state at the time
each row was parsed. |
protected abstract T |
wrapContext(T context)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractConcurrentProcessor(Processor<T> processor)
AbstractConcurrentProcessor, to perform processing of rows parsed from the input in a separate thread.
processor - a regular Processor implementation which will be executed in a separate thread.
public AbstractConcurrentProcessor(Processor<T> processor,
int limit)
ConcurrentProcessor, to perform processing of rows parsed from the input in a separate thread.
processor - a regular Processor implementation which will be executed in a separate thread.limit - the limit of rows to be kept in memory before blocking the input parsing process.| Method Detail |
|---|
public boolean isContextCopyingEnabled()
Context object that is sent to the wrapped Processor
given in the constructor of this class, so all methods of Context reflect the parser state at the time
each row was parsed.
Defaults to false
public void setContextCopyingEnabled(boolean contextCopyingEnabled)
Context object that is sent to the wrapped Processor
given in the constructor of this class, so all methods of Context reflect the parser state at the time
each row was parsed.
Defaults to false
contextCopyingEnabled - a flag indicating whether the parsing context must be persisted along with the parsed row
so its methods reflect the state of the parser at the time the record was produced.public final void processStarted(T context)
Processor
processStarted in interface Processor<T extends Context>context - A contextual object with information and controls over the current state of the parsing process
public final void rowProcessed(String[] row,
T context)
Processor
rowProcessed in interface Processor<T extends Context>row - the data extracted by the parser for an individual record. Note that:
CommonSettings.setSkipEmptyLines(boolean)Format.setComment(char) to '\0'context - A contextual object with information and controls over the current state of the parsing processpublic final void processEnded(T context)
Processor 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().
processEnded in interface Processor<T extends Context>context - A contextual object with information and controls over the state of the parsing processprotected final long getRowCount()
protected abstract T copyContext(T context)
protected abstract T wrapContext(T context)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||