for (final DependencyNode unchangedNode : deltaCalculator.getUnchangedNodes()) {
if (unchangedNode.isMarketDataSourcingFunction()) {
// Market data is already in the cache, so don't need to copy it across again
continue;
}
final DependencyNodeJobExecutionResult previousExecutionResult = previousJobExecutionResultCache.find(unchangedNode.getOutputValues());
if (getLogModeSource().getLogMode(unchangedNode) == ExecutionLogMode.FULL
&& (previousExecutionResult == null || previousExecutionResult.getJobResultItem().getExecutionLog().getEvents() == null)) {
// Need to rerun calculation to collect logs, so cannot reuse
continue;
}
final NodeStateFlag nodeState = previousCycle.getNodeState(unchangedNode);
if (nodeState != null) {
setNodeState(unchangedNode, nodeState);
if (nodeState == NodeStateFlag.EXECUTED) {
specsToCopy.addAll(unchangedNode.getOutputValues());
} else {
for (final ValueSpecification outputValue : unchangedNode.getOutputValues()) {
errors.add(new ComputedValue(outputValue, MissingOutput.SUPPRESSED));
}
}
}
}
if (!specsToCopy.isEmpty()) {
final ComputationCycleQuery reusableResultsQuery = new ComputationCycleQuery();
reusableResultsQuery.setCalculationConfigurationName(depGraph.getCalculationConfigurationName());
reusableResultsQuery.setValueSpecifications(specsToCopy);
final ComputationResultsResponse reusableResultsQueryResponse = previousCycle.queryResults(reusableResultsQuery);
final Map<ValueSpecification, ComputedValueResult> resultsToReuse = reusableResultsQueryResponse.getResults();
final Collection<ComputedValue> newValues = new ArrayList<>(resultsToReuse.size());
for (final ComputedValueResult computedValueResult : resultsToReuse.values()) {
final ValueSpecification valueSpec = computedValueResult.getSpecification();
if (depGraph.getTerminalOutputSpecifications().contains(valueSpec)
&& getViewDefinition().getResultModelDefinition().shouldOutputResult(valueSpec, depGraph)) {
fragmentResultModel.addValue(depGraph.getCalculationConfigurationName(), computedValueResult);
fullResultModel.addValue(depGraph.getCalculationConfigurationName(), computedValueResult);
}
final Object previousValue = computedValueResult.getValue() != null ? computedValueResult.getValue() : MissingOutput.EVALUATION_ERROR;
newValues.add(new ComputedValue(valueSpec, previousValue));
final DependencyNodeJobExecutionResult previousDependencyNodeJobExecutionResult = previousJobExecutionResultCache.get(valueSpec);
if (previousDependencyNodeJobExecutionResult != null) {
jobExecutionResultCache.put(valueSpec, previousDependencyNodeJobExecutionResult);
}
}
cache.putSharedValues(newValues);