use of org.hisp.dhis.analytics.DataQueryGroups in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryD.
/**
* Query spans 2 aggregation types. Splits on 2 aggregation types, then
* splits one query on 3 days in period to satisfy optimal for a total of 4
* queries.
*/
@Test
void planQueryD() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB, deC)).withOrganisationUnits(getList(ouA)).withPeriods(getList(createPeriod("200001"), createPeriod("200002"), createPeriod("200003"), createPeriod("200004"), createPeriod("200005"), createPeriod("200006"), createPeriod("200007"), createPeriod("200008"), createPeriod("200009"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(4, queryGroups.getAllQueries().size());
assertEquals(2, queryGroups.getSequentialQueries().size());
assertEquals(3, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
use of org.hisp.dhis.analytics.DataQueryGroups in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryA.
/**
* Query spans two period types and two aggregation types. Splits in 2
* queries for each period type, then splits in 4 queries on data elements
* to satisfy optimal of 4 queries per query group.
*/
@Test
void planQueryA() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB, deC, deD)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD, ouE)).withPeriods(getList(createPeriod("200101"), createPeriod("200103"), createPeriod("200105"), createPeriod("200107"), createPeriod("2002Q3"), createPeriod("2002Q4"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(8, queryGroups.getAllQueries().size());
assertEquals(2, queryGroups.getSequentialQueries().size());
assertEquals(4, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
use of org.hisp.dhis.analytics.DataQueryGroups in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryDataElementGroupSetDisaggregation.
/**
* Query is type disaggregation as aggregation period type for periods is
* monthly and data element groups period type is yearly. Split on two org
* units.
*/
@Test
void planQueryDataElementGroupSetDisaggregation() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElementGroupSet(dgsB).withOrganisationUnits(getList(ouA, ouB)).withPeriods(getList(createPeriod("201001"), createPeriod("201003"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(2, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(2, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
assertNotNull(query.getDataPeriodType());
assertEquals(yearly, query.getDataPeriodType());
assertTrue(query.isDisaggregation());
}
}
use of org.hisp.dhis.analytics.DataQueryGroups in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryDataElementDisaggregation.
/**
* Query is type disaggregation as aggregation period type for periods is
* monthly and data elements period type is yearly. Split on two data
* elements.
*/
@Test
void planQueryDataElementDisaggregation() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deI, deJ)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD)).withPeriods(getList(createPeriod("201001"), createPeriod("201003"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(4, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(4, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
assertNotNull(query.getDataPeriodType());
assertEquals(yearly, query.getDataPeriodType());
assertTrue(query.isDisaggregation());
}
}
use of org.hisp.dhis.analytics.DataQueryGroups in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryM.
/**
* Splits in 4 queries for data elements to satisfy optimal for a total of 4
* queries.
*/
@Test
void planQueryM() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB, deG, deH)).withOrganisationUnits(getList(ouA)).withPeriods(getList(createPeriod("200101"), createPeriod("200103"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(4, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(4, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
Aggregations