Class QueryExecutor

  • Direct Known Subclasses:
    PathQueryExecutor, WebResultsExecutor

    public abstract class QueryExecutor
    extends java.lang.Object
    Common superclass of query executors that holds cache of pathToQueryNode maps per query. This cache is not just for performance, if a query hits the results cache a different pathToQueryNode map needs to be used because QueryNodes are not equals() to one another even if they represent the same class/field.
    Author:
    Richard Smith
    • Field Detail

      • queryToPathToQueryNode

        protected static java.util.Map<Query,​java.util.Map<java.lang.String,​QuerySelectable>> queryToPathToQueryNode
        A cache of pathToQueryNode maps that is shared between subclasses of QueryExecutor. The maps are needed to link paths in path queries to objects in the underlying ObjectStore results.
      • summaryBatchSize

        protected int summaryBatchSize
      • profile

        protected Profile profile
        The profile to use to find bags from.
    • Constructor Detail

      • QueryExecutor

        public QueryExecutor()
    • Method Detail

      • makeSummaryQuery

        public Query makeSummaryQuery​(PathQuery pathQuery,
                                      java.lang.String summaryPath,
                                      boolean asOccurrances)
                               throws ObjectStoreException
        Creates a query that returns the summary for a column in a PathQuery. The format of the results is as follows:
        • For non-numeric types:
          1. The item
          2. The count of occurrences of this item
        • For numeric types:
          1. Minimum Value
          2. Maximum Value
          3. Average
          4. Standard Deviation
        Parameters:
        pathQuery - the query to convert
        summaryPath - the column to summarise
        asOccurrances - If true, will only return the list of values and their counts.
        Returns:
        an IQL Query object
        Throws:
        ObjectStoreException - if there is a problem creating the query
      • makeSummaryQuery

        public Query makeSummaryQuery​(PathQuery pathQuery,
                                      java.lang.String summaryPath)
                               throws ObjectStoreException
        Parameters:
        pathQuery - the query to summarise
        summaryPath - the column to summarise
        Returns:
        a Results object with varying styles of data
        Throws:
        ObjectStoreException - if there is a problem creating the query
      • makeSummaryQuery

        public Query makeSummaryQuery​(PathQuery pq,
                                      java.lang.String summaryPath,
                                      java.lang.String filterTerm,
                                      boolean asOccurrances)
                               throws ObjectStoreException
        Creates a query that returns the summary for a column in a PathQuery, applying a filter at the database level.
        Parameters:
        filterTerm - what to filter by
        asOccurrances - If true, will only return the list of values and their counts.
        pq - the query to convert
        summaryPath - the column to summarise
        Returns:
        an IQL Query object
        Throws:
        ObjectStoreException - if there is a problem creating the query
      • summariseQuery

        public Results summariseQuery​(PathQuery pathQuery,
                                      java.lang.String summaryPath,
                                      boolean asOccurrances)
                               throws ObjectStoreException
        Returns the results for a summary for a column in a PathQuery. The format of the results is as follows:
        • For non-numeric types:
          1. The item
          2. The count of occurrences of this item
        • For numeric types:
          1. Minimum Value
          2. Maximum Value
          3. Average
          4. Standard Deviation
        Parameters:
        pathQuery - the query to summarise
        summaryPath - the column to summarise
        asOccurrances - If true, will only return the list of values and their counts.
        Returns:
        a Results object with varying styles of data
        Throws:
        ObjectStoreException - if there is a problem summarising
      • summariseQuery

        public Results summariseQuery​(PathQuery pathQuery,
                                      java.lang.String summaryPath)
                               throws ObjectStoreException
        Parameters:
        pathQuery - The query to execute.
        summaryPath - The path whose unique column value count we want.
        Returns:
        A set of results.
        Throws:
        ObjectStoreException - If there is a problem making the query.
      • summariseQuery

        public Results summariseQuery​(PathQuery pq,
                                      java.lang.String summaryPath,
                                      java.lang.String filterTerm,
                                      boolean asOccurrances)
                               throws ObjectStoreException
        Summarise a query.
        Parameters:
        pq - The query to summarise
        summaryPath - The path of the query to focus on.
        filterTerm - An optional term to further filter by.
        asOccurrances - If true, will only return the list of values and their counts.
        Returns:
        A set of results.
        Throws:
        ObjectStoreException - in case of Ragnarok.
      • count

        public int count​(PathQuery pathQuery)
                  throws ObjectStoreException
        Take a query and return the results row count.
        Parameters:
        pathQuery - the query to count
        Returns:
        the number of rows returned
        Throws:
        ObjectStoreException - if there is a problem counting the query
      • uniqueColumnValues

        public int uniqueColumnValues​(PathQuery pq,
                                      java.lang.String path)
                               throws ObjectStoreException
        Get the the total number of unique column values for a given path in the context of a given query. eg:
           int count = ex.uniqueColumnValues(pq, "Gene.symbol");
         
        Parameters:
        pq - The query to execute.
        path - The path whose unique column value count we want.
        Returns:
        The number of different values this path can have.
        Throws:
        ObjectStoreException - If there is a problem making the query.
      • makeQuery

        public abstract Query makeQuery​(PathQuery pathQuery)
                                 throws ObjectStoreException
        Make an InterMine Query object from a PathQuery.
        Parameters:
        pathQuery - The path query.
        Returns:
        The internal Query representation.
        Throws:
        ObjectStoreException - If there is a problem making the query.
      • updateQueryToPathToQueryNode

        public void updateQueryToPathToQueryNode​(Query q,
                                                 java.util.Map<java.lang.String,​QuerySelectable> pathToQueryNode)
        Update the map to query queryToPathToQueryNode
        Parameters:
        q - The query.
        pathToQueryNode - the pathToQueryNode