Package org.intermine.sql.precompute
Class PrecomputedTable
- java.lang.Object
-
- org.intermine.sql.precompute.PrecomputedTable
-
- All Implemented Interfaces:
java.lang.Comparable<PrecomputedTable>
,SQLStringable
public class PrecomputedTable extends java.lang.Object implements SQLStringable, java.lang.Comparable<PrecomputedTable>
Represents a Precomputed table in a database. A precomputed table is a materialised SQL query. Note - the query encapsulated in this PrecomputedTable should not be altered.- Author:
- Andrew Varley
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
category
protected boolean
firstOrderByHasNoNulls
protected java.lang.String
generationSqlString
protected java.lang.String
name
static java.lang.String
ORDERBY_FIELD
The name of the field that is generated as the order by fieldprotected java.lang.String
orderByField
protected java.lang.String
originalSql
protected Query
q
protected java.util.Map<AbstractValue,SelectValue>
valueMap
-
Constructor Summary
Constructors Constructor Description PrecomputedTable(Query q, java.lang.String originalSql, java.lang.String name, java.lang.String category, java.sql.Connection conn)
Construct a new PrecomputedTable
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(PrecomputedTable obj)
Implements Comparable's method, so we can put PrecomputedTable objects into SortedMaps.boolean
equals(java.lang.Object obj)
Overrides Object.equals().java.lang.String
getCategory()
Returns the category of this PrecomputedTableboolean
getFirstOrderByHasNoNulls()
Returns true if the first element of the ORDER BY clause is a column that contains no nulls.java.lang.String
getName()
Gets the name of this PrecomputedTablejava.lang.String
getOrderByField()
Returns the name of the order by field, if it exists.java.lang.String
getOriginalSql()
Returns the original SQL text stored in the index for this PrecomputedTableQuery
getQuery()
Gets the Query that is materialised in this PrecomputedTablejava.lang.String
getSQLString()
Get a "CREATE TABLE" SQL statement for this PrecomputedTable.java.util.Map<AbstractValue,SelectValue>
getValueMap()
Gets a Map from AbstractValue to SelectValue for the Query in this PrecomputedTable.int
hashCode()
Overrides Object.hashCode().java.lang.String
toString()
-
-
-
Field Detail
-
ORDERBY_FIELD
public static final java.lang.String ORDERBY_FIELD
The name of the field that is generated as the order by field- See Also:
- Constant Field Values
-
q
protected Query q
-
originalSql
protected java.lang.String originalSql
-
name
protected java.lang.String name
-
category
protected java.lang.String category
-
valueMap
protected java.util.Map<AbstractValue,SelectValue> valueMap
-
orderByField
protected java.lang.String orderByField
-
generationSqlString
protected java.lang.String generationSqlString
-
firstOrderByHasNoNulls
protected boolean firstOrderByHasNoNulls
-
-
Constructor Detail
-
PrecomputedTable
public PrecomputedTable(Query q, java.lang.String originalSql, java.lang.String name, java.lang.String category, java.sql.Connection conn)
Construct a new PrecomputedTable- Parameters:
q
- the Query that this PrecomputedTable materialisesoriginalSql
- the original SQL text that appears in the index tablename
- the name of this PrecomputedTablecategory
- the type of PrecomputedTable this is. Note that a value of "template" denotes PrecomputedTables that are managed automatically by the webapp. Such tables are liable to be created and deleted at randomconn
- a Connection to use to work out if the order by fields are compatible with a unified orderby_field
-
-
Method Detail
-
getQuery
public Query getQuery()
Gets the Query that is materialised in this PrecomputedTable- Returns:
- the Query that this PrecomputedTable materialises
-
getOriginalSql
public java.lang.String getOriginalSql()
Returns the original SQL text stored in the index for this PrecomputedTable- Returns:
- an SQL String
-
getName
public java.lang.String getName()
Gets the name of this PrecomputedTable- Returns:
- the name of the PrecomputedTable
-
getCategory
public java.lang.String getCategory()
Returns the category of this PrecomputedTable- Returns:
- a String
-
getValueMap
public java.util.Map<AbstractValue,SelectValue> getValueMap()
Gets a Map from AbstractValue to SelectValue for the Query in this PrecomputedTable.- Returns:
- the valueMap
-
getSQLString
public java.lang.String getSQLString()
Get a "CREATE TABLE" SQL statement for this PrecomputedTable.- Specified by:
getSQLString
in interfaceSQLStringable
- Returns:
- this PrecomputedTable as an SQL statement
-
getOrderByField
public java.lang.String getOrderByField()
Returns the name of the order by field, if it exists.- Returns:
- orderByField
-
getFirstOrderByHasNoNulls
public boolean getFirstOrderByHasNoNulls()
Returns true if the first element of the ORDER BY clause is a column that contains no nulls.- Returns:
- a boolean
-
equals
public boolean equals(java.lang.Object obj)
Overrides Object.equals().- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- an Object to compare to- Returns:
- true if the object is equal
-
hashCode
public int hashCode()
Overrides Object.hashCode().- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- an arbitrary integer based on the contents of the Query and the name
-
compareTo
public int compareTo(PrecomputedTable obj)
Implements Comparable's method, so we can put PrecomputedTable objects into SortedMaps.- Specified by:
compareTo
in interfacejava.lang.Comparable<PrecomputedTable>
- Parameters:
obj
- an Object to compare to- Returns:
- an integer based on the comparison
- Throws:
java.lang.ClassCastException
- if obj is not a PrecomputedTable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-