dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21093
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9895: Analytics, validation on max table size
------------------------------------------------------------
revno: 9895
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-02-25 13:37:47 +0100
message:
Analytics, validation on max table size
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.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/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-02-25 12:09:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-02-25 12:37:47 +0000
@@ -70,6 +70,8 @@
public static final List<String> DATA_DIMS = Arrays.asList( INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID );
public static final List<String> FIXED_DIMS = Arrays.asList( DATA_X_DIM_ID, INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID, PERIOD_DIM_ID, ORGUNIT_DIM_ID );
+ public static final int MAX_DIM_OPT_PERM = 5000;
+
private static final List<DimensionType> COMPLETENESS_DIMENSION_TYTPES = Arrays.asList( DATASET, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET );
private static final DimensionOption[] DIM_OPT_ARR = new DimensionOption[0];
@@ -317,6 +319,21 @@
}
/**
+ * Returns the number of dimension option permutations.
+ */
+ public int getNumberOfDimensionOptionPermutations()
+ {
+ int total = 1;
+
+ for ( Dimension dim : dimensions )
+ {
+ total *= dim.getOptions().size();
+ }
+
+ return total;
+ }
+
+ /**
* Returns a mapping between identifier and period type for all data sets
* in this query.
*/
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-02-25 12:09:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-02-25 12:37:47 +0000
@@ -106,7 +106,7 @@
private static final String VALUE_HEADER_NAME = "Value";
private static final int PERCENT = 100;
- private static final int MAX_QUERIES = 6; //TODO increase?
+ private static final int MAX_QUERIES = 8; //TODO increase?
//TODO completeness on time
//TODO make sure data x dims are successive
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-02-21 18:18:15 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-02-25 12:37:47 +0000
@@ -36,6 +36,7 @@
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM;
import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_BOOL;
+import static org.hisp.dhis.analytics.DataQueryParams.MAX_DIM_OPT_PERM;
import java.util.ArrayList;
import java.util.Collection;
@@ -100,6 +101,11 @@
throw new IllegalQueryException( "Category option combos cannot be specified as filter" );
}
+ if ( params.getNumberOfDimensionOptionPermutations() > MAX_DIM_OPT_PERM )
+ {
+ throw new IllegalQueryException( "Table exceeds max number of cells: " + MAX_DIM_OPT_PERM );
+ }
+
//TODO check if any dimension occur more than once
}