Class ReduceBinding
java.lang.Object
ai.badmonkey.agentspaces.agent.reduce.ReduceBinding
- All Implemented Interfaces:
AutoCloseable
The runtime behind
@SpaceReduce (ISSUE-SpaceReduce ยง9.3): a fold
whose accumulator is an entry beside its elements. A step takes one element,
invokes the method with the key's current accumulator, and completes the
element with the new accumulator as the result, atomically; the previous
accumulator is then retired. A JoinTicket per key, taken before a
drain and re-armed by completion after it, serializes the steps of one key
across reducers; under SpaceReduce.Mode.ORDERED every take goes
through the ordered-log coordinator and the log decides the ticket's holder.
Constructed and started by AgentBinder; the step and the
side-output dispatch it is given are the binder's method invocation and
return handling, so this class never reflects on the agent itself.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat the binder configured. -
Constructor Summary
ConstructorsConstructorDescriptionReduceBinding(ReduceBinding.Config config, BiFunction<Object, Object, Object> step, Consumer<Object> sideOutputs, InstantSource clock) -
Method Summary
-
Constructor Details
-
ReduceBinding
public ReduceBinding(ReduceBinding.Config config, BiFunction<Object, Object, Object> step, Consumer<Object> sideOutputs, InstantSource clock) - Parameters:
config- what the binder resolved from the annotationstep- invokes the agent's method on (accumulator or null, element) and returns its resultsideOutputs- the binder's return handling for a fork's other elementsclock- the binder's clock
-
-
Method Details
-
name
The reduce's name, as tickets, accumulators, and the card carry it. -
start
public void start()Seeds the pending keys from the space, subscribes to the elements, and starts the drain. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-