Class SimpleDocumentProcessor
- All Implemented Interfaces:
com.yahoo.component.chain.model.Chainable,com.yahoo.component.Component,com.yahoo.component.Deconstructable,Comparable<com.yahoo.component.Component>
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
-
Nested Class Summary
Nested classes/interfaces inherited from class com.yahoo.docproc.DocumentProcessor
DocumentProcessor.LaterProgress, DocumentProcessor.Progress -
Field Summary
Fields inherited from class com.yahoo.component.AbstractComponent
isDeconstructable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprocess(Processing processing) Simple process() that follows the official guidelines for looping overDocumentOperations, and then calls the appropriate, overloaded process() depending on the type of base.voidprocess(com.yahoo.document.DocumentPut put) Override this to process DocumentPuts.voidprocess(com.yahoo.document.DocumentRemove remove) Override this to process DocumentRemoves.voidprocess(com.yahoo.document.DocumentUpdate update) Override this to process DocumentUpdates.Methods inherited from class com.yahoo.docproc.DocumentProcessor
getDocMap, getFieldMap, setFieldMap, toStringMethods inherited from class com.yahoo.component.chain.ChainedComponent
getDependencies, initDependenciesMethods inherited from class com.yahoo.component.AbstractComponent
clone, compareTo, deconstruct, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructableMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.yahoo.component.chain.model.Chainable
getAnnotatedDependencies
-
Constructor Details
-
SimpleDocumentProcessor
public SimpleDocumentProcessor()
-
-
Method Details
-
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 aRuntimeException.- 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 aRuntimeException.- 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 aRuntimeException.- Parameters:
remove- the DocumentRemove to process.
-
process
Simple process() that follows the official guidelines for looping overDocumentOperations, 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 inProcessing.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:
processin classDocumentProcessor- Parameters:
processing- the Processing to process.- Returns:
- Progress.DONE, unless a subclass decides to throw an exception
-