Changeset 1142 for raptor-client


Ignore:
Timestamp:
09/27/11 19:30:50 (9 years ago)
Author:
philsmart
Message:
 
Location:
raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/runtimeutils/ReflectionHelper.java

    r1028 r1142  
    357357 
    358358    /** 
    359      * Code taken and adapted from the JWhich project. Finds all subclasses of the uk.ac.cardiff.model.Entry class in 
     359     * Code taken and adapted from the JWhich project. Finds all subclasses of the uk.ac.cardiff.model.Event class in 
    360360     * the package <code>pckgname</code> if they exist outside any JAR libraries, use 
    361361     * <code>getClasseNamesInPackageJAR</code> 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/store/dao/RaptorDataConnection.java

    r817 r1142  
    1717 * 
    1818 */ 
     19 
    1920package uk.ac.cardiff.raptor.store.dao; 
    2021 
     
    2627/** 
    2728 * @author philsmart 
    28  * 
     29 *  
    2930 */ 
    3031public interface RaptorDataConnection { 
    3132 
    32         public List runQuery(String query, Object[] parameters)  throws DataAccessException; 
    33         public Object runQueryUnique(String query, Object[] parameters)  throws DataAccessException; 
    34         public void save(Object object) throws DataAccessException; 
    35         public void deleteAllEntries(Collection entries) throws DataAccessException; 
    36         public void saveAll(Collection collection) throws DataAccessException; 
    37         public List runQuery(String query, Object[] parameters, int maxResultSize)throws DataAccessException; 
    38         public void runUpdate(String query, Object[] parameters)  throws DataAccessException; 
     33    public List runQuery(String query, Object[] parameters) throws DataAccessException; 
    3934 
     35    public Object runQueryUnique(String query, Object[] parameters) throws DataAccessException; 
    4036 
     37    public void save(Object object) throws DataAccessException; 
     38 
     39    public void deleteAllEntries(Collection<?> entries) throws DataAccessException; 
     40 
     41    public void saveAll(Collection<?> collection) throws DataAccessException; 
     42 
     43    public List runQuery(String query, Object[] parameters, int maxResultSize) throws DataAccessException; 
     44 
     45    public void runUpdate(String query, Object[] parameters) throws DataAccessException; 
    4146 
    4247} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/store/impl/PersistantEventHandler.java

    r1081 r1142  
    5555     */ 
    5656    private Set<Event> persistQueue; 
     57 
     58    /** 
     59     * If true, COUNT queries to the database are seperated per table as described in <code>countTableNames</code>. 
     60     * Otherwise a COUNT of the highest level <code>Event</code> class is issued which uses table joins to determine 
     61     * counts from all subclasses thereof. 
     62     */ 
     63    private boolean optimiseCountQueries; 
     64 
     65    /** 
     66     * The names of the classes used in count queries if <code>optimiseCountQueries</code> is set to true 
     67     */ 
     68    private List<String> countClassNames; 
    5769 
    5870    public PersistantEventHandler(RaptorDataConnection dataConnection) { 
     
    197209    } 
    198210 
     211    /** 
     212     * Retrieves the number of events stored by this persistent event handler. This is retrieved from the underlying 
     213     * persistent storage e.g. a database. The query can be separated to determine row counts from each individual table 
     214     * that is a subclass of Event before being summed together if the optimiseCountQueries is set to true - to speed up 
     215     * queries to certain database. Otherwise a fully automatic and higher level 'select count(*) from Event' is used 
     216     * where table joins are required to sum all subclasses of Event. 
     217     */ 
    199218    public long getNumberOfEvents() { 
    200         Object result = dataConnection.runQueryUnique("select count(*) from Event", null); 
    201         return (Long) result; 
     219        if (optimiseCountQueries == true) { 
     220            log.trace("Using optimised COUNT query, but dependent on the user defined countClassNames XML property"); 
     221            long count = 0; 
     222            if (countClassNames == null) { 
     223                log.error("Tried to compute Event count using optimised query, but no classes specified in mua-core.xml"); 
     224                return 0; 
     225            } 
     226            for (String className : countClassNames) { 
     227                Object result = dataConnection.runQueryUnique("select count(*) from " + className, null); 
     228                Long resultLong = (Long) result; 
     229                count += resultLong; 
     230            } 
     231            return count; 
     232        } else { 
     233            log.trace("Using joined COUNT query"); 
     234            Object result = dataConnection.runQueryUnique("select count(*) from Event", null); 
     235            return (Long) result; 
     236        } 
    202237    } 
    203238 
     
    217252    } 
    218253 
     254    /** 
     255     * @param optimiseCountQueries the optimiseCountQueries to set 
     256     */ 
     257    public void setOptimiseCountQueries(boolean optimiseCountQueries) { 
     258        this.optimiseCountQueries = optimiseCountQueries; 
     259    } 
     260 
     261    /** 
     262     * @return the optimiseCountQueries 
     263     */ 
     264    public boolean isOptimiseCountQueries() { 
     265        return optimiseCountQueries; 
     266    } 
     267 
     268    /** 
     269     * @param countClassNames the countClassNames to set 
     270     */ 
     271    public void setCountClassNames(List<String> countClassNames) { 
     272        this.countClassNames = countClassNames; 
     273    } 
     274 
     275    /** 
     276     * @return the countClassNames 
     277     */ 
     278    public List<String> getCountClassNames() { 
     279        return countClassNames; 
     280    } 
     281 
    219282} 
Note: See TracChangeset for help on using the changeset viewer.