← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3863: Minor performance improvement in indicator aggregation. No need to calculate numerator value if d...

 

------------------------------------------------------------
revno: 3863
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-06-10 11:19:09 +0200
message:
  Minor performance improvement in indicator aggregation. No need to calculate numerator value if denominator is 0.
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.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/indicator/DefaultIndicatorDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-06-05 16:40:02 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-06-10 09:19:09 +0000
@@ -135,36 +135,36 @@
                 {                
                     for ( final Indicator indicator : indicators )
                     {
-                        final double numeratorValue = calculateExpression( expressionService.generateExpression( indicator.getExplodedNumerator(), valueMap, days ) );                    
                         final double denominatorValue = calculateExpression( expressionService.generateExpression( indicator.getExplodedDenominator(), valueMap, days ) );
-    
-                        // ---------------------------------------------------------
-                        // AggregatedIndicatorValue
-                        // ---------------------------------------------------------
-    
-                        if ( denominatorValue != 0 && !( omitZeroNumerator && numeratorValue == 0 ) )
+
+                        if ( denominatorValue != 0 )
                         {
-                            final double annualizationFactor = DateUtils.getAnnualizationFactor( indicator, period.getStartDate(), period.getEndDate() );                            
-                            final double factor = indicator.getIndicatorType().getFactor();                            
-                            final double aggregatedValue = ( numeratorValue / denominatorValue ) * factor * annualizationFactor;                            
-                            final double annualizedFactor = factor * annualizationFactor;
-    
-                            indicatorValue.clear();
-                            
-                            indicatorValue.setIndicatorId( indicator.getId() );
-                            indicatorValue.setPeriodId( period.getId() );
-                            indicatorValue.setPeriodTypeId( periodType.getId() );
-                            indicatorValue.setOrganisationUnitId( unit.getId() );
-                            indicatorValue.setLevel( level );
-                            indicatorValue.setAnnualized( getAnnualizationString( indicator.getAnnualized() ) );
-                            indicatorValue.setFactor( annualizedFactor);
-                            indicatorValue.setValue( getRounded( aggregatedValue, DECIMALS ) );
-                            indicatorValue.setNumeratorValue( getRounded( numeratorValue, DECIMALS ) );
-                            indicatorValue.setDenominatorValue( getRounded( denominatorValue, DECIMALS ) );
-                            
-                            batchHandler.addObject( indicatorValue );
-                            
-                            count++;
+                            final double numeratorValue = calculateExpression( expressionService.generateExpression( indicator.getExplodedNumerator(), valueMap, days ) );
+                         
+                            if ( !( omitZeroNumerator && numeratorValue == 0 ) )
+                            {
+                                final double annualizationFactor = DateUtils.getAnnualizationFactor( indicator, period.getStartDate(), period.getEndDate() );                            
+                                final double factor = indicator.getIndicatorType().getFactor();                            
+                                final double aggregatedValue = ( numeratorValue / denominatorValue ) * factor * annualizationFactor;                            
+                                final double annualizedFactor = factor * annualizationFactor;
+        
+                                indicatorValue.clear();
+                                
+                                indicatorValue.setIndicatorId( indicator.getId() );
+                                indicatorValue.setPeriodId( period.getId() );
+                                indicatorValue.setPeriodTypeId( periodType.getId() );
+                                indicatorValue.setOrganisationUnitId( unit.getId() );
+                                indicatorValue.setLevel( level );
+                                indicatorValue.setAnnualized( getAnnualizationString( indicator.getAnnualized() ) );
+                                indicatorValue.setFactor( annualizedFactor);
+                                indicatorValue.setValue( getRounded( aggregatedValue, DECIMALS ) );
+                                indicatorValue.setNumeratorValue( getRounded( numeratorValue, DECIMALS ) );
+                                indicatorValue.setDenominatorValue( getRounded( denominatorValue, DECIMALS ) );
+                                
+                                batchHandler.addObject( indicatorValue );
+                                
+                                count++;
+                            }
                         }
                     }
                 }