Package org.wikidata.wdtk.dumpfiles
Class EntityTimerProcessor
java.lang.Object
org.wikidata.wdtk.dumpfiles.EntityTimerProcessor
- All Implemented Interfaces:
EntityDocumentDumpProcessor
,EntityDocumentProcessor
Simple
EntityDocumentProcessor
for basic counting and time keeping.
It will print statistics on elapsed time and processed entities once in a
while. The class also supports a timeout mechanism: if a timeout time (in
seconds) is given, then a EntityTimerProcessor.TimeoutException
(unchecked) will be thrown soon after this many seconds have passed. This can
be used to abort processing in a relatively clean way by catching this
exception at a higher level.- Author:
- Markus Kroetzsch
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Stops the processing and prints the final time.void
open()
Starts the processing by performing any initial steps to prepare processing.void
processItemDocument
(ItemDocument itemDocument) Processes the given ItemDocument.void
processPropertyDocument
(PropertyDocument propertyDocument) Processes the given PropertyDocument.void
setReportInterval
(int seconds) Sets the interval after which the timer should report progress.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.wikidata.wdtk.datamodel.interfaces.EntityDocumentProcessor
processEntityRedirectDocument, processLexemeDocument, processMediaInfoDocument
-
Constructor Details
-
EntityTimerProcessor
public EntityTimerProcessor(int timeout) Constructor.- Parameters:
timeout
- the timeout in seconds or 0 if no timeout should be used
-
-
Method Details
-
setReportInterval
public void setReportInterval(int seconds) Sets the interval after which the timer should report progress. By default, this is ten seconds. When using a timeout, the timeout condition will only be checked at this interval, too, so using a very large value would lead to increasing imprecision with the timeout. The timer does not use a separate thread, and reports will only be generated after an entity was fully processed. Thus, very long processing times would also affect the accuracy of the interval.- Parameters:
seconds
- time after which progress should be reported.
-
processItemDocument
Description copied from interface:EntityDocumentProcessor
Processes the given ItemDocument.- Specified by:
processItemDocument
in interfaceEntityDocumentProcessor
- Parameters:
itemDocument
- the ItemDocument
-
processPropertyDocument
Description copied from interface:EntityDocumentProcessor
Processes the given PropertyDocument.- Specified by:
processPropertyDocument
in interfaceEntityDocumentProcessor
- Parameters:
propertyDocument
- the PropertyDocument
-
open
public void open()Description copied from interface:EntityDocumentDumpProcessor
Starts the processing by performing any initial steps to prepare processing.- Specified by:
open
in interfaceEntityDocumentDumpProcessor
-
close
public void close()Stops the processing and prints the final time.- Specified by:
close
in interfaceEntityDocumentDumpProcessor
-