From 03d1fb471bbc41b51fc9710d92e9107eeec7f62d Mon Sep 17 00:00:00 2001 From: bergmann Date: Sun, 8 Jul 2018 13:48:39 +0200 Subject: [PATCH] [536794] Make LS flattener predicate aware of BackendRequirement logic Change-Id: I24502fc906ac5591052bb0f061f12b499d6f7e97 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=536794 Signed-off-by: bergmann Signed-off-by: Zoltan Ujhelyi --- .../DontFlattenIncrementalPredicate.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/DontFlattenIncrementalPredicate.java b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/DontFlattenIncrementalPredicate.java index 299d3516a6..04cb772704 100644 --- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/DontFlattenIncrementalPredicate.java +++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/DontFlattenIncrementalPredicate.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.viatra.query.runtime.localsearch.matcher.integration; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint.BackendRequirement; import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.IFlattenCallPredicate; /** - * This implementation forbids flattening of patterns marked to be executed with a backend other than the - * Local search engine (e.g. Rete). This makes is possible for the user to configure hybrid matching via using + * This implementation forbids flattening of patterns marked to be executed with a caching / incremental backend. + * This makes is possible for the user to configure hybrid matching via using * the 'search' and 'incremental keywords in the pattern definition file. * * @since 1.5 @@ -29,8 +29,18 @@ public class DontFlattenIncrementalPredicate implements IFlattenCallPredicate { public boolean shouldFlatten(PositivePatternCall positivePatternCall) { QueryEvaluationHint evaluationHints = positivePatternCall.getReferredQuery().getEvaluationHints(); if (evaluationHints == null) return true; - IQueryBackendFactory configuredBackend = evaluationHints.getQueryBackendFactory(); - return configuredBackend == null || !configuredBackend.isCaching(); + + BackendRequirement backendRequirementType = evaluationHints.getQueryBackendRequirementType(); + switch(backendRequirementType) { + case DEFAULT_CACHING: + return false; + case SPECIFIC: + return !evaluationHints.getQueryBackendFactory().isCaching(); + case UNSPECIFIED: + case DEFAULT_SEARCH: + default: + return true; + } } }