Class ObjectStoreTranslatingImpl
- java.lang.Object
-
- org.intermine.objectstore.ObjectStoreAbstractImpl
-
- org.intermine.objectstore.translating.ObjectStoreTranslatingImpl
-
- All Implemented Interfaces:
ObjectStore
public class ObjectStoreTranslatingImpl extends ObjectStoreAbstractImpl
ObjectStore that transparently translates incoming queries and outgoing objects- Author:
- Andrew Varley, Mark Woodbridge
-
-
Field Summary
-
Fields inherited from class org.intermine.objectstore.ObjectStoreAbstractImpl
cache, getObjectHits, getObjectOps, getObjectPrefetches, maxLimit, maxOffset, maxQueryParseTime, maxTime, model, rand, sequenceKeys, sequenceNumber
-
Fields inherited from interface org.intermine.objectstore.ObjectStore
SEQUENCE_IGNORE
-
-
Constructor Summary
Constructors Constructor Description ObjectStoreTranslatingImpl(Model model, ObjectStore os, Translator translator)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
count(Query q, java.util.Map<java.lang.Object,java.lang.Integer> sequence)
Counts the number of rows the query will produceResultsInfo
estimate(Query q)
Explain a Query (give estimate for execution time and number of rows).java.util.List<ResultsRow<java.lang.Object>>
execute(Query q, int start, int limit, boolean optimise, boolean explain, java.util.Map<java.lang.Object,java.lang.Integer> sequence)
Execute a Query on this ObjectStore, asking for a certain range of rows to be returned.java.util.Set<java.lang.Object>
getComponentsForQuery(Query q)
Returns a Set of independent components that affect the results of the given Query.static ObjectStoreTranslatingImpl
getInstance(java.lang.String osAlias, java.util.Properties props)
Gets an ObjectStore for the given underlying properties.<T extends InterMineObject>
TgetObjectByExample(T o, java.util.Set<java.lang.String> fieldNames)
Return an object from the objectstore that has the fields mentioned in the list set to the same values as the fields in the provided example object.<T extends InterMineObject>
java.util.Collection<T>getObjectsByExample(T o, java.util.Set<java.lang.String> fs)
Return an object from the objectstore that has the fields mentioned in the list set to the same values as the fields in the provided example object.java.lang.Integer
getSerial()
Gets an ID number which is unique in the database.Translator
getTranslator()
Return the Translator that was passed to the constructor.InterMineObject
internalGetObjectById(java.lang.Integer id, java.lang.Class<? extends InterMineObject> clazz)
Internal service method for getObjectById.boolean
isMultiConnection()
Return whether or not this ObjectStore gives a performance improvement when multiple simultaneous are made.-
Methods inherited from class org.intermine.objectstore.ObjectStoreAbstractImpl
cacheObjectById, changeSequence, checkSequence, checkStartLimit, createClob, createObjectStoreBag, execute, execute, executeSingleton, executeSingleton, flushObjectById, getMaxLimit, getMaxOffset, getMaxQueryParseTime, getMaxTime, getModel, getModelFromClasspath, getNewWriter, getObjectById, getObjectById, getObjectsByIds, getSequence, invalidateObjectById, pilferObjectById, prefetchObjectById
-
-
-
-
Constructor Detail
-
ObjectStoreTranslatingImpl
public ObjectStoreTranslatingImpl(Model model, ObjectStore os, Translator translator)
Constructor- Parameters:
model
- the Model that this ObjectStore appears to useos
- the underlying ObjectStoretranslator
- the Translator used to translate queries and objects
-
-
Method Detail
-
getInstance
public static ObjectStoreTranslatingImpl getInstance(java.lang.String osAlias, java.util.Properties props) throws ObjectStoreException
Gets an ObjectStore for the given underlying properties.- Parameters:
osAlias
- the alias of this objectstoreprops
- the properties used to configure the objectstore- Returns:
- the ObjectStore
- Throws:
java.lang.IllegalArgumentException
- if props or model are invalidObjectStoreException
- if there is any problem with the instance
-
getTranslator
public Translator getTranslator()
Return the Translator that was passed to the constructor.- Returns:
- the Translator
-
execute
public java.util.List<ResultsRow<java.lang.Object>> execute(Query q, int start, int limit, boolean optimise, boolean explain, java.util.Map<java.lang.Object,java.lang.Integer> sequence) throws ObjectStoreException
Execute a Query on this ObjectStore, asking for a certain range of rows to be returned. This will usually only be called by the Results object returned fromexecute(Query q)
.- Parameters:
q
- the Query to executestart
- the start rowlimit
- the maximum number of rows to returnoptimise
- true if it is expected that optimising the query will improve performanceexplain
- true if the ObjectStore should enforce maximum query running time constraintssequence
- an object representing the state of the database corresponding to when the action that resulted in this execute was started. This number must match the ObjectStore's internal sequence number or a DataChangedException is thrown. The sequence number is incremented each time the data in the objectstore is changed- Returns:
- a List of ResultRows
- Throws:
ObjectStoreException
- if an error occurs during the running of the Query
-
estimate
public ResultsInfo estimate(Query q) throws ObjectStoreException
Explain a Query (give estimate for execution time and number of rows).- Parameters:
q
- the query to estimate rows for- Returns:
- parsed results of EXPLAIN
- Throws:
ObjectStoreException
- if an error occurs explaining the query
-
count
public int count(Query q, java.util.Map<java.lang.Object,java.lang.Integer> sequence) throws ObjectStoreException
Counts the number of rows the query will produce- Parameters:
q
- InterMine Query on which to count rowssequence
- an object representing the state of the database corresponding to when the action that resulted in this execute was started. This number must match the ObjectStore's internal sequence number or a DataChangedException is thrown. The sequence number is incremented each time the data in the objectstore is changed- Returns:
- the number of rows that will be produced by query
- Throws:
ObjectStoreException
- if an error occurs counting the query
-
getObjectByExample
public <T extends InterMineObject> T getObjectByExample(T o, java.util.Set<java.lang.String> fieldNames)
Description copied from interface:ObjectStore
Return an object from the objectstore that has the fields mentioned in the list set to the same values as the fields in the provided example object. If there are no objects in the objectstore like that, then this method returns null. If there are more than one object, then this method throws an IllegalArgumentException.- Specified by:
getObjectByExample
in interfaceObjectStore
- Overrides:
getObjectByExample
in classObjectStoreAbstractImpl
- Type Parameters:
T
- The actual type to return.- Parameters:
o
- an example objectfieldNames
- a Set of fieldnames- Returns:
- an InterMineObject from the objectstore, or null if none fits
-
getObjectsByExample
public <T extends InterMineObject> java.util.Collection<T> getObjectsByExample(T o, java.util.Set<java.lang.String> fs)
Description copied from interface:ObjectStore
Return an object from the objectstore that has the fields mentioned in the list set to the same values as the fields in the provided example object. If there are no objects in the objectstore like that, then this method returns null. If there are more than one object, then this method throws an IllegalArgumentException.- Specified by:
getObjectsByExample
in interfaceObjectStore
- Overrides:
getObjectsByExample
in classObjectStoreAbstractImpl
- Type Parameters:
T
- The actual type to return.- Parameters:
o
- an example objectfs
- a Set of fieldnames- Returns:
- zero or more InterMineObjects from the objectstore
-
isMultiConnection
public boolean isMultiConnection()
Return whether or not this ObjectStore gives a performance improvement when multiple simultaneous are made. Note that ALL Objectstore must be multi-threading safe. If this method returns true, then the ObjectStore probably handles multiple connections to the database. The Results class uses this to work out whether or not to do prefetching.- Returns:
- true if one should do multiple simultaneous operations
-
getComponentsForQuery
public java.util.Set<java.lang.Object> getComponentsForQuery(Query q)
Returns a Set of independent components that affect the results of the given Query.- Specified by:
getComponentsForQuery
in interfaceObjectStore
- Specified by:
getComponentsForQuery
in classObjectStoreAbstractImpl
- Parameters:
q
- a Query- Returns:
- a Set of objects
-
internalGetObjectById
public InterMineObject internalGetObjectById(java.lang.Integer id, java.lang.Class<? extends InterMineObject> clazz) throws ObjectStoreException
Internal service method for getObjectById.- Overrides:
internalGetObjectById
in classObjectStoreAbstractImpl
- Parameters:
id
- the ID of the object to getclazz
- a class of the object- Returns:
- an object from the database
- Throws:
ObjectStoreException
- if an error occurs during the running of the Query
-
getSerial
public java.lang.Integer getSerial() throws ObjectStoreException
Gets an ID number which is unique in the database.- Returns:
- an Integer
- Throws:
ObjectStoreException
- if a problem occurs
-
-