Class LoopExecutor
java.lang.Object
ai.nervemind.app.executor.LoopExecutor
- All Implemented Interfaces:
NodeExecutor
Executor for the "loop" node type - iterates over arrays or collections.
Enables processing of multiple items by iterating through a collection and executing child operations for each item. Supports both sequential and parallel execution modes using Java virtual threads.
Node Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| items | String | "items" | Field name containing the array to iterate |
| parallel | Boolean | false | Enable virtual thread parallelism |
| batchSize | Integer | 10 | Items processed concurrently when parallel=true |
Output Data
| Key | Type | Description |
|---|---|---|
| results | List | List of result objects, each with "item" and "index" |
| count | Integer | Number of items processed |
Result Item Structure
Each item in the results list contains:
- item - The original item from the input array
- index - Zero-based index of the item in the original array
Parallel Execution
When parallel=true, items are processed using virtual threads
(requires Java 21+). The batch size controls how many virtual threads
are spawned concurrently:
// Configuration for parallel processing with batches of 5
{
"parallel": true,
"batchSize": 5,
"items": "dataArray"
}
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Executes the business logic for this node type.Unique identifier for the node type this executor handles.
-
Constructor Details
-
LoopExecutor
public LoopExecutor()Default constructor.
-
-
Method Details
-
execute
public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Description copied from interface:NodeExecutorExecutes the business logic for this node type.- Specified by:
executein interfaceNodeExecutor- Parameters:
node- The node definition containing parameters and configuration. UseNode.parameters()to access user settings.input- Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.context- Verification context providing access to workflow-scoped services, logger, and execution metadata.- Returns:
- A Map containing the results of this node's execution.
Keys in this map become available variables for downstream nodes.
Note: Returningnullis treated as an empty map.
-
getNodeType
Description copied from interface:NodeExecutorUnique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.- Specified by:
getNodeTypein interfaceNodeExecutor- Returns:
- The unique type string (e.g., "httpRequest", "llmChat").
-