Class PrefetchManager


  • public final class PrefetchManager
    extends java.lang.Object
    A manager for the prefetch mechanism for the Results object.
    Author:
    Matthew Wakeling
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int LOADING  
      protected static java.util.Set<org.intermine.objectstore.query.PrefetchManager.Request> pending
      Pending set of requests - always accessed inside a synchronise on sync.
      protected static java.util.Set<org.intermine.objectstore.query.PrefetchManager.Request> serviced
      Set of requests currently being serviced.
      protected static int serviceThreads  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addRequest​(ResultsBatches result, int batchNo, boolean optimise, boolean explain)
      Adds a request to the Set of pending requests, and wakes up a Thread to handle it.
      protected static java.util.List<java.lang.Object> doRequest​(org.intermine.objectstore.query.PrefetchManager.Request request)
      Returns the batch described by the request.
      static java.util.List<java.lang.Object> doRequest​(ResultsBatches result, int batchNo, boolean optimise, boolean explain)
      Returns when the given request is completed.
      protected static org.intermine.objectstore.query.PrefetchManager.Request getRequest()
      Returns a request for a thread to service.
      protected static void reportDone​(org.intermine.objectstore.query.PrefetchManager.Request request)
      Allows a system to report that it has finished servicing a particular request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pending

        protected static java.util.Set<org.intermine.objectstore.query.PrefetchManager.Request> pending
        Pending set of requests - always accessed inside a synchronise on sync.
      • serviced

        protected static java.util.Set<org.intermine.objectstore.query.PrefetchManager.Request> serviced
        Set of requests currently being serviced. This Set is not accessed inside a block synchronised on any global object, so it must be able to handle concurrent access.
      • serviceThreads

        protected static int serviceThreads
    • Method Detail

      • addRequest

        public static void addRequest​(ResultsBatches result,
                                      int batchNo,
                                      boolean optimise,
                                      boolean explain)
        Adds a request to the Set of pending requests, and wakes up a Thread to handle it.
        Parameters:
        result - a ResultsBatches object that is making the request
        batchNo - the batch number to be fetched
        optimise - true if queries should be optimised
        explain - true if this method should explain each query first
      • doRequest

        public static java.util.List<java.lang.Object> doRequest​(ResultsBatches result,
                                                                 int batchNo,
                                                                 boolean optimise,
                                                                 boolean explain)
                                                          throws ObjectStoreException
        Returns when the given request is completed. If the given request is not already being serviced, then this method will start servicing the request in the current thread.
        Parameters:
        result - a ResultsBatches object that is making the request
        batchNo - the batch number to be fetched
        optimise - true if queries should be optimised
        explain - true if this method should explain each query first
        Returns:
        a List containing the contents of the batch
        Throws:
        ObjectStoreException - if an error occurs in the underlying ObjectStore
        java.lang.IndexOutOfBoundsException - if the batch is off the end of the results
      • doRequest

        protected static java.util.List<java.lang.Object> doRequest​(org.intermine.objectstore.query.PrefetchManager.Request request)
                                                             throws ObjectStoreException
        Returns the batch described by the request. If the batch is not already available, then the current thread fetches it.
        Parameters:
        request - a Request object
        Returns:
        a List containing the contents of the batch
        Throws:
        ObjectStoreException - if an error occurs in the underlying ObjectStore
        java.lang.IndexOutOfBoundsException - if the batch is off the end of the results
      • reportDone

        protected static void reportDone​(org.intermine.objectstore.query.PrefetchManager.Request request)
        Allows a system to report that it has finished servicing a particular request.
        Parameters:
        request - the request that has been done
      • getRequest

        protected static org.intermine.objectstore.query.PrefetchManager.Request getRequest()
        Returns a request for a thread to service.
        Returns:
        a request to service