1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*******************************************************************************
* Copyright (c) 2010-2014, Bergmann Gabor, Istvan Rath and Daniel Varro
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package tools.refinery.viatra.runtime.rete.matcher;
import tools.refinery.viatra.runtime.matchers.backend.IMatcherCapability;
import tools.refinery.viatra.runtime.matchers.backend.IQueryBackend;
import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendFactory;
import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendHintProvider;
import tools.refinery.viatra.runtime.matchers.backend.QueryEvaluationHint;
import tools.refinery.viatra.runtime.matchers.context.IQueryBackendContext;
import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery;
import tools.refinery.viatra.runtime.rete.construction.plancompiler.ReteRecipeCompiler;
import tools.refinery.viatra.runtime.rete.util.Options;
public class ReteBackendFactory implements IQueryBackendFactory {
/**
* EXPERIMENTAL
*/
protected static final int reteThreads = 0;
/**
* @since 2.0
*/
public static final ReteBackendFactory INSTANCE = new ReteBackendFactory();
/**
* @deprecated Use the static {@link #INSTANCE} field instead
*/
@Deprecated
public ReteBackendFactory() {
}
/**
* @since 1.5
*/
@Override
public IQueryBackend create(IQueryBackendContext context) {
return create(context, false, null);
}
/**
* @since 2.4
*/
public IQueryBackend create(IQueryBackendContext context, boolean deleteAndRederiveEvaluation,
TimelyConfiguration timelyConfiguration) {
ReteEngine engine;
engine = new ReteEngine(context, reteThreads, deleteAndRederiveEvaluation, timelyConfiguration);
IQueryBackendHintProvider hintConfiguration = engine.getHintConfiguration();
ReteRecipeCompiler compiler = new ReteRecipeCompiler(
Options.builderMethod.layoutStrategy(context, hintConfiguration), context.getLogger(),
context.getRuntimeContext().getMetaContext(), context.getQueryCacheContext(), hintConfiguration,
context.getQueryAnalyzer(), deleteAndRederiveEvaluation, timelyConfiguration);
engine.setCompiler(compiler);
return engine;
}
@Override
public Class<? extends IQueryBackend> getBackendClass() {
return ReteEngine.class;
}
@Override
public int hashCode() {
return ReteBackendFactory.class.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ReteBackendFactory)) {
return false;
}
return true;
}
/**
* @since 1.4
*/
@Override
public IMatcherCapability calculateRequiredCapability(PQuery query, QueryEvaluationHint hint) {
return new IncrementalMatcherCapability();
}
@Override
public boolean isCaching() {
return true;
}
}
|