use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCache in project legend-engine by finos.
the class ExecutionNodeExecutor method findGraphFetchCacheByTargetCrossKeys.
private ExecutionCache<GraphFetchCacheKey, List<Object>> findGraphFetchCacheByTargetCrossKeys(GlobalGraphFetchExecutionNode globalGraphFetchExecutionNode) {
List<GraphFetchCache> graphFetchCaches = this.executionState.graphFetchCaches;
XStorePropertyFetchDetails fetchDetails = globalGraphFetchExecutionNode.xStorePropertyFetchDetails;
return graphFetchCaches.stream().filter(GraphFetchCacheByTargetCrossKeys.class::isInstance).map(GraphFetchCacheByTargetCrossKeys.class::cast).filter(cache -> cache.getGraphFetchCrossAssociationKeys() != null).filter(cache -> {
GraphFetchCrossAssociationKeys c = cache.getGraphFetchCrossAssociationKeys();
return c.getPropertyPath().equals(fetchDetails.propertyPath) && c.getSourceMappingId().equals(fetchDetails.sourceMappingId) && c.getSourceSetId().equals(fetchDetails.sourceSetId) && c.getTargetMappingId().equals(fetchDetails.targetMappingId) && c.getTargetSetId().equals(fetchDetails.targetSetId) && c.getTargetPropertiesOrdered().equals(fetchDetails.targetPropertiesOrdered) && c.getSubTree().equals(fetchDetails.subTree);
}).map(GraphFetchCacheByTargetCrossKeys::getExecutionCache).findFirst().orElse(null);
}
use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCache in project legend-engine by finos.
the class AbstractServicePlanExecutor method execute.
protected Result execute(Map<String, ?> parameters, ServiceRunnerInput serviceRunnerInput, StreamProvider streamProvider) {
MutableList<CommonProfile> profiles = Lists.mutable.empty();
PlanExecutionContext planExecutionContext = null;
if (serviceRunnerInput != null) {
Identity identity = serviceRunnerInput.getIdentity();
if (identity != null) {
profiles.addAll(IdentityFactoryProvider.getInstance().adapt(identity));
}
if (serviceRunnerInput.getOperationalContext() != null && serviceRunnerInput.getOperationalContext().getGraphFetchCrossAssociationKeysCacheConfig() != null) {
List<GraphFetchCache> graphFetchCaches = serviceRunnerInput.getOperationalContext().getGraphFetchCrossAssociationKeysCacheConfig().entrySet().stream().map(e -> ExecutionCacheBuilder.buildGraphFetchCacheByTargetCrossKeysFromExecutionCache(e.getValue(), e.getKey())).collect(Collectors.toList());
planExecutionContext = new PlanExecutionContext(graphFetchCaches);
}
}
return this.executor.execute(this.plan, parameters, streamProvider, profiles, planExecutionContext);
}
use of org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCache in project legend-engine by finos.
the class RelationalGraphFetchUtils method findCacheByEqualityKeys.
static GraphFetchCacheByEqualityKeys findCacheByEqualityKeys(GraphFetchTree graphFetchTree, String mappingId, String instanceSetId, List<GraphFetchCache> graphFetchCaches) {
if (!subTreeValidForCaching(graphFetchTree)) {
return null;
}
String subTree = getSubTreeString(graphFetchTree);
GraphFetchCacheByEqualityKeys matchingUtilizedCache = null;
for (GraphFetchCache c : graphFetchCaches) {
if (c instanceof GraphFetchCacheByEqualityKeys) {
GraphFetchCacheByEqualityKeys ce = (GraphFetchCacheByEqualityKeys) c;
if (ce.isCacheUtilized() && mappingId.equals(ce.getMappingId()) && instanceSetId.equals(ce.getInstanceSetId()) && subTree.equals(ce.getSubTree())) {
matchingUtilizedCache = ce;
break;
}
}
}
if (matchingUtilizedCache == null) {
GraphFetchCacheByEqualityKeys unUtilizedCache = null;
for (GraphFetchCache c : graphFetchCaches) {
if (c instanceof GraphFetchCacheByEqualityKeys) {
GraphFetchCacheByEqualityKeys ce = (GraphFetchCacheByEqualityKeys) c;
if (!ce.isCacheUtilized() && mappingId.equals(ce.getMappingId()) && instanceSetId.equals(ce.getInstanceSetId())) {
unUtilizedCache = ce;
break;
}
}
}
if (unUtilizedCache != null) {
unUtilizedCache.setSubTree(subTree);
return unUtilizedCache;
}
return null;
}
return matchingUtilizedCache;
}
Aggregations