Control the Processing

In Java and Groovy, the evaluation of documents in the list of transformation and aggregation processors is:

  • Ordered: They are processed in the order they are defined.

  • Automatic: Processed documents are allowed to pass to the next processor or the next stage automatically without declaring a yield operation. However, you must yield explicitly all documents created inside a processor. Calls to delete operations are automatically yielded.

Since the document is automatically passed to the next processor or the next stage available in the processing pipeline, you must make a call to the discard method to prevent it from going further.

This method stops the pipelining. If the document was already present in the Consolidation Store, discarding it at the transformation phase does not delete it from the Consolidation Store. If you want to discard it and ask for deletion, you can add a delete operation in the processor where the discard operation occurs.

Important: As for the yield method, the discard method does not interrupt the runtime execution flow of your processor.

In the following code snippet, the code after discard is executed. If you want to interrupt the flow, you have to add a return; after the discard call. The documents to yield in an aggregation processor are the current processed document and, potentially the documents created during the process code execution.

Recommendation: Do not yield other documents that could have been grabbed using a match function. Doing so would lead to undefined behavior on the receiving end (Indexing Server for example).

@Override
public void process(final IJavaAllUpdatesAggregationHandler handler, final IAggregationDocument document)
 throws Exception {
  ...  if (someCondition) {
    ...    discard();
  }
  // Some other calls
  ...
}

For more code samples, see Discard Processor Code Samples.