dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12403
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3811: Minor performance improvement in datamart
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 3811 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-31 21:08:48 +0200
message:
Minor performance improvement in datamart
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.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
--
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-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2011-05-08 10:23:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2011-05-31 18:41:17 +0000
@@ -312,7 +312,7 @@
operandType = TYPE_TOTAL;
}
- DataElementOperand operand = new DataElementOperand();
+ final DataElementOperand operand = new DataElementOperand();
operand.setDataElementId( dataElementId );
operand.setOptionComboId( categoryOptionComboId );
operand.setOperandType( operandType );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2011-05-20 16:00:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2011-05-31 18:41:17 +0000
@@ -180,7 +180,7 @@
public String convertExpression( String expression, Map<Object, Integer> dataElementMapping, Map<Object, Integer> categoryOptionComboMapping )
{
- StringBuffer convertedFormula = new StringBuffer();
+ final StringBuffer convertedFormula = new StringBuffer();
if ( expression != null )
{
@@ -255,7 +255,7 @@
{
DataElementOperand operand = null;
- String match = matcher.group();
+ final String match = matcher.group();
if ( !DAYS_EXPRESSION.equals( match ) )
{
@@ -363,11 +363,11 @@
if ( operand.isTotal() )
{
- StringBuilder replace = new StringBuilder();
-
- DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() );
-
- DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo();
+ final StringBuilder replace = new StringBuilder();
+
+ final DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() );
+
+ final DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo();
for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryCombo.getOptionCombos() )
{
@@ -412,7 +412,7 @@
if ( aggregated )
{
- Double aggregatedValue = aggregatedDataValueService.getAggregatedDataValue( operand.getDataElementId(), operand.getOptionComboId(), period.getId(), source.getId() );
+ final Double aggregatedValue = aggregatedDataValueService.getAggregatedDataValue( operand.getDataElementId(), operand.getOptionComboId(), period.getId(), source.getId() );
value = aggregatedValue != null ? String.valueOf( aggregatedValue ) : null;
}
@@ -460,7 +460,7 @@
{
final DataElementOperand operand = DataElementOperand.getOperand( match );
- Double aggregatedValue = valueMap.get( operand );
+ final Double aggregatedValue = valueMap.get( operand );
match = ( aggregatedValue == null ) ? NULL_REPLACEMENT : String.valueOf( aggregatedValue );
}
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java 2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java 2011-05-31 19:07:15 +0000
@@ -119,8 +119,6 @@
double duration = 0.0;
double value = 0.0;
double relevantDays = 0.0;
- double existingValue = 0.0;
- double existingRelevantDays = 0.0;
int dataValueLevel = 0;
@@ -168,10 +166,11 @@
value = relevantDays;
}
- existingValue = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 0 ] : 0;
- existingRelevantDays = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 1 ] : 0;
+ final double[] totalSum = totalSums.get( entry.getKey() );
+ value += totalSum != null ? totalSum[0] : 0;
+ relevantDays += totalSum != null ? totalSum[1] : 0;
- final double[] values = { ( value + existingValue ), ( relevantDays + existingRelevantDays ) };
+ final double[] values = { value, relevantDays };
totalSums.put( entry.getKey(), values );
}
@@ -182,9 +181,9 @@
return totalSums;
}
- public Collection<DataElementOperand> filterOperands( Collection<DataElementOperand> operands, PeriodType periodType )
+ public Collection<DataElementOperand> filterOperands( final Collection<DataElementOperand> operands, final PeriodType periodType )
{
- Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
+ final Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
for ( final DataElementOperand operand : operands )
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java 2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java 2011-05-31 19:07:15 +0000
@@ -130,8 +130,6 @@
double value = 0.0;
double relevantDays = 0.0;
- double existingValue = 0.0;
- double existingRelevantDays = 0.0;
double duration = 0.0;
int dataValueLevel = 0;
@@ -189,11 +187,12 @@
}
value = value * relevantDays;
-
- existingValue = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 0 ] : 0;
- existingRelevantDays = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 1 ] : 0;
-
- final double[] values = { ( value + existingValue ), ( relevantDays + existingRelevantDays ) };
+
+ final double[] totalSum = totalSums.get( entry.getKey() );
+ value += totalSum != null ? totalSum[0] : 0;
+ relevantDays += totalSum != null ? totalSum[1] : 0;
+
+ final double[] values = { value, relevantDays };
totalSums.put( entry.getKey(), values );
}
@@ -204,9 +203,9 @@
return totalSums;
}
- public Collection<DataElementOperand> filterOperands( Collection<DataElementOperand> operands, PeriodType periodType )
+ public Collection<DataElementOperand> filterOperands( final Collection<DataElementOperand> operands, final PeriodType periodType )
{
- Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
+ final Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
for ( final DataElementOperand operand : operands )
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.java 2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.java 2011-05-31 19:07:15 +0000
@@ -118,8 +118,6 @@
double value = 0.0;
double relevantDays = 0.0;
- double existingValue = 0.0;
- double existingRelevantDays = 0.0;
double duration = 0.0;
int dataValueLevel = 0;
@@ -161,11 +159,12 @@
{
relevantDays = getDaysInclusive( startDate, endDate );
}
-
- existingValue = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 0 ] : 0;
- existingRelevantDays = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 1 ] : 0;
-
- final double[] values = { ( value + existingValue ), ( relevantDays + existingRelevantDays ) };
+
+ final double[] totalSum = totalSums.get( entry.getKey() );
+ value += totalSum != null ? totalSum[0] : 0;
+ relevantDays += totalSum != null ? totalSum[1] : 0;
+
+ final double[] values = { value, relevantDays };
totalSums.put( entry.getKey(), values );
}
@@ -176,9 +175,9 @@
return totalSums;
}
- public Collection<DataElementOperand> filterOperands( Collection<DataElementOperand> operands, PeriodType periodType )
+ public Collection<DataElementOperand> filterOperands( final Collection<DataElementOperand> operands, final PeriodType periodType )
{
- Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
+ final Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
for ( final DataElementOperand operand : operands )
{
=== 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-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java 2011-05-31 19:07:15 +0000
@@ -117,8 +117,6 @@
double value = 0.0;
double relevantDays = 0.0;
double factor = 0.0;
- double existingValue = 0.0;
- double existingRelevantDays = 0.0;
int dataValueLevel = 0;
@@ -172,11 +170,12 @@
}
value = value * factor;
-
- existingValue = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 0 ] : 0;
- existingRelevantDays = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 1 ] : 0;
- final double[] values = { ( value + existingValue ), ( relevantDays + existingRelevantDays ) };
+ final double[] totalSum = totalSums.get( entry.getKey() );
+ value += totalSum != null ? totalSum[0] : 0;
+ relevantDays += totalSum != null ? totalSum[1] : 0;
+
+ final double[] values = { value, relevantDays };
totalSums.put( entry.getKey(), values );
}
@@ -187,9 +186,9 @@
return totalSums;
}
- public Collection<DataElementOperand> filterOperands( Collection<DataElementOperand> operands, PeriodType periodType )
+ public Collection<DataElementOperand> filterOperands( final Collection<DataElementOperand> operands, final PeriodType periodType )
{
- Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
+ final Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
for ( final DataElementOperand operand : operands )
{
=== 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-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java 2011-05-31 19:07:15 +0000
@@ -119,8 +119,6 @@
double value = 0.0;
double relevantDays = 0.0;
double factor = 0.0;
- double existingValue = 0.0;
- double existingRelevantDays = 0.0;
double duration = 0.0;
int dataValueLevel = 0;
@@ -183,11 +181,12 @@
}
value = value * factor;
-
- existingValue = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 0 ] : 0;
- existingRelevantDays = totalSums.containsKey( entry.getKey() ) ? totalSums.get( entry.getKey() )[ 1 ] : 0;
-
- final double[] values = { ( value + existingValue ), ( relevantDays + existingRelevantDays ) };
+
+ final double[] totalSum = totalSums.get( entry.getKey() );
+ value += totalSum != null ? totalSum[0] : 0;
+ relevantDays += totalSum != null ? totalSum[1] : 0;
+
+ final double[] values = { value, relevantDays };
totalSums.put( entry.getKey(), values );
}
@@ -198,9 +197,9 @@
return totalSums;
}
- public Collection<DataElementOperand> filterOperands( Collection<DataElementOperand> operands, PeriodType periodType )
+ public Collection<DataElementOperand> filterOperands( final Collection<DataElementOperand> operands, final PeriodType periodType )
{
- Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
+ final Collection<DataElementOperand> filteredOperands = new HashSet<DataElementOperand>();
for ( final DataElementOperand operand : operands )
{