void loadFullCommits() { if (commitsMap.isEmpty()) { return; } QueryParams params = QueryParamsBuilder .withLimit(Integer.MAX_VALUE) .commitIds(commitsMap.keySet().stream().map(it -> it.getId()).collect(toSet())) .build(); List<CdoSnapshot> fullCommitsSnapshots = repository.getSnapshots(params); query.stats().logQueryInCommitDeepScope(fullCommitsSnapshots); appendSnapshots(fullCommitsSnapshots); }
List<Shadow> loadNextPage() { JqlQuery currentQuery = awaitingQuery; Pair<List<Shadow>, List<CdoSnapshot>> result = shadowQueryRunner.queryForShadows(currentQuery, filledGapsSnapshots); queries.add(currentQuery); queries.get(0).appendNextStatsForStream(currentQuery.stats()); filledGapsSnapshots.addAll(result.right()); awaitingQuery = currentQuery.nextQueryForStream(); return result.left(); }
private List<CdoSnapshot> queryForCoreSnapshots(JqlQuery query) { queryCompiler.compile(query); query.aggregateIfEntityQuery(); List<CdoSnapshot> snapshots = snapshotQueryRunner.queryForSnapshots(query); query.stats().logShallowQuery(snapshots); return snapshots; }
List<CdoSnapshot> fillGapFromRepository(SnapshotReference snapshotReference, int limit) { if (filledGapsCount >= maxGapsToFill && !isInChildValueObjectScope(snapshotReference)) { return Collections.emptyList(); } List<CdoSnapshot> historicals; if (isInChildValueObjectScope(snapshotReference)) { historicals = getHistoricals(snapshotReference.targetId(), snapshotReference, false, limit); query.stats().logQueryInChildValueObjectScope(snapshotReference.targetId(), snapshotReference.timepointCommitId(), historicals.size()); } else { historicals = getHistoricals(snapshotReference.targetId(), snapshotReference, query.isAggregate(), limit); query.stats().logQueryInDeepPlusScope(snapshotReference.targetId(), snapshotReference.timepointCommitId(), historicals.size()); } filledGapsCount++; filledGapsSnapshots.addAll(historicals); return historicals; }
CdoSnapshot referenceResolver(CommitMetadata rootContext, GlobalId targetId) { SnapshotReference reference = new SnapshotReference(rootContext, targetId); if (!commitsMap.containsKey(rootContext)) { return null; } CdoSnapshot latest = findLatestToInCommitTable(reference); if (latest == null) { appendSnapshots(fillGapFromRepository(reference, 15)); } latest = findLatestToInCommitTable(reference); if (latest == null){ query.stats().logMaxGapsToFillExceededInfo(targetId); } return latest; }
Pair<List<Shadow>, List<CdoSnapshot>> queryForShadows(JqlQuery query, List<CdoSnapshot> gapsFilledInPreviousQuery) { List<CdoSnapshot> coreSnapshots = queryForCoreSnapshots(query); CommitTable commitTable = new CommitTable( coreSnapshots, query.getMaxGapsToFill(), query); commitTable.appendSnapshots(gapsFilledInPreviousQuery); if (query.getShadowScope().isCommitDeep()) { commitTable.loadFullCommits(); } List<Shadow> shadows = commitTable.rootsForQuery(query).stream() .map(r -> shadowFactory.createShadow(r.root, r.context, (cm, targetId) -> commitTable.referenceResolver(cm, targetId))) .collect(toList()); query.stats().stop(); logger.debug("queryForShadows executed: {}", query); return new Pair(shadows, commitTable.getFilledGapsSnapshots()); }