private CdoSnapshot findLatestToInCommitTable(SnapshotReference reference) { final List<CdoSnapshot> found = new ArrayList<>(); iterateUntil(ce -> { if (ce.getAny(reference.targetId()) != null) { found.add(ce.getAny(reference.targetId())); } }, reference.timepointCommitId()); if (found.size() == 0) { return null; } else { return found.get(found.size() - 1); } }
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; }
private boolean isInChildValueObjectScope(SnapshotReference snapshotReference) { return query.isAggregate() && snapshotReference.targetId() instanceof ValueObjectId; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SnapshotReference that = (SnapshotReference) o; return Objects.equals(timepointCommitId(), timepointCommitId()) && Objects.equals(targetId, that.targetId); }
@Override public int hashCode() { return Objects.hash(timepointCommitId(), targetId); } }
private List<CdoSnapshot> getHistoricals(GlobalId globalId, SnapshotReference timePoint, boolean withChildValueObjects, int limit) { if (javersCoreConfiguration.getCommitIdGenerator() == CommitIdGenerator.SYNCHRONIZED_SEQUENCE){ return repository.getHistoricals(globalId, timePoint.timepointCommitId(), withChildValueObjects, limit); } return repository.getHistoricals(globalId, timePoint.timepoint().getCommitDate(), withChildValueObjects, limit); }