dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14130
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4679: Data mart, improved performance, exploiting the fact that disaggregation of sum data element valu...
------------------------------------------------------------
revno: 4679
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-09-24 22:57:32 +0200
message:
Data mart, improved performance, exploiting the fact that disaggregation of sum data element values are not allowed, 9% down.
modified:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/AggregationCache.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/MemoryAggregationCache.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.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-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/AggregationCache.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/AggregationCache.java 2010-06-17 22:42:56 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/AggregationCache.java 2011-09-24 20:57:32 +0000
@@ -40,6 +40,8 @@
{
Collection<Integer> getIntersectingPeriods( Date startDate, Date endDate );
+ Collection<Integer> getPeriodsBetweenDates( final Date startDate, final Date endDate );
+
Period getPeriod( int id );
int getLevelOfOrganisationUnit( int id );
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/MemoryAggregationCache.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/MemoryAggregationCache.java 2010-07-04 10:31:31 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/MemoryAggregationCache.java 2011-09-24 20:57:32 +0000
@@ -51,6 +51,8 @@
private final ThreadLocal<Map<String, Collection<Integer>>> intersectingPeriodCache = new ThreadLocal<Map<String,Collection<Integer>>>();
+ private final ThreadLocal<Map<String, Collection<Integer>>> periodBetweenCache = new ThreadLocal<Map<String,Collection<Integer>>>();
+
private final ThreadLocal<Map<String, Period>> periodCache = new ThreadLocal<Map<String,Period>>();
private final ThreadLocal<Map<String, Integer>> organisationUnitLevelCache = new ThreadLocal<Map<String, Integer>>();
@@ -100,6 +102,30 @@
return periods;
}
+
+ public Collection<Integer> getPeriodsBetweenDates( final Date startDate, final Date endDate )
+ {
+ final String key = startDate.toString() + SEPARATOR + endDate.toString();
+
+ Map<String, Collection<Integer>> cache = periodBetweenCache.get();
+
+ Collection<Integer> periods = null;
+
+ if ( cache != null && ( periods = cache.get( key ) ) != null )
+ {
+ return periods;
+ }
+
+ periods = ConversionUtils.getIdentifiers( Period.class, periodService.getPeriodsBetweenDates( startDate, endDate ) );
+
+ cache = ( cache == null ) ? new HashMap<String, Collection<Integer>>() : cache;
+
+ cache.put( key, periods );
+
+ periodBetweenCache.set( cache );
+
+ return periods;
+ }
public Period getPeriod( final int id )
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java 2011-05-31 20:50:19 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java 2011-09-24 20:57:32 +0000
@@ -95,7 +95,7 @@
for ( final Entry<DataElementOperand, double[]> entry : entries.entrySet() )
{
- if ( entry.getValue() != null && entry.getValue()[ 1 ] > 0 )
+ if ( entry.getValue() != null )
{
values.put( entry.getKey(), getFloor( entry.getValue()[ 0 ] ) );
}
@@ -126,46 +126,16 @@
{
if ( entry.getValue() != null && entry.getKey().aggregationLevelIsValid( unitLevel, dataValueLevel ) )
{
- double value = 0.0;
- double relevantDays = 0.0;
- double factor = 0.0;
-
- if ( currentStartDate.compareTo( startDate ) >= 0 && currentEndDate.compareTo( endDate ) <= 0 ) // Value is within period
- {
- relevantDays = getDaysInclusive( startDate, endDate );
- factor = 1;
- }
- else if ( currentStartDate.compareTo( startDate ) <= 0 && currentEndDate.compareTo( endDate ) >= 0 ) // Value spans whole period
- {
- relevantDays = getDaysInclusive( startDate, endDate );
- factor = relevantDays / duration;
- }
- else if ( currentStartDate.compareTo( startDate ) <= 0 && currentEndDate.compareTo( startDate ) >= 0
- && currentEndDate.compareTo( endDate ) <= 0 ) // Value spans period start
- {
- relevantDays = getDaysInclusive( startDate, currentEndDate );
- factor = relevantDays / duration;
- }
- else if ( currentStartDate.compareTo( startDate ) >= 0 && currentStartDate.compareTo( endDate ) <= 0
- && currentEndDate.compareTo( endDate ) >= 0 ) // Value spans period end
- {
- relevantDays = getDaysInclusive( currentStartDate, endDate );
- factor = relevantDays / duration;
- }
+ double value = 0.0;
if ( entry.getValue().toLowerCase().equals( TRUE ) )
{
value = 1;
}
- value = value * factor;
-
final double[] totalSum = totalSums.get( entry.getKey() );
- value += totalSum != null ? totalSum[0] : 0;
- relevantDays += totalSum != null ? totalSum[1] : 0;
-
- final double[] values = { value, relevantDays };
-
+ value += totalSum != null ? totalSum[0] : 0;
+ final double[] values = { value, 0 };
totalSums.put( entry.getKey(), values );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java 2011-05-31 20:50:19 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java 2011-09-24 20:57:32 +0000
@@ -89,7 +89,7 @@
}
final Collection<CrossTabDataValue> crossTabValues = crossTabService.getCrossTabDataValues( operands,
- aggregationCache.getIntersectingPeriods( period.getStartDate(), period.getEndDate() ), hierarchy.getChildren( unit.getId() ), key );
+ aggregationCache.getPeriodsBetweenDates( period.getStartDate(), period.getEndDate() ), hierarchy.getChildren( unit.getId() ), key );
final Map<DataElementOperand, double[]> entries = getAggregate( crossTabValues, period.getStartDate(),
period.getEndDate(), period.getStartDate(), period.getEndDate(), unitLevel ); // <Operand, [total value, total relevant days]>
@@ -98,7 +98,7 @@
for ( final Entry<DataElementOperand, double[]> entry : entries.entrySet() )
{
- if ( entry.getValue() != null && entry.getValue()[ 1 ] > 0 )
+ if ( entry.getValue() != null )
{
values.put( entry.getKey(), entry.getValue()[ 0 ] );
}
@@ -130,8 +130,6 @@
if ( entry.getValue() != null && entry.getKey().aggregationLevelIsValid( unitLevel, dataValueLevel ) )
{
double value = 0.0;
- double relevantDays = 0.0;
- double factor = 0.0;
try
{
@@ -146,37 +144,9 @@
continue;
}
- if ( currentStartDate.compareTo( startDate ) >= 0 && currentEndDate.compareTo( endDate ) <= 0 ) // Value is within period
- {
- relevantDays = getDaysInclusive( startDate, endDate );
- factor = 1;
- }
- else if ( currentStartDate.compareTo( startDate ) <= 0 && currentEndDate.compareTo( endDate ) >= 0 ) // Value spans whole period
- {
- relevantDays = getDaysInclusive( startDate, endDate );
- factor = relevantDays / duration;
- }
- else if ( currentStartDate.compareTo( startDate ) <= 0 && currentEndDate.compareTo( startDate ) >= 0
- && currentEndDate.compareTo( endDate ) <= 0 ) // Value spans period start
- {
- relevantDays = getDaysInclusive( startDate, currentEndDate );
- factor = relevantDays / duration;
- }
- else if ( currentStartDate.compareTo( startDate ) >= 0 && currentStartDate.compareTo( endDate ) <= 0
- && currentEndDate.compareTo( endDate ) >= 0 ) // Value spans period end
- {
- relevantDays = getDaysInclusive( currentStartDate, endDate );
- factor = relevantDays / duration;
- }
-
- value = value * factor;
-
final double[] totalSum = totalSums.get( entry.getKey() );
- value += totalSum != null ? totalSum[0] : 0;
- relevantDays += totalSum != null ? totalSum[1] : 0;
-
- final double[] values = { value, relevantDays };
-
+ value += totalSum != null ? totalSum[0] : 0;
+ final double[] values = { value, 0 };
totalSums.put( entry.getKey(), values );
}
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2011-09-24 20:57:32 +0000
@@ -94,4 +94,14 @@
{
return password != null && password.length() >= 5 && password.length() < 50;
}
+
+ /**
+ * Validates whether a coordinate is valid.
+ *
+ * @return true if the coordinate is valid, false otherwise.
+ */
+ public static boolean validateGeoCoordinates( String coordinate )
+ {
+ return true;
+ }
}