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); }
void stop() { validateChange(); endTimestamp = System.currentTimeMillis(); }
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; }
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()); }
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; }
void logQueryInCommitDeepScope(List<CdoSnapshot> snapshots) { validateChange(); logger.debug("COMMIT_DEEP query: {} snapshots loaded", snapshots.size()); dbQueriesCount++; allSnapshotsCount += snapshots.size(); commitDeepSnapshotsCount+=snapshots.size(); }
void logShallowQuery(List<CdoSnapshot> snapshots) { validateChange(); logger.debug("SHALLOW query: {} snapshots loaded (entities: {}, valueObjects: {})", snapshots.size(), snapshots.stream().filter(it -> it.getGlobalId() instanceof InstanceId).count(), snapshots.stream().filter(it -> it.getGlobalId() instanceof ValueObjectId).count()); dbQueriesCount++; allSnapshotsCount += snapshots.size(); shallowSnapshotsCount += snapshots.size(); }
void logQueryInChildValueObjectScope(GlobalId reference, CommitId context, int snapshotsLoaded) { validateChange(); logger.debug("CHILD_VALUE_OBJECT query for '{}' at timepointCommitId {}, {} snapshot(s) loaded", reference.toString(), context.value(), snapshotsLoaded); dbQueriesCount++; allSnapshotsCount += snapshotsLoaded; childVOSnapshotsCount += snapshotsLoaded; }
private List<CdoSnapshot> queryForCoreSnapshots(JqlQuery query) { queryCompiler.compile(query); query.aggregateIfEntityQuery(); List<CdoSnapshot> snapshots = snapshotQueryRunner.queryForSnapshots(query); query.stats().logShallowQuery(snapshots); return snapshots; }
void logQueryInDeepPlusScope(GlobalId reference, CommitId context, int snapshotsLoaded) { validateChange(); dbQueriesCount++; allSnapshotsCount += snapshotsLoaded; deepPlusSnapshotsCount += snapshotsLoaded; deepPlusGapsFilled++; logger.debug("DEEP_PLUS query for '{}' at timepointCommitId {}, {} snapshot(s) loaded, gaps filled so far: {}", reference.toString(), context.value(), snapshotsLoaded, deepPlusGapsFilled); }
void compile(GlobalIdFactory globalIdFactory, TypeMapper typeMapper) { stats = new Stats(); filter = filterDefinition.compile(globalIdFactory, typeMapper); validate(); }
void logMaxGapsToFillExceededInfo(GlobalId reference) { validateChange(); deepPlusGapsLeft++; logger.debug("warning: object '" + reference.toString() + "' is outside of the DEEP_PLUS+{} scope" + ", references to this object will be nulled. " + "Increase maxGapsToFill and fill all gaps in your object graph.", deepPlusGapsFilled); }