Class ObjectStoreTranslatingImpl

  • All Implemented Interfaces:
    ObjectStore

    public class ObjectStoreTranslatingImpl
    extends ObjectStoreAbstractImpl
    ObjectStore that transparently translates incoming queries and outgoing objects
    Author:
    Andrew Varley, Mark Woodbridge
    • Constructor Detail

      • ObjectStoreTranslatingImpl

        public ObjectStoreTranslatingImpl​(Model model,
                                          ObjectStore os,
                                          Translator translator)
        Constructor
        Parameters:
        model - the Model that this ObjectStore appears to use
        os - the underlying ObjectStore
        translator - 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 objectstore
        props - the properties used to configure the objectstore
        Returns:
        the ObjectStore
        Throws:
        java.lang.IllegalArgumentException - if props or model are invalid
        ObjectStoreException - 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 from execute(Query q).
        Parameters:
        q - the Query to execute
        start - the start row
        limit - the maximum number of rows to return
        optimise - true if it is expected that optimising the query will improve performance
        explain - true if the ObjectStore should enforce maximum query running time constraints
        sequence - 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 rows
        sequence - 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 interface ObjectStore
        Overrides:
        getObjectByExample in class ObjectStoreAbstractImpl
        Type Parameters:
        T - The actual type to return.
        Parameters:
        o - an example object
        fieldNames - 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 interface ObjectStore
        Overrides:
        getObjectsByExample in class ObjectStoreAbstractImpl
        Type Parameters:
        T - The actual type to return.
        Parameters:
        o - an example object
        fs - 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
      • 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