Class SimpleDocumentProcessor
- java.lang.Object
-
- com.yahoo.component.AbstractComponent
-
- com.yahoo.component.chain.ChainedComponent
-
- com.yahoo.docproc.DocumentProcessor
-
- com.yahoo.docproc.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
DocumentOperation
s inProcessing.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 aDocumentProcessor.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
, subclassDocumentProcessor
instead.- Author:
- Einar M R Rosenvinge, havardpe
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.yahoo.docproc.DocumentProcessor
DocumentProcessor.LaterProgress, DocumentProcessor.Progress
-
-
Constructor Summary
Constructors Constructor Description SimpleDocumentProcessor()
-
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 overDocumentOperation
s, 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.docproc.DocumentProcessor
getDocMap, getFieldMap, setFieldMap, toString
-
Methods inherited from class com.yahoo.component.chain.ChainedComponent
getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
-
-
-
-
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 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
public final DocumentProcessor.Progress process(Processing processing)
Simple process() that follows the official guidelines for looping overDocumentOperation
s, 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
DocumentOperation
s 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:
process
in classDocumentProcessor
- Parameters:
processing
- the Processing to process.- Returns:
- Progress.DONE, unless a subclass decides to throw an exception
-
-