use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryF.
/**
* Splits on 3 queries on organisation units for an optimal of 3 queries. No
* data elements specified.
*/
@Test
public void planQueryF() {
DataQueryParams params = DataQueryParams.newBuilder().withOrganisationUnits(getList(ouA, ouB, ouC, ouD, ouE)).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).withTableName(ANALYTICS_TABLE_NAME).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(3, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(3, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertTrue(samePartition(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryStartEndDateQueryGrouperB.
/**
* Splits in 4 queries for each period to satisfy optimal for a total
* of 4 queries, because all queries have different periods.
*/
@Test
public void planQueryStartEndDateQueryGrouperB() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB)).withOrganisationUnits(getList(ouA)).withFilterPeriods(getList(createPeriod("200101"), createPeriod("200102"), createPeriod("200103"), createPeriod("200104"))).build();
List<Function<DataQueryParams, List<DataQueryParams>>> queryGroupers = Lists.newArrayList();
queryGroupers.add(q -> queryPlanner.groupByStartEndDate(q));
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableName(ANALYTICS_TABLE_NAME).withQueryGroupers(queryGroupers).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
List<DataQueryParams> queries = queryGroups.getAllQueries();
assertEquals(2, queries.size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(2, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queries) {
assertNotNull(query.getStartDate());
assertNotNull(query.getEndDate());
assertDimensionNameNotNull(query);
assertNull(query.getFilter(PERIOD_DIM_ID));
}
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryM.
/**
* Query spans 1 partition. Splits on 2 queries for data types, then splits
* on 2 queries for data elements to satisfy optimal for a total of 4 queries.
*/
@Test
public 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).withTableName(ANALYTICS_TABLE_NAME).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()));
assertTrue(samePartition(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class QueryPlannerTest method validateFailureMultipleIndicatorsFilter.
@Test(expected = IllegalQueryException.class)
public void validateFailureMultipleIndicatorsFilter() {
DataQueryParams params = DataQueryParams.newBuilder().addDimension(new BaseDimensionalObject(ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, getList(ouA, ouB))).addDimension(new BaseDimensionalObject(PERIOD_DIM_ID, DimensionType.PERIOD, getList(peA, peB))).addFilter(new BaseDimensionalObject(DATA_X_DIM_ID, DimensionType.DATA_X, getList(inA, inB))).build();
queryPlanner.validate(params);
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryK.
/**
* Query spans 2 partitions. Splits in 2 queries for each partition, then
* splits in 2 queries on data sets to satisfy optimal for a total
* of 4 queries.
*/
@Test
public void planQueryK() {
DataQueryParams params = DataQueryParams.newBuilder().withReportingRates(getList(rrA, rrB, rrC, rrD)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD, ouE)).withPeriods(getList(createPeriod("2000Q1"), createPeriod("2000Q2"), createPeriod("2000Q3"), createPeriod("2000Q4"), createPeriod("2001Q1"), createPeriod("2001Q2"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableName(ANALYTICS_TABLE_NAME).build();
List<DataQueryParams> queries = queryPlanner.planQuery(params, plannerParams).getAllQueries();
assertEquals(4, queries.size());
for (DataQueryParams query : queries) {
assertTrue(samePeriodType(query.getPeriods()));
assertTrue(samePartition(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
Aggregations