dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29488
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14909: Analytics, changed from List to Set for partitions method for slight performance improvement
------------------------------------------------------------
revno: 14909
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-04-19 10:06:02 +0200
message:
Analytics, changed from List to Set for partitions method for slight performance improvement
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java 2014-03-24 21:32:04 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java 2014-04-19 08:06:02 +0000
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
/**
* @author Lars Helge Overland
@@ -95,11 +96,11 @@
/**
* Prunes this instance so that it retains only the partitions included in
- * the given list. No operation takes place if the given list is null or empty.
+ * the given set. No operation takes place if the given set is null or empty.
*
- * @param validPartitions list of valid partitions to retain.
+ * @param validPartitions set of valid partitions to retain.
*/
- public Partitions prunePartitions( List<String> validPartitions )
+ public Partitions prunePartitions( Set<String> validPartitions )
{
if ( validPartitions != null && !validPartitions.isEmpty() )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java 2014-04-19 08:06:02 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.List;
+import java.util.Set;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.program.Program;
@@ -44,5 +44,5 @@
int getEventCount( EventQueryParams params );
- public List<String> getAnalyticsTables( Program program );
+ public Set<String> getAnalyticsTables( Program program );
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java 2014-04-19 07:47:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java 2014-04-19 08:06:02 +0000
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -123,7 +124,7 @@
@Override
public List<EventQueryParams> planAggregateQuery( EventQueryParams params )
{
- List<String> validPartitions = analyticsManager.getAnalyticsTables( params.getProgram() );
+ Set<String> validPartitions = analyticsManager.getAnalyticsTables( params.getProgram() );
List<EventQueryParams> queries = new ArrayList<EventQueryParams>();
@@ -145,7 +146,7 @@
@Override
public EventQueryParams planEventQuery( EventQueryParams params )
{
- List<String> validPartitions = analyticsManager.getAnalyticsTables( params.getProgram() );
+ Set<String> validPartitions = analyticsManager.getAnalyticsTables( params.getProgram() );
String tableSuffix = "_" + params.getProgram().getUid();
@@ -175,7 +176,7 @@
// Supportive methods
// -------------------------------------------------------------------------
- private List<EventQueryParams> groupByPartition( EventQueryParams params, List<String> validPartitions )
+ private List<EventQueryParams> groupByPartition( EventQueryParams params, Set<String> validPartitions )
{
String tableSuffix = "_" + params.getProgram().getUid();
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2014-04-19 07:47:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2014-04-19 08:06:02 +0000
@@ -39,7 +39,9 @@
import static org.hisp.dhis.system.util.TextUtils.trimEnd;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -297,7 +299,7 @@
return count;
}
- public List<String> getAnalyticsTables( Program program )
+ public Set<String> getAnalyticsTables( Program program )
{
final String sql =
"select table_name from information_schema.tables " +
@@ -306,7 +308,7 @@
log.info( "Information schema SQL: " + sql );
- return jdbcTemplate.queryForList( sql, String.class );
+ return new HashSet<String>( jdbcTemplate.queryForList( sql, String.class ) );
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2014-04-19 08:06:02 +0000
@@ -69,7 +69,7 @@
//TODO optimize by including required filter periods only
- public static Partitions getPartitions( Period period, String tablePrefix, String tableSuffix, List<String> validPartitions )
+ public static Partitions getPartitions( Period period, String tablePrefix, String tableSuffix, Set<String> validPartitions )
{
tablePrefix = StringUtils.trimToEmpty( tablePrefix );
tableSuffix = StringUtils.trimToEmpty( tableSuffix );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java 2014-04-19 08:06:02 +0000
@@ -35,7 +35,9 @@
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.analytics.Partitions;
import org.hisp.dhis.common.ListMap;
@@ -105,7 +107,7 @@
assertEquals( expected, PartitionUtils.getPartitions( period, TBL, null, null ) );
- List<String> validPartitions = new ArrayList<String>();
+ Set<String> validPartitions = new HashSet<String>();
validPartitions.add( TBL + "_2008" );
validPartitions.add( TBL + "_2010" );