private boolean isAggregationDataComplete(TimePeriod.Duration parentDuration, TimePeriod.Duration childDuration,
            Long endOFLatestEventTimestamp, Long lastData) {
        OnDemandQuery onDemandQuery = getOnDemandQuery(aggregationTables.get(childDuration), true,
                endOFLatestEventTimestamp, true, OrderByAttribute.Order.ASC);
        onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.FIND);
        OnDemandQueryRuntime onDemandQueryRuntime = OnDemandQueryParser.parse(onDemandQuery, null, siddhiAppContext,
                tableMap, windowMap, aggregationMap);
        Event[] events = onDemandQueryRuntime.execute();
        if (lastData == null && events == null) {
            return true;
        } else if (lastData == null
                && (Long) events[events.length - 1].getData(0) >= IncrementalTimeConverterUtil.getStartTimeOfAggregates(
                System.currentTimeMillis(), parentDuration, timeZone)) {
            return true;

        }

        return events == null || events.length == 0;
    }
This class is used to recreate in-memory data from the tables (Such as RDBMS) in incremental aggregation.
This ensures that the aggregation calculations are done correctly in case of server restart.
modules/siddhi-core/src/main/java/io/siddhi/core/aggregation/IncrementalExecutorsInitialiser.java