Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZoltan Ujhelyi2017-06-30 11:30:39 +0000
committerZoltan Ujhelyi2017-07-03 06:48:17 +0000
commite6901b9e20673f746960f3441455ee69b13da535 (patch)
tree15d48ee641b40524729974ec067b757477b9fc1d
parentf8a5a53c4d0fe6d2190aef097f97cc9705928b87 (diff)
downloadorg.eclipse.viatra-e6901b9e20673f746960f3441455ee69b13da535.tar.gz
org.eclipse.viatra-e6901b9e20673f746960f3441455ee69b13da535.tar.xz
org.eclipse.viatra-e6901b9e20673f746960f3441455ee69b13da535.zip
[469149] Removed direct dependency on the backend instance
Change-Id: I4c8121b812f273357eb1a06412e4a895df09faf9 Signed-off-by: Zoltan Ujhelyi <ujhelyiz@incquerylabs.com>
-rw-r--r--query/plugins/org.eclipse.viatra.query.runtime.localsearch/.settings/.api_filters28
-rw-r--r--query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/LocalSearchResultProvider.java4
-rw-r--r--query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/operations/extend/nobase/IterateOverEDatatypeInstances.java22
-rw-r--r--query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/CachingPlanProvider.java12
-rw-r--r--query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/IPlanProvider.java9
-rw-r--r--query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/LocalSearchPlanner.java19
-rw-r--r--query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/POperationCompiler.java12
7 files changed, 78 insertions, 28 deletions
diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/.settings/.api_filters b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/.settings/.api_filters
index c6c900b6d..7f2c14c51 100644
--- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/.settings/.api_filters
+++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/.settings/.api_filters
@@ -38,6 +38,20 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/viatra/query/runtime/localsearch/plan/IPlanProvider.java" type="org.eclipse.viatra.query.runtime.localsearch.plan.IPlanProvider">
+ <filter comment="Internal API modification" id="403804204">
+ <message_arguments>
+ <message_argument value="org.eclipse.viatra.query.runtime.localsearch.plan.IPlanProvider"/>
+ <message_argument value="getPlan(IQueryBackendContext, LocalSearchHints, MatcherReference)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Internal API modification" id="405901410">
+ <message_arguments>
+ <message_argument value="org.eclipse.viatra.query.runtime.localsearch.plan.IPlanProvider"/>
+ <message_argument value="getPlan(LocalSearchBackend, LocalSearchHints, MatcherReference)"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/viatra/query/runtime/localsearch/planner/PConstraintInfo.java" type="org.eclipse.viatra.query.runtime.localsearch.planner.PConstraintInfo">
<filter comment="Internal API implementation" id="576725006">
<message_arguments>
@@ -46,4 +60,18 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/viatra/query/runtime/localsearch/planner/POperationCompiler.java" type="org.eclipse.viatra.query.runtime.localsearch.planner.POperationCompiler">
+ <filter comment="Internal API modification" id="338722907">
+ <message_arguments>
+ <message_argument value="org.eclipse.viatra.query.runtime.localsearch.planner.POperationCompiler"/>
+ <message_argument value="POperationCompiler(IQueryRuntimeContext, IQueryBackend)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Internal API modification" id="338722907">
+ <message_arguments>
+ <message_argument value="org.eclipse.viatra.query.runtime.localsearch.planner.POperationCompiler"/>
+ <message_argument value="POperationCompiler(IQueryRuntimeContext, IQueryBackend, boolean)"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/LocalSearchResultProvider.java b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/LocalSearchResultProvider.java
index db1b2817a..18116860c 100644
--- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/LocalSearchResultProvider.java
+++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/matcher/integration/LocalSearchResultProvider.java
@@ -111,7 +111,7 @@ public class LocalSearchResultProvider implements IQueryResultProvider {
private IPlanDescriptor createPlan(MatcherReference key, IPlanProvider planProvider) throws QueryProcessingException {
LocalSearchHints configuration = overrideDefaultHints(key.getQuery());
- IPlanDescriptor plan = planProvider.getPlan((LocalSearchBackend) backend, configuration, key);
+ IPlanDescriptor plan = planProvider.getPlan(backend.getBackendContext(), configuration, key);
return plan;
}
@@ -208,7 +208,7 @@ public class LocalSearchResultProvider implements IQueryResultProvider {
// Plan for possible adornments
Iterator<MatcherReference> iterator = computeExpectedAdornments();
while(iterator.hasNext()){
- IPlanDescriptor plan = planProvider.getPlan((LocalSearchBackend) backend, overrideDefaultHints(query), iterator.next());
+ IPlanDescriptor plan = planProvider.getPlan(backend.getBackendContext(), overrideDefaultHints(query), iterator.next());
// Index keys
try {
indexKeys(plan.getIteratedKeys());
diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/operations/extend/nobase/IterateOverEDatatypeInstances.java b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/operations/extend/nobase/IterateOverEDatatypeInstances.java
index afeb8bb3d..4b06fcc1a 100644
--- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/operations/extend/nobase/IterateOverEDatatypeInstances.java
+++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/operations/extend/nobase/IterateOverEDatatypeInstances.java
@@ -25,12 +25,13 @@ import org.eclipse.viatra.query.runtime.emf.EMFScope;
import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
import org.eclipse.viatra.query.runtime.localsearch.MatchingFrame;
import org.eclipse.viatra.query.runtime.localsearch.matcher.ISearchContext;
-import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchBackend;
import org.eclipse.viatra.query.runtime.localsearch.operations.IIteratingSearchOperation;
import org.eclipse.viatra.query.runtime.matchers.context.IInputKey;
+import org.eclipse.viatra.query.runtime.matchers.util.IProvider;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
+import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -43,16 +44,21 @@ import com.google.common.collect.Table;
public class IterateOverEDatatypeInstances extends AbstractIteratingExtendOperation<Object> implements IIteratingSearchOperation {
private EDataType dataType;
- private final LocalSearchBackend backend;
- public IterateOverEDatatypeInstances(int position, EDataType dataType, EMFScope scope, LocalSearchBackend backend) {
+ public IterateOverEDatatypeInstances(int position, EDataType dataType, EMFScope scope) {
super(position, scope);
this.dataType = dataType;
- this.backend = backend;
}
- protected Iterator<EAttribute> doGetEAttributes(EClass eclass){
- Table<EDataType, EClass, Set<EAttribute>> cache = backend.geteAttributesByTypeForEClass();
+ protected Iterator<EAttribute> doGetEAttributes(EClass eclass, ISearchContext context){
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ Table<EDataType, EClass, Set<EAttribute>> cache = context.accessBackendLevelCache(getClass(), Table.class, new IProvider<Table>() {
+
+ @Override
+ public Table<EDataType, EClass, Set<EAttribute>> get() {
+ return HashBasedTable.create();
+ }
+ });
if(!cache.contains(dataType, eclass)){
EList<EAttribute> eAllAttributes = eclass.getEAllAttributes();
cache.put(dataType, eclass, Sets.filter(Sets.newHashSet(eAllAttributes), new Predicate<EAttribute>() {
@@ -70,12 +76,12 @@ public class IterateOverEDatatypeInstances extends AbstractIteratingExtendOperat
}
@Override
- public void onInitialize(MatchingFrame frame, ISearchContext context) {
+ public void onInitialize(MatchingFrame frame, final ISearchContext context) {
it = Iterators.concat(Iterators.transform(Iterators.filter(getModelContents(), EObject.class), new Function<EObject, Iterator<Object>>(){
@Override
public Iterator<Object> apply(final EObject input) {
- Iterator<EAttribute> features = doGetEAttributes(input.eClass());
+ Iterator<EAttribute> features = doGetEAttributes(input.eClass(), context);
return Iterators.concat(
Iterators.transform(features, new Function<EAttribute, Iterator<?>>() {
diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/CachingPlanProvider.java b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/CachingPlanProvider.java
index c5f28c99e..5cf34a649 100644
--- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/CachingPlanProvider.java
+++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/CachingPlanProvider.java
@@ -18,6 +18,7 @@ import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSea
import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchHints;
import org.eclipse.viatra.query.runtime.localsearch.planner.LocalSearchPlanner;
import org.eclipse.viatra.query.runtime.localsearch.planner.util.SearchPlanForBody;
+import org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext;
import org.eclipse.viatra.query.runtime.matchers.planning.QueryProcessingException;
import com.google.common.collect.ArrayListMultimap;
@@ -40,9 +41,18 @@ public class CachingPlanProvider implements IPlanProvider {
this.logger = logger;
}
- @Override
+ /**
+ * @deprecated use {@link #getPlan(IQueryBackendContext, LocalSearchHints, MatcherReference)} instead
+ */
+ @Deprecated
public IPlanDescriptor getPlan(LocalSearchBackend backend, final LocalSearchHints configuration, MatcherReference key)
throws QueryProcessingException {
+ return getPlan(backend.getBackendContext(), configuration, key);
+ }
+
+ @Override
+ public IPlanDescriptor getPlan(IQueryBackendContext backend, final LocalSearchHints configuration, MatcherReference key)
+ throws QueryProcessingException {
if (cache.containsKey(key)){
diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/IPlanProvider.java b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/IPlanProvider.java
index 8ba108d9b..029671f61 100644
--- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/IPlanProvider.java
+++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/plan/IPlanProvider.java
@@ -11,17 +11,20 @@
package org.eclipse.viatra.query.runtime.localsearch.plan;
import org.eclipse.viatra.query.runtime.localsearch.matcher.MatcherReference;
-import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchBackend;
import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchHints;
+import org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext;
import org.eclipse.viatra.query.runtime.matchers.planning.QueryProcessingException;
/**
* @author Grill Balázs
* @since 1.4
- *
+ * @noreference This interface is not intended to be referenced by clients.
*/
public interface IPlanProvider {
- public IPlanDescriptor getPlan(LocalSearchBackend backend, LocalSearchHints configuration, MatcherReference key) throws QueryProcessingException;
+ /**
+ * @since 1.7
+ */
+ public IPlanDescriptor getPlan(IQueryBackendContext backend, LocalSearchHints configuration, MatcherReference key) throws QueryProcessingException;
}
diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/LocalSearchPlanner.java b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/LocalSearchPlanner.java
index bf9cbb614..8f7c122a8 100644
--- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/LocalSearchPlanner.java
+++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/LocalSearchPlanner.java
@@ -51,14 +51,23 @@ public class LocalSearchPlanner {
private final IQueryRuntimeContext runtimeContext;
private final LocalSearchHints configuration;
private final IQueryBackendContext context;
- private final LocalSearchBackend backend;
+// private final LocalSearchBackend backend;
/**
* @since 1.4
+ * @deprecated
*/
+ @Deprecated
public LocalSearchPlanner(LocalSearchBackend backend, Logger logger, final LocalSearchHints configuration) {
+ this(backend.getBackendContext(), logger, configuration);
+ }
+
+ /**
+ * @since 1.7
+ */
+ public LocalSearchPlanner(IQueryBackendContext backendContext, Logger logger, final LocalSearchHints configuration) {
- this.runtimeContext = backend.getRuntimeContext();
+ this.runtimeContext = backendContext.getRuntimeContext();
this.configuration = configuration;
PQueryFlattener flattener = new PQueryFlattener(configuration.getFlattenCallPredicate());
/*
@@ -78,9 +87,8 @@ public class LocalSearchPlanner {
preprocessor = new PDisjunctionRewriterCacher(flattener, normalizer);
plannerStrategy = new LocalSearchRuntimeBasedStrategy();
- this.backend = backend;
- context = backend.getBackendContext();
+ context = backendContext;
}
/**
@@ -109,8 +117,7 @@ public class LocalSearchPlanner {
SubPlan plan = plannerStrategy.plan(normalizedBody, boundVariables, context, configuration);
// 3. PConstraint -> POperation compilation step
// * Pay extra caution to extend operations, when more than one variables are unbound
- POperationCompiler operationCompiler = new POperationCompiler(runtimeContext, backend,
- configuration.isUseBase());
+ POperationCompiler operationCompiler = new POperationCompiler(runtimeContext, configuration.isUseBase());
List<ISearchOperation> compiledOperations = operationCompiler.compile(plan, boundParameters);
// Store the variable mappings for the plans for debug purposes (traceability information)
SearchPlanForBody compiledPlan = new SearchPlanForBody(normalizedBody,
diff --git a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/POperationCompiler.java b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/POperationCompiler.java
index b68d68ca8..2d8f393f1 100644
--- a/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/POperationCompiler.java
+++ b/query/plugins/org.eclipse.viatra.query.runtime.localsearch/src/org/eclipse/viatra/query/runtime/localsearch/planner/POperationCompiler.java
@@ -22,7 +22,6 @@ import org.eclipse.viatra.query.runtime.emf.types.EClassUnscopedTransitiveInstan
import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
import org.eclipse.viatra.query.runtime.localsearch.matcher.MatcherReference;
-import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchBackend;
import org.eclipse.viatra.query.runtime.localsearch.operations.ISearchOperation;
import org.eclipse.viatra.query.runtime.localsearch.operations.check.AggregatorCheck;
import org.eclipse.viatra.query.runtime.localsearch.operations.check.BinaryTransitiveClosureCheck;
@@ -50,7 +49,6 @@ import org.eclipse.viatra.query.runtime.localsearch.operations.extend.IterateOve
import org.eclipse.viatra.query.runtime.localsearch.operations.extend.IterateOverEClassInstances;
import org.eclipse.viatra.query.runtime.localsearch.operations.extend.IterateOverEDatatypeInstances;
import org.eclipse.viatra.query.runtime.localsearch.planner.util.CompilerHelper;
-import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend;
import org.eclipse.viatra.query.runtime.matchers.context.IInputKey;
import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext;
import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
@@ -103,7 +101,6 @@ public class POperationCompiler {
private Map<PVariable, Integer> variableMappings;
private final boolean baseIndexAvailable;
private final EMFQueryRuntimeContext runtimeContext;
- private final IQueryBackend backend;
private class FrameMapping{
final Map<PParameter, Integer> mapping = Maps.newHashMap();
@@ -136,12 +133,11 @@ public class POperationCompiler {
}
}
- public POperationCompiler(IQueryRuntimeContext runtimeContext, IQueryBackend backend) {
- this(runtimeContext, backend, false);
+ public POperationCompiler(IQueryRuntimeContext runtimeContext) {
+ this(runtimeContext, false);
}
- public POperationCompiler(IQueryRuntimeContext runtimeContext, IQueryBackend backend, boolean baseIndexAvailable) {
- this.backend = backend;
+ public POperationCompiler(IQueryRuntimeContext runtimeContext, boolean baseIndexAvailable) {
this.runtimeContext = (EMFQueryRuntimeContext) runtimeContext;
this.baseIndexAvailable = baseIndexAvailable;
}
@@ -459,7 +455,7 @@ public class POperationCompiler {
int position = variableMapping.get(typeConstraint.getVariableInTuple(0));
operations
.add(new org.eclipse.viatra.query.runtime.localsearch.operations.extend.nobase.IterateOverEDatatypeInstances(position,
- ((EDataTypeInSlotsKey) inputKey).getEmfKey(), runtimeContext.getEmfScope(), (LocalSearchBackend) backend));
+ ((EDataTypeInSlotsKey) inputKey).getEmfKey(), runtimeContext.getEmfScope()));
operations.add(new ScopeCheck(position, runtimeContext.getEmfScope()));
}
} else if (inputKey instanceof EClassTransitiveInstancesKey) {

Back to the top