T
- query stage configuration classpublic interface QueryStage<T extends QueryStageConfig>
@Stage(type = "myStage", configClass = MyStageConfig.class) public class MyStage implements QueryStage<MyStageConfig> { @Override public void init(MyStageConfig config, Fusion fusion) { // stage initialization logic } @Override public Document process(Document document, Context context) { // document processing logic }Implementations of this class must be stateless. Fusion can create and use multiple query stage instances at the same time.
Modifier and Type | Method and Description |
---|---|
void |
init(T config,
Fusion fusion)
Stage initialization callback.
|
default DslQueryRequestResponse |
process(DslQueryRequestResponse dslQueryRequestResponse,
Context context)
Process a single dslQueryRequestResponse.
|
default void |
process(DslQueryRequestResponse dslQueryRequestResponse,
Context context,
java.util.function.Consumer<DslQueryRequestResponse> output)
Process single dslQueryRequestResponse.
|
void init(T config, Fusion fusion)
QueryStageConfig
instance. Additionally Fusion
interface instance will be passed to allow calling Fusion API from the query stage.config
- query pipeline stage configurationfusion
- Fusion API instancedefault DslQueryRequestResponse process(DslQueryRequestResponse dslQueryRequestResponse, Context context)
DslQueryRequestResponse
instance that results in
either 1 or 0 dslQueryRequestResponses being emitted. Return null to drop query from the pipeline.
Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.dslQueryRequestResponse
- dslQueryRequestResponse going through query pipelinecontext
- query pipeline contextdefault void process(DslQueryRequestResponse dslQueryRequestResponse, Context context, java.util.function.Consumer<DslQueryRequestResponse> output)
DslQueryRequestResponse
instance that results in an
arbitrary number of dslQueryRequestResponses being emitted.
Call output.accept(dslQueryRequestResponse)
for each dslQueryRequestResponse you want to
emit as a result of processing. Note that after sending a dslQueryRequestResponse instance to the output, its
state may be changed by subsequent stages, therefore it is strongly advised to discard the
dslQueryRequestResponse instance immediately after emitting it. Passing null
to output
consumer will cause IllegalArgumentException
.
Overriding the default implementation of this method will result in process(DslQueryRequestResponse, Context)
to not be called. Default implementation is to call process(DslQueryRequestResponse, Context)
method.
Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.dslQueryRequestResponse
- dslQueryRequestResponse going through query pipelinecontext
- query pipeline contextoutput
- consumer for queryRequestResponses emitted as the result of processing