diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2023-09-14 19:29:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-14 19:29:36 +0200 |
commit | 98ed3b6db5f4e51961a161050cc31c66015116e8 (patch) | |
tree | 8bfd6d9bc8d6ed23b9eb0f889dd40b6c24fe8f92 /subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/backend/ResultProviderRequestor.java | |
parent | Merge pull request #38 from nagilooh/design-space-exploration (diff) | |
parent | Merge remote-tracking branch 'upstream/main' into partial-interpretation (diff) | |
download | refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.gz refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.zst refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.zip |
Merge pull request #39 from kris7t/partial-interpretation
Implement partial interpretation based model generation
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/backend/ResultProviderRequestor.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/backend/ResultProviderRequestor.java | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/backend/ResultProviderRequestor.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/backend/ResultProviderRequestor.java new file mode 100644 index 00000000..6ec6d53e --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/backend/ResultProviderRequestor.java | |||
@@ -0,0 +1,74 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2018, Gabor Bergmann, 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.matchers.backend; | ||
10 | |||
11 | import tools.refinery.viatra.runtime.matchers.context.IQueryResultProviderAccess; | ||
12 | import tools.refinery.viatra.runtime.matchers.psystem.IQueryReference; | ||
13 | import tools.refinery.viatra.runtime.matchers.psystem.PConstraint; | ||
14 | |||
15 | /** | ||
16 | * Uniform way of requesting result providers for pattern calls within queries. | ||
17 | * Intended users are query backends, for calling other backends to deliver results of dependee queries. | ||
18 | * | ||
19 | * @author Gabor Bergmann | ||
20 | * @since 2.1 | ||
21 | */ | ||
22 | public class ResultProviderRequestor { | ||
23 | IQueryBackend callerBackend; | ||
24 | IQueryResultProviderAccess resultProviderAccess; | ||
25 | IQueryBackendHintProvider hintProvider; | ||
26 | ICallDelegationStrategy delegationStrategy; | ||
27 | QueryEvaluationHint callerHint; | ||
28 | QueryEvaluationHint universalOverride; | ||
29 | |||
30 | |||
31 | /** | ||
32 | * @param callerBackend the actual backend evaluating the calling pattern. | ||
33 | * @param resultProviderAccess | ||
34 | * @param hintProvider | ||
35 | * @param delegationStrategy | ||
36 | * @param callerHint a hint under which the calling pattern is evaluated, | ||
37 | * @param universalOverride if non-null, overrides the hint with extra options <i>after</i> the {@link ICallDelegationStrategy} | ||
38 | */ | ||
39 | public ResultProviderRequestor(IQueryBackend callerBackend, IQueryResultProviderAccess resultProviderAccess, | ||
40 | IQueryBackendHintProvider hintProvider, ICallDelegationStrategy delegationStrategy, | ||
41 | QueryEvaluationHint callerHint, QueryEvaluationHint universalOverride) { | ||
42 | super(); | ||
43 | this.callerBackend = callerBackend; | ||
44 | this.resultProviderAccess = resultProviderAccess; | ||
45 | this.hintProvider = hintProvider; | ||
46 | this.delegationStrategy = delegationStrategy; | ||
47 | this.callerHint = callerHint; | ||
48 | this.universalOverride = universalOverride; | ||
49 | } | ||
50 | |||
51 | |||
52 | |||
53 | |||
54 | /** | ||
55 | * | ||
56 | * @param call a {@link PConstraint} in a query that calls another query. | ||
57 | * @param spotOverride if non-null, overrides the hint with extra options <i>after</i> the {@link ICallDelegationStrategy} | ||
58 | * and the universal override specified in the constructor | ||
59 | * @return the obtained result provider | ||
60 | */ | ||
61 | public IQueryResultProvider requestResultProvider(IQueryReference call, QueryEvaluationHint spotOverride) { | ||
62 | QueryEvaluationHint hints = | ||
63 | delegationStrategy.transformHints(call, callerHint, callerBackend, hintProvider); | ||
64 | |||
65 | if (universalOverride != null) | ||
66 | hints = hints.overrideBy(universalOverride); | ||
67 | |||
68 | if (spotOverride != null) | ||
69 | hints = hints.overrideBy(spotOverride); | ||
70 | |||
71 | return resultProviderAccess.getResultProvider(call.getReferredQuery(), hints); | ||
72 | } | ||
73 | |||
74 | } | ||