Package com.complexible.common.rdf.rio
Class RDFStreamProcessor
- java.lang.Object
-
- com.complexible.common.rdf.rio.RDFStreamProcessor
-
public final class RDFStreamProcessor extends java.lang.ObjectStream processor that handles concurrent production of statements from multiple streams and passes the statements tohandlersor provides the results as aniteration(List, CancelCheck).- Since:
- 0.1
- Author:
- Michael Grove, Evren Sirin, Fernando Hernandez
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_HANDLER_COUNTstatic intDEFAULT_MAX_PARSER_COUNT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RDFStreamProcessoradd(RDFStream theStream)Adds a new stream to process.RDFStreamProcessoradd(java.lang.Iterable<RDFStream> theStreams)voidcancel(java.lang.String theCause)static RDFStreamProcessorcreate(CancelCheck check)RDFStreamProcessorexecutor(java.util.concurrent.ExecutorService theExecutor)Specifies the executor that will be used for processing.java.lang.ThrowablegetException(RDFStream theStream)RDFStreamProcessorhandler(RDFNamespaceHandler theNamespaceHandler)Specifies the namespace handler that will be used by this process.RDFStreamProcessorhandler(RDFStatementHandler.Factory theHandler)Specifies the factory that will be used to create handlers.static StatementIteratoriteration(java.util.List<RDFStream> theStreams, CancelCheck check)static voidmain(java.lang.String[] args)RDFStreamProcessormaxHandlers(int count)RDFStreamProcessormaxParsers(int count)RDFStreamProcessormonitorOutput(ProgressReporter reporter)RDFStreamProcessormonitorOutput(java.io.OutputStream theStream)Sets the output progress if progress should be reported ornullif progress should not be reported.voidpause()Pauses processing.voidprocess()Waits for the processing of streams to finish.java.util.Map<RDFStream,java.lang.Exception>processSilently()Waits for the processing of streams to finish and returns a mapping from the streams to exceptions.RDFStreamProcessorresizeHandlers(boolean value)voidresume()Resumes processing as soon as possible.
-
-
-
Method Detail
-
create
public static RDFStreamProcessor create(CancelCheck check)
-
iteration
public static StatementIterator iteration(java.util.List<RDFStream> theStreams, CancelCheck check)
-
handler
public RDFStreamProcessor handler(RDFStatementHandler.Factory theHandler)
Specifies the factory that will be used to create handlers. Multiple handlers may be created depending on the number of streams processed, number of available processors, etc.
-
handler
public RDFStreamProcessor handler(RDFNamespaceHandler theNamespaceHandler)
Specifies the namespace handler that will be used by this process. A single namespace handler is used for all the streams processed.
-
executor
public RDFStreamProcessor executor(java.util.concurrent.ExecutorService theExecutor)
Specifies the executor that will be used for processing.
-
monitorOutput
public RDFStreamProcessor monitorOutput(java.io.OutputStream theStream)
Sets the output progress if progress should be reported ornullif progress should not be reported. Passingnullvalue is preferred compared to passing an output stream that ignores its output so that we will avoid keeping track of progress completely.
-
monitorOutput
public RDFStreamProcessor monitorOutput(ProgressReporter reporter)
-
maxParsers
public RDFStreamProcessor maxParsers(int count)
-
maxHandlers
public RDFStreamProcessor maxHandlers(int count)
-
resizeHandlers
public RDFStreamProcessor resizeHandlers(boolean value)
-
add
public RDFStreamProcessor add(RDFStream theStream)
Adds a new stream to process. Processing might start immediately
-
add
public RDFStreamProcessor add(java.lang.Iterable<RDFStream> theStreams)
-
getException
public java.lang.Throwable getException(RDFStream theStream)
-
process
public void process() throws InvalidRDF, java.io.IOExceptionWaits for the processing of streams to finish. No more streams may be added to the processor after this function is called. An exception is thrown at the very end if there was an error processing any one of the streams.- Throws:
InvalidRDFjava.io.IOException
-
processSilently
public java.util.Map<RDFStream,java.lang.Exception> processSilently()
Waits for the processing of streams to finish and returns a mapping from the streams to exceptions. The map will be empty if there were no exceptions during processing. No more streams may be added to the processor after this function is called.
-
pause
public void pause()
Pauses processing. All parsing and processing tasks will block untilresume()is called.
-
resume
public void resume()
Resumes processing as soon as possible.
-
cancel
public void cancel(java.lang.String theCause)
-
main
public static void main(java.lang.String[] args)
-
-