Class QueryTimeoutImpl

java.lang.Object
org.apache.lucene.index.QueryTimeoutImpl
All Implemented Interfaces:
QueryTimeout

public class QueryTimeoutImpl extends Object implements QueryTimeout
An implementation of QueryTimeout that can be used by the ExitableDirectoryReader class to time out and exit out when a query takes a long time to rewrite.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Long
    The local variable to store the time beyond which, the processing should exit.
  • Constructor Summary

    Constructors
    Constructor
    Description
    QueryTimeoutImpl(long timeAllowed)
    Sets the time at which to time out by adding the given timeAllowed to the current time.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns time at which to time out, in nanoseconds relative to the (JVM-specific) epoch for System.nanoTime(), to compare with the value returned by nanoTime().
    void
    Reset the timeout value.
    boolean
    Return true if reset() has not been called and the elapsed time has exceeded the time allowed.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • timeoutAt

      private Long timeoutAt
      The local variable to store the time beyond which, the processing should exit.
  • Constructor Details

    • QueryTimeoutImpl

      public QueryTimeoutImpl(long timeAllowed)
      Sets the time at which to time out by adding the given timeAllowed to the current time.
      Parameters:
      timeAllowed - Number of milliseconds after which to time out. Use Long.MAX_VALUE to effectively never time out.
  • Method Details

    • getTimeoutAt

      public Long getTimeoutAt()
      Returns time at which to time out, in nanoseconds relative to the (JVM-specific) epoch for System.nanoTime(), to compare with the value returned by nanoTime().
    • shouldExit

      public boolean shouldExit()
      Return true if reset() has not been called and the elapsed time has exceeded the time allowed.
      Specified by:
      shouldExit in interface QueryTimeout
    • reset

      public void reset()
      Reset the timeout value.
    • toString

      public String toString()
      Overrides:
      toString in class Object