Class AccumulatingProcessorManager<T,R>
- java.lang.Object
-
- org.apache.druid.frame.processor.manager.AccumulatingProcessorManager<T,R>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ProcessorManager<T,R>
public class AccumulatingProcessorManager<T,R> extends Object implements ProcessorManager<T,R>
Processor manager that wraps anotherProcessorManagerand accumulates a result.
-
-
Constructor Summary
Constructors Constructor Description AccumulatingProcessorManager(ProcessorManager<T,?> delegate, R initialResult, BiFunction<R,T,R> accumulateFn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Called when all processors are done, or when one has failed.com.google.common.util.concurrent.ListenableFuture<Optional<ProcessorAndCallback<T>>>next()Returns the next processor that should be run, along with a callback.Rresult()Called after all procesors are done, prior toProcessorManager.close(), to retrieve the result of this computation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.frame.processor.manager.ProcessorManager
withAccumulation
-
-
-
-
Constructor Detail
-
AccumulatingProcessorManager
public AccumulatingProcessorManager(ProcessorManager<T,?> delegate, R initialResult, BiFunction<R,T,R> accumulateFn)
-
-
Method Detail
-
next
public com.google.common.util.concurrent.ListenableFuture<Optional<ProcessorAndCallback<T>>> next()
Description copied from interface:ProcessorManagerReturns the next processor that should be run, along with a callback. The callback is called when the processor completes successfully, along with the result of the processor. If the processor fails, the callback is not called. The callback is called in a thread-safe manner: it will never be called concurrently with another callback, or concurrently with a call to "next" orProcessorManager.close(). To ensure this,FrameProcessorExecutor.runAllFully(org.apache.druid.frame.processor.manager.ProcessorManager<T, R>, int, org.apache.druid.frame.processor.Bouncer, java.lang.String)synchronizes executions of callbacks for the same processor manager. Therefore, it is important that the callbacks executed quickly. This method returns a future, so it allows for logic where the construction of later processors depends on the results of earlier processors. Returns an empty Optional if there are no more processors to run. Behavior of this method is undefined if called afterProcessorManager.close().- Specified by:
nextin interfaceProcessorManager<T,R>
-
result
public R result()
Description copied from interface:ProcessorManagerCalled after all procesors are done, prior toProcessorManager.close(), to retrieve the result of this computation. Behavior of this method is undefined if called afterProcessorManager.close(), or if called prior toProcessorManager.next()returning an emptyOptional, or if called prior to all callbacks fromProcessorManager.next()having been called.- Specified by:
resultin interfaceProcessorManager<T,R>
-
close
public void close()
Description copied from interface:ProcessorManagerCalled when all processors are done, or when one has failed. This method releases all resources associated with this manager. After calling this method, callers must call no other methods.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceProcessorManager<T,R>
-
-