Skip to content

Commit

Permalink
[536794] Make LS flattener predicate aware of BackendRequirement logic
Browse files Browse the repository at this point in the history
Change-Id: I24502fc906ac5591052bb0f061f12b499d6f7e97
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=536794
Signed-off-by: bergmann <[email protected]>
Signed-off-by: Zoltan Ujhelyi <[email protected]>
  • Loading branch information
bergmanngabor authored and ujhelyiz committed Jul 13, 2018
1 parent dba5a5b commit 03d1fb4
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}

}

0 comments on commit 03d1fb4

Please sign in to comment.