Skip to content

Commit

Permalink
[519628] Fixes poset comparator lookup for aggregators in the RETE
Browse files Browse the repository at this point in the history
compiler

Change-Id: I4abd4614ac75ea1e1b180011c0fc5d1dfb17514f
Signed-off-by: Tamás Szabó <[email protected]>
(cherry picked from commit fd9e92c)
  • Loading branch information
Tamás Szabó authored and bergmanngabor committed Jul 18, 2017
1 parent d68c1a1 commit a71e103
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eclipse.viatra.query.runtime.matchers.planning.QueryProcessingException;
import org.eclipse.viatra.query.runtime.matchers.planning.SubPlan;
import org.eclipse.viatra.query.runtime.matchers.planning.helpers.BuildHelper;
import org.eclipse.viatra.query.runtime.matchers.planning.helpers.TypeHelper;
import org.eclipse.viatra.query.runtime.matchers.planning.operations.PApply;
import org.eclipse.viatra.query.runtime.matchers.planning.operations.PEnumerate;
import org.eclipse.viatra.query.runtime.matchers.planning.operations.PJoin;
Expand All @@ -59,6 +58,7 @@
import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery;
import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.IRewriterTraceCollector;
import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyNormalizer;
Expand Down Expand Up @@ -182,12 +182,13 @@ public void reset() {
public CompiledQuery getCompiledForm(PQuery query) throws QueryProcessingException {
CompiledQuery compiled = queryCompilerCache.get(query);
if (compiled == null) {

IRewriterTraceCollector traceCollector = CommonQueryHintOptions.normalizationTraceCollector.getValueOrDefault(hintProvider.getQueryEvaluationHint(query));

IRewriterTraceCollector traceCollector = CommonQueryHintOptions.normalizationTraceCollector
.getValueOrDefault(hintProvider.getQueryEvaluationHint(query));
if (traceCollector != null) {
traceCollector.addTrace(query, query);
}

boolean reentrant = !compilationInProgress.add(query);
if (reentrant) { // oops, recursion into body in progress
RecursionCutoffPoint cutoffPoint = new RecursionCutoffPoint(query, getHints(query), metaContext);
Expand Down Expand Up @@ -252,7 +253,8 @@ public SubPlan getPlan(PBody pBody) throws QueryProcessingException {

private CompiledQuery compileProduction(PQuery query) throws QueryProcessingException {
Collection<SubPlan> bodyPlans = new ArrayList<SubPlan>();
normalizer.setTraceCollector(CommonQueryHintOptions.normalizationTraceCollector.getValueOrDefault(hintProvider.getQueryEvaluationHint(query)));
normalizer.setTraceCollector(CommonQueryHintOptions.normalizationTraceCollector
.getValueOrDefault(hintProvider.getQueryEvaluationHint(query)));
for (PBody pBody : normalizer.rewrite(query).getBodies()) {
SubPlan bodyPlan = getPlan(pBody);
bodyPlans.add(bodyPlan);
Expand Down Expand Up @@ -560,21 +562,16 @@ private CompiledSubPlan compileDeferred(AggregatorConstraint constraint, SubPlan
columnAggregatorRecipe.setMultisetAggregationOperator(operator);

int columnIndex = constraint.getAggregatedColumn();
PVariable aggregatedVariable = (PVariable) constraint.getActualParametersTuple().get(columnIndex);
IPosetComparator posetComparator = null;
boolean deleteRederiveEvaluation = ReteHintOptions.deleteRederiveEvaluation.getValueOrDefault(getHints(plan));
Mask groupMask = CompilerHelper.toRecipeMask(callGroupMask);

columnAggregatorRecipe.setDeleteRederiveEvaluation(deleteRederiveEvaluation);
if (deleteRederiveEvaluation) {
Map<PVariable, Set<IInputKey>> typeMap = TypeHelper.inferUnaryTypesFor(
Collections.singleton(aggregatedVariable), constraint.getPSystem().getConstraints(), metaContext);

for (IInputKey key : typeMap.get(aggregatedVariable)) {
if (key != null && metaContext.isPosetKey(key)) {
posetComparator = metaContext.getPosetComparator(Collections.singleton(key));
break;
}
List<PParameter> parameters = constraint.getReferredQuery().getParameters();
IInputKey key = parameters.get(columnIndex).getDeclaredUnaryType();
if (key != null && metaContext.isPosetKey(key)) {
posetComparator = metaContext.getPosetComparator(Collections.singleton(key));
}
}

Expand Down

0 comments on commit a71e103

Please sign in to comment.