diff options
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/matcher/ReteBackendFactory.java')
-rw-r--r-- | subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/matcher/ReteBackendFactory.java | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/matcher/ReteBackendFactory.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/matcher/ReteBackendFactory.java new file mode 100644 index 00000000..347cabc4 --- /dev/null +++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/matcher/ReteBackendFactory.java | |||
@@ -0,0 +1,100 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2014, Bergmann Gabor, Istvan Rath and Daniel Varro | ||
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.rete.matcher; | ||
10 | |||
11 | import tools.refinery.viatra.runtime.matchers.backend.IMatcherCapability; | ||
12 | import tools.refinery.viatra.runtime.matchers.backend.IQueryBackend; | ||
13 | import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendFactory; | ||
14 | import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendHintProvider; | ||
15 | import tools.refinery.viatra.runtime.matchers.backend.QueryEvaluationHint; | ||
16 | import tools.refinery.viatra.runtime.matchers.context.IQueryBackendContext; | ||
17 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; | ||
18 | import tools.refinery.viatra.runtime.rete.construction.plancompiler.ReteRecipeCompiler; | ||
19 | import tools.refinery.viatra.runtime.rete.util.Options; | ||
20 | |||
21 | public class ReteBackendFactory implements IQueryBackendFactory { | ||
22 | /** | ||
23 | * EXPERIMENTAL | ||
24 | */ | ||
25 | protected static final int reteThreads = 0; | ||
26 | |||
27 | /** | ||
28 | * @since 2.0 | ||
29 | */ | ||
30 | public static final ReteBackendFactory INSTANCE = new ReteBackendFactory(); | ||
31 | |||
32 | /** | ||
33 | * @deprecated Use the static {@link #INSTANCE} field instead | ||
34 | */ | ||
35 | @Deprecated | ||
36 | public ReteBackendFactory() { | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * @since 1.5 | ||
41 | */ | ||
42 | @Override | ||
43 | public IQueryBackend create(IQueryBackendContext context) { | ||
44 | return create(context, false, null); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * @since 2.4 | ||
49 | */ | ||
50 | public IQueryBackend create(IQueryBackendContext context, boolean deleteAndRederiveEvaluation, | ||
51 | TimelyConfiguration timelyConfiguration) { | ||
52 | ReteEngine engine; | ||
53 | engine = new ReteEngine(context, reteThreads, deleteAndRederiveEvaluation, timelyConfiguration); | ||
54 | IQueryBackendHintProvider hintConfiguration = engine.getHintConfiguration(); | ||
55 | ReteRecipeCompiler compiler = new ReteRecipeCompiler( | ||
56 | Options.builderMethod.layoutStrategy(context, hintConfiguration), context.getLogger(), | ||
57 | context.getRuntimeContext().getMetaContext(), context.getQueryCacheContext(), hintConfiguration, | ||
58 | context.getQueryAnalyzer(), deleteAndRederiveEvaluation, timelyConfiguration); | ||
59 | engine.setCompiler(compiler); | ||
60 | return engine; | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public Class<? extends IQueryBackend> getBackendClass() { | ||
65 | return ReteEngine.class; | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | public int hashCode() { | ||
70 | return ReteBackendFactory.class.hashCode(); | ||
71 | } | ||
72 | |||
73 | @Override | ||
74 | public boolean equals(Object obj) { | ||
75 | if (this == obj) { | ||
76 | return true; | ||
77 | } | ||
78 | if (obj == null) { | ||
79 | return false; | ||
80 | } | ||
81 | if (!(obj instanceof ReteBackendFactory)) { | ||
82 | return false; | ||
83 | } | ||
84 | return true; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * @since 1.4 | ||
89 | */ | ||
90 | @Override | ||
91 | public IMatcherCapability calculateRequiredCapability(PQuery query, QueryEvaluationHint hint) { | ||
92 | return new IncrementalMatcherCapability(); | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public boolean isCaching() { | ||
97 | return true; | ||
98 | } | ||
99 | |||
100 | } \ No newline at end of file | ||