Package com.saxonica.ee.parallel
Class MultithreadedItemMappingIterator
java.lang.Object
net.sf.saxon.expr.ItemMappingIterator
com.saxonica.ee.parallel.MultithreadedItemMappingIterator
- All Implemented Interfaces:
Closeable,AutoCloseable,LastPositionFinder,SequenceIterator,LookaheadIterator
Parallel-processing version of the ItemMappingIterator class, which executes a mapping function
for each item in a sequence. In this implementation (which is designed initially for use
by the collection() function), the order of items in the result sequence retains
the order of items in the input sequence.
-
Constructor Summary
ConstructorsConstructorDescriptionMultithreadedItemMappingIterator(SequenceIterator base, ItemMappingFunction action, MultithreadingFactory factory) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()The user of aSequenceIteratoris encouraged to call theclose()method if no further items are required from the sequence of items delivered by theSequenceIterator.protected intOverridable method that decides how many threads to use.next()Get the next item in the sequence.Methods inherited from class net.sf.saxon.expr.ItemMappingIterator
filter, getBaseIterator, getLength, getMappingFunction, hasNext, isOneToOne, map, setOneToOne, supportsGetLength, supportsHasNext
-
Constructor Details
-
MultithreadedItemMappingIterator
public MultithreadedItemMappingIterator(SequenceIterator base, ItemMappingFunction action, MultithreadingFactory factory) throws XPathException - Throws:
XPathException
-
-
Method Details
-
getMaxThreads
protected int getMaxThreads()Overridable method that decides how many threads to use. The default implementation returns the value ofRuntime.getRuntime().availableProcessors(), or 1 if greater.- Returns:
- the maximum number of threads to use.
-
next
Description copied from interface:SequenceIteratorGet the next item in the sequence. This method changes the state of the iterator.- Specified by:
nextin interfaceSequenceIterator- Overrides:
nextin classItemMappingIterator- Returns:
- the next item, or null if there are no more items. Once a call on next() has returned null, no further calls should be made. The preferred action for an iterator if subsequent calls on next() are made is to return null again, and all implementations within Saxon follow this rule.
-
close
public void close()The user of aSequenceIteratoris encouraged to call theclose()method if no further items are required from the sequence of items delivered by theSequenceIterator. This allows resources to be released. ASequenceIteratoris NOT normally closed explicitly if it has been read to completion. This implementation of theclose()method shuts down theExecutorServiceused to schedule threads.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSequenceIterator- Overrides:
closein classItemMappingIterator
-