Class SimpleDocumentProcessor

  • All Implemented Interfaces:
    com.yahoo.component.Component, java.lang.Comparable<com.yahoo.component.Component>

    public class SimpleDocumentProcessor
    extends DocumentProcessor

    Simple layer on top of DocumentProcessor, in order to make docproc development more user friendly and to the point.

    This simply iterates over the DocumentOperations in Processing.getDocumentOperations(), and calls the appropriate process() method given by this class.

    Note that more sophisticated use cases should subclass DocumentProcessor instead. Specifically, it is not possible to return a DocumentProcessor.LaterProgress from any of the process() methods that SimpleDocumentProcessor provides - since their return type is void.

    SimpleDocumentProcessor is for the simple cases. For complete control over document processing, like returning instances of DocumentProcessor.LaterProgress, subclass DocumentProcessor instead.

    Author:
    Einar M R Rosenvinge, havardpe
    • Field Summary

      • Fields inherited from class com.yahoo.component.AbstractComponent

        isDeconstructable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DocumentProcessor.Progress process​(Processing processing)
      Simple process() that follows the official guidelines for looping over DocumentOperations, and then calls the appropriate, overloaded process() depending on the type of base.
      void process​(com.yahoo.document.DocumentPut put)
      Override this to process DocumentPuts.
      void process​(com.yahoo.document.DocumentRemove remove)
      Override this to process DocumentRemoves.
      void process​(com.yahoo.document.DocumentUpdate update)
      Override this to process DocumentUpdates.
      • Methods inherited from class com.yahoo.component.chain.ChainedComponent

        getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
      • Methods inherited from class com.yahoo.component.AbstractComponent

        clone, compareTo, deconstruct, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SimpleDocumentProcessor

        public SimpleDocumentProcessor()
    • Method Detail

      • process

        public void process​(com.yahoo.document.DocumentPut put)
        Override this to process DocumentPuts. If this method is not overridden, the implementation in this class will ignore DocumentPuts (passing them through un-processed). If processing of this DocumentPut fails, the implementation must throw a RuntimeException.
        Parameters:
        put - the DocumentPut to process.
      • process

        public void process​(com.yahoo.document.DocumentUpdate update)
        Override this to process DocumentUpdates. If this method is not overridden, the implementation in this class will ignore DocumentUpdates (passing them through un-processed). If processing of this DocumentUpdate fails, the implementation must throw a RuntimeException.
        Parameters:
        update - the DocumentUpdate to process.
      • process

        public void process​(com.yahoo.document.DocumentRemove remove)
        Override this to process DocumentRemoves. If this method is not overridden, the implementation in this class will ignore DocumentRemoves (passing them through un-processed). If processing of this DocumentRemove fails, the implementation must throw a RuntimeException.
        Parameters:
        remove - the DocumentRemove to process.
      • process

        public final DocumentProcessor.Progress process​(Processing processing)
        Simple process() that follows the official guidelines for looping over DocumentOperations, and then calls the appropriate, overloaded process() depending on the type of base.

        Declared as final, so if you want to handle everything yourself you should of course extend DocumentProcessor instead of SimpleDocumentProcessor and just go about as usual.

        It is important to note that when iterating over the DocumentOperations in Processing.getDocumentOperations(), an exception thrown from any of the process() methods provided by this class will be thrown straight out of this here. This means that failing one document will fail the entire batch.

        Specified by:
        process in class DocumentProcessor
        Parameters:
        processing - the Processing to process.
        Returns:
        Progress.DONE, unless a subclass decides to throw an exception