diff options
Diffstat (limited to 'subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/plan/SimplePlanProvider.java')
-rw-r--r-- | subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/plan/SimplePlanProvider.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/plan/SimplePlanProvider.java b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/plan/SimplePlanProvider.java new file mode 100644 index 00000000..ed31bcb0 --- /dev/null +++ b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/plan/SimplePlanProvider.java | |||
@@ -0,0 +1,49 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2016, Grill Balázs, IncQuery Labs Ltd. | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.viatra.runtime.localsearch.plan; | ||
10 | |||
11 | import java.util.Collection; | ||
12 | |||
13 | import org.apache.log4j.Logger; | ||
14 | import tools.refinery.viatra.runtime.localsearch.matcher.MatcherReference; | ||
15 | import tools.refinery.viatra.runtime.localsearch.matcher.integration.LocalSearchHints; | ||
16 | import tools.refinery.viatra.runtime.localsearch.planner.LocalSearchPlanner; | ||
17 | import tools.refinery.viatra.runtime.localsearch.planner.compiler.IOperationCompiler; | ||
18 | import tools.refinery.viatra.runtime.matchers.backend.ResultProviderRequestor; | ||
19 | import tools.refinery.viatra.runtime.matchers.context.IQueryBackendContext; | ||
20 | |||
21 | /** | ||
22 | * A plan provider implementation which caches previously calculated plans to avoid re-planning for the same adornment | ||
23 | * | ||
24 | * @author Grill Balázs | ||
25 | * @since 1.7 | ||
26 | * | ||
27 | */ | ||
28 | public class SimplePlanProvider implements IPlanProvider { | ||
29 | |||
30 | private final Logger logger; | ||
31 | |||
32 | public SimplePlanProvider(Logger logger) { | ||
33 | this.logger = logger; | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | public IPlanDescriptor getPlan(IQueryBackendContext backend, IOperationCompiler compiler, | ||
38 | final ResultProviderRequestor resultRequestor, | ||
39 | final LocalSearchHints configuration, MatcherReference key) { | ||
40 | |||
41 | LocalSearchPlanner planner = new LocalSearchPlanner(backend, compiler, logger, configuration, resultRequestor); | ||
42 | |||
43 | Collection<SearchPlanForBody> plansForBodies = planner.plan(key.getQuery(), key.getAdornment()); | ||
44 | |||
45 | IPlanDescriptor plan = new PlanDescriptor(key.getQuery(), plansForBodies, key.getAdornment()); | ||
46 | return plan; | ||
47 | } | ||
48 | |||
49 | } | ||