ExtractionExecutionStrategy

Controls how the PropositionPipeline dispatches the stateless per-chunk extraction stage. Implementations choose serial or concurrent execution; the resolution stage (entity resolution) always runs serially regardless of the strategy, preserving cross-chunk entity identity.

Contract

  • Input order is preserved: the returned list has exactly chunks.size elements and result[i] corresponds to chunks[i] (or null if extraction of chunks[i] failed).

  • Failure is a null slot: when extract(chunk) throws, that slot becomes null rather than propagating the exception. The pipeline maps a null slot to a ChunkPropositionResult.Failed. No element is ever dropped or reordered.

Executor ownership

Each implementation owns its execution mechanism. The execute signature intentionally does not mention ExecutorService — any executor is an injected implementation detail. A caller-supplied executor is never shut down by the strategy — its lifecycle stays the caller's. When a strategy creates its own pool (the no-executor constructors), that pool is the strategy's to clean up: both concurrent strategies are AutoCloseable, and close shuts down only an internally-created pool.

Thread-safety gate for production

The default is SerialExtractionStrategy (no concurrency). Before switching to ParallelExtractionStrategy or BatchedExtractionStrategy with batchSize > 1, verify that the Ai implementation backing your PropositionExtractor is thread-safe for concurrent extract() calls. Until then, BatchedExtractionStrategy(batchSize = 1) is the safe degrade-to-serial path.

Note: this is a plain interface rather than a fun interface because Kotlin SAM conversion does not support abstract methods with their own type parameters (fun <T> execute(...)).

Inheritors

Functions

Link copied to clipboard
abstract fun <T> execute(chunks: List<<Error class: unknown class>>, extract: (<Error class: unknown class>) -> T): List<T?>

Apply extract to each chunk, returning results in INPUT ORDER. A null slot at index i means extract(chunks[i]) threw and was caught (see contract above).