Package org.intermine.api.query
Class QueryExecutor
- java.lang.Object
-
- org.intermine.api.query.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 Summary
Fields Modifier and Type Field Description protected BagManager
bagManager
protected BagQueryRunner
bagQueryRunner
protected ObjectStore
os
protected Profile
profile
The profile to use to find bags from.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.protected int
summaryBatchSize
-
Constructor Summary
Constructors Constructor Description QueryExecutor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
count(PathQuery pathQuery)
Take a query and return the results row count.abstract Query
makeQuery(PathQuery pathQuery)
Make an InterMine Query object from a PathQuery.Query
makeSummaryQuery(PathQuery pathQuery, java.lang.String summaryPath)
Query
makeSummaryQuery(PathQuery pathQuery, java.lang.String summaryPath, boolean asOccurrances)
Creates a query that returns the summary for a column in a PathQuery.Query
makeSummaryQuery(PathQuery pq, java.lang.String summaryPath, java.lang.String filterTerm, boolean asOccurrances)
Creates a query that returns the summary for a column in a PathQuery, applying a filter at the database level.Results
summariseQuery(PathQuery pathQuery, java.lang.String summaryPath)
Results
summariseQuery(PathQuery pathQuery, java.lang.String summaryPath, boolean asOccurrances)
Returns the results for a summary for a column in a PathQuery.Results
summariseQuery(PathQuery pq, java.lang.String summaryPath, java.lang.String filterTerm, boolean asOccurrances)
Summarise a query.int
uniqueColumnValues(PathQuery pq, java.lang.String path)
Get the the total number of unique column values for a given path in the context of a given query.void
updateQueryToPathToQueryNode(Query q, java.util.Map<java.lang.String,QuerySelectable> pathToQueryNode)
Update the map to query queryToPathToQueryNode
-
-
-
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.
-
bagManager
protected BagManager bagManager
-
bagQueryRunner
protected BagQueryRunner bagQueryRunner
-
os
protected ObjectStore os
-
-
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:
- The item
- The count of occurrences of this item
- For numeric types:
- Minimum Value
- Maximum Value
- Average
- Standard Deviation
- Parameters:
pathQuery
- the query to convertsummaryPath
- the column to summariseasOccurrances
- 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 summarisesummaryPath
- 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 byasOccurrances
- If true, will only return the list of values and their counts.pq
- the query to convertsummaryPath
- 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:
- The item
- The count of occurrences of this item
- For numeric types:
- Minimum Value
- Maximum Value
- Average
- Standard Deviation
- Parameters:
pathQuery
- the query to summarisesummaryPath
- the column to summariseasOccurrances
- 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 summarisesummaryPath
- 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
-
-