Class AccumulateCsvResults<T>

java.lang.Object
java.lang.Thread
com.opencsv.bean.concurrent.AccumulateCsvResults<T>
Type Parameters:
T - Type of output being created (bean or strings)
All Implemented Interfaces:
Runnable

class AccumulateCsvResults<T> extends Thread
The accumulator takes two queues of results of transforming text input into bean output or bean input into text output (output and exceptions) and orders them for later consumption. This task is delegated to a separate thread so threads can quickly queue their results in a (synchronized, thread-safe) queue and move on with other work, while the relatively expensive operation of ordering the results doesn't block other threads waiting for access to the ordered map.
Since:
4.0
  • Field Details

  • Constructor Details

    • AccumulateCsvResults

      AccumulateCsvResults(BlockingQueue<OrderedObject<T>> resultantBeansQueue, BlockingQueue<OrderedObject<CsvException>> thrownExceptionsQueue, SortedSet<Long> expectedRecords, ConcurrentMap<Long,T> resultantBeanMap, org.apache.commons.collections4.ListValuedMap<Long,CsvException> thrownExceptionsMap)
      The only accepted constructor for the accumulator.
      Parameters:
      resultantBeansQueue - A queue of beans coming out of the pool of threads creating them. The accumulator pulls from this queue.
      thrownExceptionsQueue - A queue of CsvException and its derivatives coming out of the pool of threads creating beans. The accumulator pulls from this queue.
      expectedRecords - A list of outstanding record numbers so gaps in ordering due to filtered input or exceptions while converting can be detected.
      resultantBeanMap - The (ordered) map of beans that have been created. The accumulator inserts into this map.
      thrownExceptionsMap - The map of suppressed exceptions thrown during bean creation. The accumulator inserts into this map. All access to this variable must be synchronized.
  • Method Details

    • isMustStop

      private boolean isMustStop()
      Checks whether the accumulator should shut itself down. This method must always be used to check the value of the signal boolean, because it's synchronized.
      Returns:
      Whether the accumulator should stop
    • setMustStop

      void setMustStop(boolean mustStop)
      Tells the accumulator whether it should stop. This method must always be used to set the value of the signal boolean, because it's synchronized.
      Parameters:
      mustStop - Whether the accumulator should stop
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread