From a71e103b1a2650d821629148e9a39f4752bc1f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Szab=C3=B3?= Date: Thu, 13 Jul 2017 17:54:58 +0200 Subject: [PATCH] [519628] Fixes poset comparator lookup for aggregators in the RETE compiler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4abd4614ac75ea1e1b180011c0fc5d1dfb17514f Signed-off-by: Tamás Szabó (cherry picked from commit fd9e92ce799ec9bb69f3f79f7ab315c4f080b882) --- .../plancompiler/ReteRecipeCompiler.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/query/plugins/org.eclipse.viatra.query.runtime.rete/src/org/eclipse/viatra/query/runtime/rete/construction/plancompiler/ReteRecipeCompiler.java b/query/plugins/org.eclipse.viatra.query.runtime.rete/src/org/eclipse/viatra/query/runtime/rete/construction/plancompiler/ReteRecipeCompiler.java index 015a03d229..9915c65f00 100644 --- a/query/plugins/org.eclipse.viatra.query.runtime.rete/src/org/eclipse/viatra/query/runtime/rete/construction/plancompiler/ReteRecipeCompiler.java +++ b/query/plugins/org.eclipse.viatra.query.runtime.rete/src/org/eclipse/viatra/query/runtime/rete/construction/plancompiler/ReteRecipeCompiler.java @@ -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; @@ -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; @@ -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); @@ -252,7 +253,8 @@ public SubPlan getPlan(PBody pBody) throws QueryProcessingException { private CompiledQuery compileProduction(PQuery query) throws QueryProcessingException { Collection bodyPlans = new ArrayList(); - 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); @@ -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> 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 parameters = constraint.getReferredQuery().getParameters(); + IInputKey key = parameters.get(columnIndex).getDeclaredUnaryType(); + if (key != null && metaContext.isPosetKey(key)) { + posetComparator = metaContext.getPosetComparator(Collections.singleton(key)); } }