Class EntityTimerProcessor

java.lang.Object
org.wikidata.wdtk.dumpfiles.EntityTimerProcessor
All Implemented Interfaces:
EntityDocumentDumpProcessor, EntityDocumentProcessor

public class EntityTimerProcessor extends Object implements EntityDocumentDumpProcessor
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
  • 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

      public void processItemDocument(ItemDocument itemDocument)
      Description copied from interface: EntityDocumentProcessor
      Processes the given ItemDocument.
      Specified by:
      processItemDocument in interface EntityDocumentProcessor
      Parameters:
      itemDocument - the ItemDocument
    • processPropertyDocument

      public void processPropertyDocument(PropertyDocument propertyDocument)
      Description copied from interface: EntityDocumentProcessor
      Processes the given PropertyDocument.
      Specified by:
      processPropertyDocument in interface EntityDocumentProcessor
      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 interface EntityDocumentDumpProcessor
    • close

      public void close()
      Stops the processing and prints the final time.
      Specified by:
      close in interface EntityDocumentDumpProcessor