From 9adbb3d49899a87b3026c11cb4ba3ff77f4fb75b Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sat, 19 Aug 2023 02:31:57 +0200 Subject: chore: import VIATRA source Make our modifications more maintainable by editing the source code directly instead of using reflection. --- .../rete/network/RefineryConnectionFactory.java | 34 --- .../runtime/rete/network/RefineryNodeFactory.java | 37 ---- .../query/viatra/ViatraModelQueryBuilder.java | 6 +- .../query/viatra/ViatraModelQueryStoreAdapter.java | 2 +- .../query/viatra/internal/RelationalScope.java | 8 +- .../internal/ViatraModelQueryAdapterImpl.java | 81 +------- .../internal/ViatraModelQueryBuilderImpl.java | 16 +- .../internal/ViatraModelQueryStoreAdapterImpl.java | 6 +- .../viatra/internal/context/DummyBaseIndexer.java | 10 +- .../internal/context/RelationalEngineContext.java | 6 +- .../context/RelationalQueryMetaContext.java | 8 +- .../internal/context/RelationalRuntimeContext.java | 12 +- .../localsearch/ExtendOperationExecutor.java | 8 +- .../localsearch/ExtendPositivePatternCall.java | 18 +- .../internal/localsearch/FlatCostFunction.java | 12 +- .../internal/localsearch/GenericTypeExtend.java | 18 +- .../RelationalLocalSearchBackendFactory.java | 22 +- .../RelationalLocalSearchResultProvider.java | 16 +- .../localsearch/RelationalOperationCompiler.java | 24 +-- .../internal/matcher/AbstractViatraMatcher.java | 4 +- .../viatra/internal/matcher/FunctionalCursor.java | 4 +- .../internal/matcher/FunctionalViatraMatcher.java | 16 +- .../viatra/internal/matcher/IndexerUtils.java | 53 ----- .../viatra/internal/matcher/MatcherUtils.java | 6 +- .../viatra/internal/matcher/RawPatternMatcher.java | 6 +- .../viatra/internal/matcher/RelationalCursor.java | 2 +- .../internal/matcher/RelationalViatraMatcher.java | 16 +- .../internal/matcher/UnsafeFunctionalCursor.java | 2 +- .../viatra/internal/pquery/CheckEvaluator.java | 2 +- .../query/viatra/internal/pquery/Dnf2PQuery.java | 68 +++--- .../internal/pquery/QueryWrapperFactory.java | 22 +- .../query/viatra/internal/pquery/RawPQuery.java | 16 +- .../pquery/RepresentativeElectionConstraint.java | 45 ---- .../pquery/StatefulMultisetAggregator.java | 2 +- .../pquery/StatelessMultisetAggregator.java | 2 +- .../viatra/internal/pquery/SymbolViewWrapper.java | 2 +- .../viatra/internal/pquery/TermEvaluator.java | 4 +- .../pquery/ValueProviderBasedValuation.java | 2 +- .../pquery/rewriter/RefineryPBodyCopier.java | 35 ---- .../pquery/rewriter/RefineryPBodyNormalizer.java | 38 ---- .../rewriter/RefinerySurrogateQueryRewriter.java | 58 ------ .../internal/rete/RefineryReteBackendFactory.java | 90 -------- .../viatra/internal/rete/RefineryReteEngine.java | 134 ------------ .../internal/rete/RefineryReteRecipeCompiler.java | 228 --------------------- .../RefineryConnectionFactoryExtensions.java | 47 ----- .../network/RefineryNodeFactoryExtensions.java | 44 ---- .../network/RepresentativeElectionAlgorithm.java | 137 ------------- .../rete/network/RepresentativeElectionNode.java | 120 ----------- .../StronglyConnectedComponentAlgorithm.java | 66 ------ .../network/WeaklyConnectedComponentAlgorithm.java | 85 -------- .../rete/recipe/RefineryRecipesFactory.java | 22 -- .../rete/recipe/RefineryRecipesFactoryImpl.java | 74 ------- .../rete/recipe/RefineryRecipesPackage.java | 41 ---- .../rete/recipe/RefineryRecipesPackageImpl.java | 96 --------- .../rete/recipe/RepresentativeElectionRecipe.java | 17 -- .../recipe/RepresentativeElectionRecipeImpl.java | 105 ---------- .../internal/update/ModelUpdateListener.java | 6 +- .../viatra/internal/update/RelationViewFilter.java | 8 +- .../internal/update/SymbolViewUpdateListener.java | 8 +- .../update/TupleChangingViewUpdateListener.java | 2 +- .../update/TuplePreservingViewUpdateListener.java | 2 +- 61 files changed, 205 insertions(+), 1876 deletions(-) delete mode 100644 subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryConnectionFactory.java delete mode 100644 subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryNodeFactory.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/IndexerUtils.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyCopier.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyNormalizer.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefinerySurrogateQueryRewriter.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteBackendFactory.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteEngine.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteRecipeCompiler.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryConnectionFactoryExtensions.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryNodeFactoryExtensions.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionAlgorithm.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionNode.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/StronglyConnectedComponentAlgorithm.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/WeaklyConnectedComponentAlgorithm.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactory.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactoryImpl.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackage.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackageImpl.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipe.java delete mode 100644 subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipeImpl.java (limited to 'subprojects/store-query-viatra/src/main/java') diff --git a/subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryConnectionFactory.java b/subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryConnectionFactory.java deleted file mode 100644 index 241c5b58..00000000 --- a/subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryConnectionFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.viatra.query.runtime.rete.network; - -import org.eclipse.viatra.query.runtime.rete.traceability.RecipeTraceInfo; -import tools.refinery.store.query.viatra.internal.rete.network.RefineryConnectionFactoryExtensions; - -/** - * This class overrides some RETE connection types from {@link ConnectionFactory}. - *

- * Since {@link ConnectionFactory} is package-private, this class has to be in the - * {@code org.eclipse.viatra.query.runtime.rete.network} package as well. - * However, due to JAR signature verification errors, this class cannot be loaded directly - * and has to be loaded at runtime as a byte array instead. - */ -@SuppressWarnings("unused") -public class RefineryConnectionFactory extends ConnectionFactory { - private final RefineryConnectionFactoryExtensions extensions; - - public RefineryConnectionFactory(ReteContainer reteContainer) { - super(reteContainer); - extensions = new RefineryConnectionFactoryExtensions(reteContainer); - } - - @Override - public void connectToParents(RecipeTraceInfo recipeTrace, Node freshNode) { - if (!extensions.connectToParents(recipeTrace, freshNode)) { - super.connectToParents(recipeTrace, freshNode); - } - } -} diff --git a/subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryNodeFactory.java b/subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryNodeFactory.java deleted file mode 100644 index 1a76e22a..00000000 --- a/subprojects/store-query-viatra/src/main/java/org/eclipse/viatra/query/runtime/rete/network/RefineryNodeFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.viatra.query.runtime.rete.network; - -import org.apache.log4j.Logger; -import org.eclipse.viatra.query.runtime.rete.recipes.ReteNodeRecipe; -import org.eclipse.viatra.query.runtime.rete.traceability.TraceInfo; -import tools.refinery.store.query.viatra.internal.rete.network.RefineryNodeFactoryExtensions; - -/** - * This class overrides some RETE node types from {@link NodeFactory}. - *

- * Since {@link NodeFactory} is package-private, this class has to be in the - * {@code org.eclipse.viatra.query.runtime.rete.network} package as well. - * However, due to JAR signature verification errors, this class cannot be loaded directly - * and has to be loaded at runtime as a byte array instead. - */ -@SuppressWarnings("unused") -class RefineryNodeFactory extends NodeFactory { - private final RefineryNodeFactoryExtensions extensions = new RefineryNodeFactoryExtensions(); - - public RefineryNodeFactory(Logger logger) { - super(logger); - } - - @Override - public Supplier createNode(ReteContainer reteContainer, ReteNodeRecipe recipe, TraceInfo... traces) { - var extendedResult = extensions.createNode(reteContainer, recipe, traces); - if (extendedResult != null) { - return extendedResult; - } - return super.createNode(reteContainer, recipe, traces); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java index 66279c94..d31325f1 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java @@ -5,9 +5,9 @@ */ package tools.refinery.store.query.viatra; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; -import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import tools.refinery.viatra.runtime.api.ViatraQueryEngineOptions; +import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendFactory; +import tools.refinery.viatra.runtime.matchers.backend.QueryEvaluationHint; import tools.refinery.store.model.ModelStore; import tools.refinery.store.query.ModelQueryBuilder; import tools.refinery.store.query.dnf.AnyQuery; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryStoreAdapter.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryStoreAdapter.java index da6d7bd5..588c00d4 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryStoreAdapter.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryStoreAdapter.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; +import tools.refinery.viatra.runtime.api.ViatraQueryEngineOptions; import tools.refinery.store.model.Model; import tools.refinery.store.query.ModelQueryStoreAdapter; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java index d1a65a89..9303cae6 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/RelationalScope.java @@ -6,10 +6,10 @@ package tools.refinery.store.query.viatra.internal; import org.apache.log4j.Logger; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.scope.IEngineContext; -import org.eclipse.viatra.query.runtime.api.scope.IIndexingErrorListener; -import org.eclipse.viatra.query.runtime.api.scope.QueryScope; +import tools.refinery.viatra.runtime.api.ViatraQueryEngine; +import tools.refinery.viatra.runtime.api.scope.IEngineContext; +import tools.refinery.viatra.runtime.api.scope.IIndexingErrorListener; +import tools.refinery.viatra.runtime.api.scope.QueryScope; import tools.refinery.store.query.viatra.internal.context.RelationalEngineContext; public class RelationalScope extends QueryScope { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java index e17386e1..f1209f69 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java @@ -5,69 +5,46 @@ */ package tools.refinery.store.query.viatra.internal; -import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.GenericQueryGroup; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.internal.apiimpl.ViatraQueryEngineImpl; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; import tools.refinery.store.model.Model; import tools.refinery.store.model.ModelListener; -import tools.refinery.store.query.resultset.AnyResultSet; -import tools.refinery.store.query.resultset.EmptyResultSet; -import tools.refinery.store.query.resultset.ResultSet; import tools.refinery.store.query.dnf.AnyQuery; import tools.refinery.store.query.dnf.FunctionalQuery; import tools.refinery.store.query.dnf.Query; import tools.refinery.store.query.dnf.RelationalQuery; +import tools.refinery.store.query.resultset.AnyResultSet; +import tools.refinery.store.query.resultset.EmptyResultSet; +import tools.refinery.store.query.resultset.ResultSet; import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; import tools.refinery.store.query.viatra.internal.matcher.FunctionalViatraMatcher; import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher; import tools.refinery.store.query.viatra.internal.matcher.RelationalViatraMatcher; +import tools.refinery.viatra.runtime.api.AdvancedViatraQueryEngine; +import tools.refinery.viatra.runtime.api.GenericQueryGroup; +import tools.refinery.viatra.runtime.api.IQuerySpecification; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter, ModelListener { - private static final String DELAY_MESSAGE_DELIVERY_FIELD_NAME = "delayMessageDelivery"; - private static final MethodHandle SET_UPDATE_PROPAGATION_DELAYED_HANDLE; - private static final String QUERY_BACKENDS_FIELD_NAME = "queryBackends"; - private static final MethodHandle GET_QUERY_BACKENDS_HANDLE; - private final Model model; private final ViatraModelQueryStoreAdapterImpl storeAdapter; - private final ViatraQueryEngineImpl queryEngine; + private final AdvancedViatraQueryEngine queryEngine; private final Map resultSets; private boolean pendingChanges; - static { - try { - var lookup = MethodHandles.privateLookupIn(ViatraQueryEngineImpl.class, MethodHandles.lookup()); - SET_UPDATE_PROPAGATION_DELAYED_HANDLE = lookup.findSetter(ViatraQueryEngineImpl.class, - DELAY_MESSAGE_DELIVERY_FIELD_NAME, Boolean.TYPE); - GET_QUERY_BACKENDS_HANDLE = lookup.findGetter(ViatraQueryEngineImpl.class, QUERY_BACKENDS_FIELD_NAME, - Map.class); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new IllegalStateException("Cannot access private members of %s" - .formatted(ViatraQueryEngineImpl.class.getName()), e); - } - } - ViatraModelQueryAdapterImpl(Model model, ViatraModelQueryStoreAdapterImpl storeAdapter) { this.model = model; this.storeAdapter = storeAdapter; var scope = new RelationalScope(this); - queryEngine = (ViatraQueryEngineImpl) AdvancedViatraQueryEngine.createUnmanagedEngine(scope, + queryEngine = AdvancedViatraQueryEngine.createUnmanagedEngine(scope, storeAdapter.getEngineOptions()); var querySpecifications = storeAdapter.getQuerySpecifications(); GenericQueryGroup.of( Collections.>unmodifiableCollection(querySpecifications.values()).stream() ).prepare(queryEngine); + queryEngine.flushChanges(); var vacuousQueries = storeAdapter.getVacuousQueries(); resultSets = new LinkedHashMap<>(querySpecifications.size() + vacuousQueries.size()); for (var entry : querySpecifications.entrySet()) { @@ -79,7 +56,6 @@ public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter, Mod resultSets.put(vacuousQuery, new EmptyResultSet<>(this, (Query) vacuousQuery)); } - setUpdatePropagationDelayed(true); model.addListener(this); } @@ -95,30 +71,6 @@ public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter, Mod } } - private void setUpdatePropagationDelayed(boolean value) { - try { - SET_UPDATE_PROPAGATION_DELAYED_HANDLE.invokeExact(queryEngine, value); - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Cannot set %s".formatted(DELAY_MESSAGE_DELIVERY_FIELD_NAME), e); - } - } - - private Collection getQueryBackends() { - try { - @SuppressWarnings("unchecked") - var backendMap = (Map) GET_QUERY_BACKENDS_HANDLE.invokeExact(queryEngine); - return backendMap.values(); - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Cannot get %s".formatted(QUERY_BACKENDS_FIELD_NAME), e); - } - } - @Override public Model getModel() { return model; @@ -154,20 +106,7 @@ public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter, Mod @Override public void flushChanges() { - if (!queryEngine.isUpdatePropagationDelayed()) { - throw new IllegalStateException("Trying to flush changes while changes are already being flushed"); - } - if (!pendingChanges) { - return; - } - setUpdatePropagationDelayed(false); - try { - for (var queryBackend : getQueryBackends()) { - queryBackend.flushUpdates(); - } - } finally { - setUpdatePropagationDelayed(true); - } + queryEngine.flushChanges(); pendingChanges = false; } diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java index bf0708bf..c8aa067c 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java @@ -5,11 +5,6 @@ */ package tools.refinery.store.query.viatra.internal; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; -import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchHintOptions; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; -import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; import tools.refinery.store.adapter.AbstractModelAdapterBuilder; import tools.refinery.store.model.ModelStore; import tools.refinery.store.query.dnf.AnyQuery; @@ -23,7 +18,12 @@ import tools.refinery.store.query.viatra.internal.localsearch.FlatCostFunction; import tools.refinery.store.query.viatra.internal.localsearch.RelationalLocalSearchBackendFactory; import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher; import tools.refinery.store.query.viatra.internal.pquery.Dnf2PQuery; -import tools.refinery.store.query.viatra.internal.rete.RefineryReteBackendFactory; +import tools.refinery.viatra.runtime.api.IQuerySpecification; +import tools.refinery.viatra.runtime.api.ViatraQueryEngineOptions; +import tools.refinery.viatra.runtime.localsearch.matcher.integration.LocalSearchHintOptions; +import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendFactory; +import tools.refinery.viatra.runtime.matchers.backend.QueryEvaluationHint; +import tools.refinery.viatra.runtime.rete.matcher.ReteBackendFactory; import java.util.*; import java.util.function.Function; @@ -41,8 +41,8 @@ public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilderorg.eclipse.viatra.query.runtime.tabular.TabularEngineContext + * Copied from tools.refinery.viatra.runtime.tabular.TabularEngineContext */ public class DummyBaseIndexer implements IBaseIndex { DummyBaseIndexer() { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalEngineContext.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalEngineContext.java index 7220f8ca..f7d323ff 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalEngineContext.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalEngineContext.java @@ -5,9 +5,9 @@ */ package tools.refinery.store.query.viatra.internal.context; -import org.eclipse.viatra.query.runtime.api.scope.IBaseIndex; -import org.eclipse.viatra.query.runtime.api.scope.IEngineContext; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext; +import tools.refinery.viatra.runtime.api.scope.IBaseIndex; +import tools.refinery.viatra.runtime.api.scope.IEngineContext; +import tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; public class RelationalEngineContext implements IEngineContext { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java index 211eacb4..77d86a1c 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java @@ -5,10 +5,10 @@ */ package tools.refinery.store.query.viatra.internal.context; -import org.eclipse.viatra.query.runtime.matchers.context.AbstractQueryMetaContext; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication; -import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import tools.refinery.viatra.runtime.matchers.context.AbstractQueryMetaContext; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.context.InputKeyImplication; +import tools.refinery.viatra.runtime.matchers.context.common.JavaTransitiveInstancesKey; import tools.refinery.store.query.viatra.internal.pquery.SymbolViewWrapper; import tools.refinery.store.query.view.AnySymbolView; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java index df80a33e..d1fa5239 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java @@ -5,12 +5,12 @@ */ package tools.refinery.store.query.viatra.internal.context; -import org.eclipse.viatra.query.runtime.matchers.context.*; -import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; -import org.eclipse.viatra.query.runtime.matchers.util.Accuracy; +import tools.refinery.viatra.runtime.matchers.context.*; +import tools.refinery.viatra.runtime.matchers.tuple.ITuple; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; +import tools.refinery.viatra.runtime.matchers.util.Accuracy; import tools.refinery.store.model.Model; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; import tools.refinery.store.query.viatra.internal.pquery.SymbolViewWrapper; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendOperationExecutor.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendOperationExecutor.java index 37177cbf..fc75198c 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendOperationExecutor.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendOperationExecutor.java @@ -8,9 +8,9 @@ *******************************************************************************/ package tools.refinery.store.query.viatra.internal.localsearch; -import org.eclipse.viatra.query.runtime.localsearch.MatchingFrame; -import org.eclipse.viatra.query.runtime.localsearch.matcher.ISearchContext; -import org.eclipse.viatra.query.runtime.localsearch.operations.ISearchOperation.ISearchOperationExecutor; +import tools.refinery.viatra.runtime.localsearch.MatchingFrame; +import tools.refinery.viatra.runtime.localsearch.matcher.ISearchContext; +import tools.refinery.viatra.runtime.localsearch.operations.ISearchOperation.ISearchOperationExecutor; import java.util.Iterator; @@ -57,7 +57,7 @@ abstract class ExtendOperationExecutor implements ISearchOperationExecutor { } /** - * Fixed version of {@link org.eclipse.viatra.query.runtime.localsearch.operations.ExtendOperationExecutor#execute} + * Fixed version of {@link tools.refinery.viatra.runtime.localsearch.operations.ExtendOperationExecutor#execute} * that handles failed unification of variables correctly. * @param frame The matching frame to extend. * @param context The search context. diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendPositivePatternCall.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendPositivePatternCall.java index 9d48c785..b8b6b159 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendPositivePatternCall.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/ExtendPositivePatternCall.java @@ -8,15 +8,15 @@ *******************************************************************************/ package tools.refinery.store.query.viatra.internal.localsearch; -import org.eclipse.viatra.query.runtime.localsearch.MatchingFrame; -import org.eclipse.viatra.query.runtime.localsearch.matcher.ISearchContext; -import org.eclipse.viatra.query.runtime.localsearch.operations.IPatternMatcherOperation; -import org.eclipse.viatra.query.runtime.localsearch.operations.ISearchOperation; -import org.eclipse.viatra.query.runtime.localsearch.operations.util.CallInformation; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryResultProvider; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; -import org.eclipse.viatra.query.runtime.matchers.tuple.VolatileModifiableMaskedTuple; +import tools.refinery.viatra.runtime.localsearch.MatchingFrame; +import tools.refinery.viatra.runtime.localsearch.matcher.ISearchContext; +import tools.refinery.viatra.runtime.localsearch.operations.IPatternMatcherOperation; +import tools.refinery.viatra.runtime.localsearch.operations.ISearchOperation; +import tools.refinery.viatra.runtime.localsearch.operations.util.CallInformation; +import tools.refinery.viatra.runtime.matchers.backend.IQueryResultProvider; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; +import tools.refinery.viatra.runtime.matchers.tuple.VolatileModifiableMaskedTuple; import java.util.Iterator; import java.util.List; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/FlatCostFunction.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/FlatCostFunction.java index cc906f22..ce2a75bd 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/FlatCostFunction.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/FlatCostFunction.java @@ -5,12 +5,12 @@ */ package tools.refinery.store.query.viatra.internal.localsearch; -import org.eclipse.viatra.query.runtime.localsearch.planner.cost.IConstraintEvaluationContext; -import org.eclipse.viatra.query.runtime.localsearch.planner.cost.impl.StatisticsBasedConstraintCostFunction; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; -import org.eclipse.viatra.query.runtime.matchers.util.Accuracy; +import tools.refinery.viatra.runtime.localsearch.planner.cost.IConstraintEvaluationContext; +import tools.refinery.viatra.runtime.localsearch.planner.cost.impl.StatisticsBasedConstraintCostFunction; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; +import tools.refinery.viatra.runtime.matchers.util.Accuracy; import java.util.Optional; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/GenericTypeExtend.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/GenericTypeExtend.java index 96ac4a72..0ee69b88 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/GenericTypeExtend.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/GenericTypeExtend.java @@ -8,15 +8,15 @@ *******************************************************************************/ package tools.refinery.store.query.viatra.internal.localsearch; -import org.eclipse.viatra.query.runtime.localsearch.MatchingFrame; -import org.eclipse.viatra.query.runtime.localsearch.matcher.ISearchContext; -import org.eclipse.viatra.query.runtime.localsearch.operations.IIteratingSearchOperation; -import org.eclipse.viatra.query.runtime.localsearch.operations.ISearchOperation; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; -import org.eclipse.viatra.query.runtime.matchers.tuple.VolatileMaskedTuple; -import org.eclipse.viatra.query.runtime.matchers.util.Preconditions; +import tools.refinery.viatra.runtime.localsearch.MatchingFrame; +import tools.refinery.viatra.runtime.localsearch.matcher.ISearchContext; +import tools.refinery.viatra.runtime.localsearch.operations.IIteratingSearchOperation; +import tools.refinery.viatra.runtime.localsearch.operations.ISearchOperation; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; +import tools.refinery.viatra.runtime.matchers.tuple.VolatileMaskedTuple; +import tools.refinery.viatra.runtime.matchers.util.Preconditions; import java.util.*; import java.util.function.Function; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchBackendFactory.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchBackendFactory.java index 0c77f587..7d5401c6 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchBackendFactory.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchBackendFactory.java @@ -5,17 +5,17 @@ */ package tools.refinery.store.query.viatra.internal.localsearch; -import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.AbstractLocalSearchResultProvider; -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.localsearch.plan.IPlanProvider; -import org.eclipse.viatra.query.runtime.localsearch.plan.SimplePlanProvider; -import org.eclipse.viatra.query.runtime.matchers.backend.IMatcherCapability; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; -import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; +import tools.refinery.viatra.runtime.localsearch.matcher.integration.AbstractLocalSearchResultProvider; +import tools.refinery.viatra.runtime.localsearch.matcher.integration.LocalSearchBackend; +import tools.refinery.viatra.runtime.localsearch.matcher.integration.LocalSearchHints; +import tools.refinery.viatra.runtime.localsearch.plan.IPlanProvider; +import tools.refinery.viatra.runtime.localsearch.plan.SimplePlanProvider; +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.QueryEvaluationHint; +import tools.refinery.viatra.runtime.matchers.context.IQueryBackendContext; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; public class RelationalLocalSearchBackendFactory implements IQueryBackendFactory { public static final RelationalLocalSearchBackendFactory INSTANCE = new RelationalLocalSearchBackendFactory(); diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchResultProvider.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchResultProvider.java index da37be14..37d06864 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchResultProvider.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalLocalSearchResultProvider.java @@ -5,14 +5,14 @@ */ package tools.refinery.store.query.viatra.internal.localsearch; -import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.AbstractLocalSearchResultProvider; -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.localsearch.plan.IPlanProvider; -import org.eclipse.viatra.query.runtime.localsearch.planner.compiler.IOperationCompiler; -import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; +import tools.refinery.viatra.runtime.localsearch.matcher.integration.AbstractLocalSearchResultProvider; +import tools.refinery.viatra.runtime.localsearch.matcher.integration.LocalSearchBackend; +import tools.refinery.viatra.runtime.localsearch.matcher.integration.LocalSearchHints; +import tools.refinery.viatra.runtime.localsearch.plan.IPlanProvider; +import tools.refinery.viatra.runtime.localsearch.planner.compiler.IOperationCompiler; +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; class RelationalLocalSearchResultProvider extends AbstractLocalSearchResultProvider { public RelationalLocalSearchResultProvider(LocalSearchBackend backend, IQueryBackendContext context, PQuery query, diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalOperationCompiler.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalOperationCompiler.java index f76ef486..37f264ae 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalOperationCompiler.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/localsearch/RelationalOperationCompiler.java @@ -5,16 +5,16 @@ */ package tools.refinery.store.query.viatra.internal.localsearch; -import org.eclipse.viatra.query.runtime.localsearch.operations.generic.GenericTypeExtendSingleValue; -import org.eclipse.viatra.query.runtime.localsearch.operations.util.CallInformation; -import org.eclipse.viatra.query.runtime.localsearch.planner.compiler.GenericOperationCompiler; -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.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; +import tools.refinery.viatra.runtime.localsearch.operations.generic.GenericTypeExtendSingleValue; +import tools.refinery.viatra.runtime.localsearch.operations.util.CallInformation; +import tools.refinery.viatra.runtime.localsearch.planner.compiler.GenericOperationCompiler; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext; +import tools.refinery.viatra.runtime.matchers.psystem.PVariable; +import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; import java.util.*; @@ -52,7 +52,7 @@ public class RelationalOperationCompiler extends GenericOperationCompiler { unboundVariables.iterator().next())); } else { // Use a fixed version of - // {@code org.eclipse.viatra.query.runtime.localsearch.operations.generic.GenericTypeExtend} that handles + // {@code tools.refinery.viatra.runtime.localsearch.operations.generic.GenericTypeExtend} that handles // failed unification of variables correctly. operations.add(new GenericTypeExtend(inputKey, positions, callMask, indexerMask, unboundVariables)); } @@ -62,7 +62,7 @@ public class RelationalOperationCompiler extends GenericOperationCompiler { protected void createExtend(PositivePatternCall pCall, Map variableMapping) { CallInformation information = CallInformation.create(pCall, variableMapping, variableBindings.get(pCall)); // Use a fixed version of - // {@code org.eclipse.viatra.query.runtime.localsearch.operations.extend.ExtendPositivePatternCall} that handles + // {@code tools.refinery.viatra.runtime.localsearch.operations.extend.ExtendPositivePatternCall} that handles // failed unification of variables correctly. operations.add(new ExtendPositivePatternCall(information)); dependencies.add(information.getCallWithAdornment()); diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/AbstractViatraMatcher.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/AbstractViatraMatcher.java index 99b0a3d8..c4a5a236 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/AbstractViatraMatcher.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/AbstractViatraMatcher.java @@ -5,8 +5,8 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryResultProvider; -import org.eclipse.viatra.query.runtime.matchers.backend.IUpdateable; +import tools.refinery.viatra.runtime.matchers.backend.IQueryResultProvider; +import tools.refinery.viatra.runtime.matchers.backend.IUpdateable; import tools.refinery.store.query.dnf.Query; import tools.refinery.store.query.resultset.AbstractResultSet; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalCursor.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalCursor.java index 47efb2aa..44038669 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalCursor.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalCursor.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.rete.index.IterableIndexer; +import tools.refinery.viatra.runtime.rete.index.IterableIndexer; import tools.refinery.store.map.Cursor; import tools.refinery.store.tuple.Tuple; @@ -13,7 +13,7 @@ import java.util.Iterator; class FunctionalCursor implements Cursor { private final IterableIndexer indexer; - private final Iterator iterator; + private final Iterator iterator; private boolean terminated; private Tuple key; private T value; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalViatraMatcher.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalViatraMatcher.java index db4740cd..fb9e4df6 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalViatraMatcher.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/FunctionalViatraMatcher.java @@ -5,10 +5,10 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; -import org.eclipse.viatra.query.runtime.rete.index.IterableIndexer; -import org.eclipse.viatra.query.runtime.rete.matcher.RetePatternMatcher; +import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; +import tools.refinery.viatra.runtime.rete.index.IterableIndexer; +import tools.refinery.viatra.runtime.rete.matcher.RetePatternMatcher; import tools.refinery.store.map.Cursor; import tools.refinery.store.query.dnf.FunctionalQuery; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; @@ -17,9 +17,9 @@ import tools.refinery.store.tuple.Tuple; /** * Directly access the tuples inside a VIATRA pattern matcher.

* This class neglects calling - * {@link org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext#wrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)} + * {@link tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext#wrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)} * and - * {@link org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext#unwrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)}, + * {@link tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext#unwrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)}, * because {@link tools.refinery.store.query.viatra.internal.context.RelationalRuntimeContext} provides a trivial * implementation for these methods. * Using this class with any other runtime context may lead to undefined behavior. @@ -37,7 +37,7 @@ public class FunctionalViatraMatcher extends AbstractViatraMatcher { emptyMask = TupleMask.empty(arityWithOutput); omitOutputMask = TupleMask.omit(arity, arityWithOutput); if (backend instanceof RetePatternMatcher reteBackend) { - var maybeIterableOmitOutputIndexer = IndexerUtils.getIndexer(reteBackend, omitOutputMask); + var maybeIterableOmitOutputIndexer = reteBackend.getInternalIndexer(omitOutputMask); if (maybeIterableOmitOutputIndexer instanceof IterableIndexer iterableOmitOutputIndexer) { omitOutputIndexer = iterableOmitOutputIndexer; } else { @@ -76,7 +76,7 @@ public class FunctionalViatraMatcher extends AbstractViatraMatcher { } @Override - public void update(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple updateElement, boolean isInsertion) { + public void update(tools.refinery.viatra.runtime.matchers.tuple.Tuple updateElement, boolean isInsertion) { var key = MatcherUtils.keyToRefineryTuple(updateElement); var value = MatcherUtils.getValue(updateElement); if (isInsertion) { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/IndexerUtils.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/IndexerUtils.java deleted file mode 100644 index 15f00b2d..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/IndexerUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.matcher; - -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; -import org.eclipse.viatra.query.runtime.rete.index.Indexer; -import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; -import org.eclipse.viatra.query.runtime.rete.matcher.RetePatternMatcher; -import org.eclipse.viatra.query.runtime.rete.traceability.RecipeTraceInfo; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; - -final class IndexerUtils { - private static final MethodHandle GET_ENGINE_HANDLE; - private static final MethodHandle GET_PRODUCTION_NODE_TRACE_HANDLE; - private static final MethodHandle ACCESS_PROJECTION_HANDLE; - - static { - try { - var lookup = MethodHandles.privateLookupIn(RetePatternMatcher.class, MethodHandles.lookup()); - GET_ENGINE_HANDLE = lookup.findGetter(RetePatternMatcher.class, "engine", ReteEngine.class); - GET_PRODUCTION_NODE_TRACE_HANDLE = lookup.findGetter(RetePatternMatcher.class, "productionNodeTrace", - RecipeTraceInfo.class); - ACCESS_PROJECTION_HANDLE = lookup.findVirtual(ReteEngine.class, "accessProjection", - MethodType.methodType(Indexer.class, RecipeTraceInfo.class, TupleMask.class)); - } catch (IllegalAccessException | NoSuchFieldException | NoSuchMethodException e) { - throw new IllegalStateException("Cannot access private members of %s" - .formatted(RetePatternMatcher.class.getPackageName()), e); - } - } - - private IndexerUtils() { - throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); - } - - public static Indexer getIndexer(RetePatternMatcher backend, TupleMask mask) { - try { - var engine = (ReteEngine) GET_ENGINE_HANDLE.invokeExact(backend); - var trace = (RecipeTraceInfo) GET_PRODUCTION_NODE_TRACE_HANDLE.invokeExact(backend); - return (Indexer) ACCESS_PROJECTION_HANDLE.invokeExact(engine, trace, mask); - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Cannot access matcher for mask " + mask, e); - } - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/MatcherUtils.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/MatcherUtils.java index 6e24812a..6cda23cd 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/MatcherUtils.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/MatcherUtils.java @@ -5,8 +5,8 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import tools.refinery.viatra.runtime.matchers.tuple.ITuple; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; import org.jetbrains.annotations.Nullable; import tools.refinery.store.tuple.*; @@ -17,7 +17,7 @@ final class MatcherUtils { throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); } - public static org.eclipse.viatra.query.runtime.matchers.tuple.Tuple toViatraTuple(Tuple refineryTuple) { + public static tools.refinery.viatra.runtime.matchers.tuple.Tuple toViatraTuple(Tuple refineryTuple) { if (refineryTuple instanceof Tuple0) { return Tuples.staticArityFlatTupleOf(); } else if (refineryTuple instanceof Tuple1) { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RawPatternMatcher.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RawPatternMatcher.java index 5b82c4b7..c0be70ba 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RawPatternMatcher.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RawPatternMatcher.java @@ -5,9 +5,9 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.api.GenericPatternMatcher; -import org.eclipse.viatra.query.runtime.api.GenericQuerySpecification; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryResultProvider; +import tools.refinery.viatra.runtime.api.GenericPatternMatcher; +import tools.refinery.viatra.runtime.api.GenericQuerySpecification; +import tools.refinery.viatra.runtime.matchers.backend.IQueryResultProvider; public class RawPatternMatcher extends GenericPatternMatcher { public RawPatternMatcher(GenericQuerySpecification specification) { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalCursor.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalCursor.java index 1dc8f5db..53475218 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalCursor.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalCursor.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; +import tools.refinery.viatra.runtime.matchers.tuple.ITuple; import tools.refinery.store.map.Cursor; import tools.refinery.store.tuple.Tuple; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalViatraMatcher.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalViatraMatcher.java index ac95dcc0..da75e864 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalViatraMatcher.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/RelationalViatraMatcher.java @@ -5,10 +5,10 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; -import org.eclipse.viatra.query.runtime.rete.index.Indexer; -import org.eclipse.viatra.query.runtime.rete.matcher.RetePatternMatcher; +import tools.refinery.viatra.runtime.matchers.tuple.TupleMask; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; +import tools.refinery.viatra.runtime.rete.index.Indexer; +import tools.refinery.viatra.runtime.rete.matcher.RetePatternMatcher; import tools.refinery.store.map.Cursor; import tools.refinery.store.map.Cursors; import tools.refinery.store.query.dnf.RelationalQuery; @@ -18,9 +18,9 @@ import tools.refinery.store.tuple.Tuple; /** * Directly access the tuples inside a VIATRA pattern matcher.

* This class neglects calling - * {@link org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext#wrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)} + * {@link tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext#wrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)} * and - * {@link org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext#unwrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)}, + * {@link tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContext#unwrapTuple(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple)}, * because {@link tools.refinery.store.query.viatra.internal.context.RelationalRuntimeContext} provides a trivial * implementation for these methods. * Using this class with any other runtime context may lead to undefined behavior. @@ -37,7 +37,7 @@ public class RelationalViatraMatcher extends AbstractViatraMatcher { emptyMask = TupleMask.empty(arity); identityMask = TupleMask.identity(arity); if (backend instanceof RetePatternMatcher reteBackend) { - emptyMaskIndexer = IndexerUtils.getIndexer(reteBackend, emptyMask); + emptyMaskIndexer = reteBackend.getInternalIndexer(emptyMask); } else { emptyMaskIndexer = null; } @@ -73,7 +73,7 @@ public class RelationalViatraMatcher extends AbstractViatraMatcher { } @Override - public void update(org.eclipse.viatra.query.runtime.matchers.tuple.Tuple updateElement, boolean isInsertion) { + public void update(tools.refinery.viatra.runtime.matchers.tuple.Tuple updateElement, boolean isInsertion) { var key = MatcherUtils.toRefineryTuple(updateElement); notifyChange(key, !isInsertion, isInsertion); } diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/UnsafeFunctionalCursor.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/UnsafeFunctionalCursor.java index b0b507fe..093ade96 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/UnsafeFunctionalCursor.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/matcher/UnsafeFunctionalCursor.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.matcher; -import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; +import tools.refinery.viatra.runtime.matchers.tuple.ITuple; import tools.refinery.store.map.Cursor; import tools.refinery.store.tuple.Tuple; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java index 5dde41be..ada154d4 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; import tools.refinery.store.query.term.Term; class CheckEvaluator extends TermEvaluator { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java index af3bf32e..492bd054 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java @@ -5,24 +5,6 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; -import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.BoundAggregator; -import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.*; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; import tools.refinery.store.query.Constraint; import tools.refinery.store.query.dnf.Dnf; import tools.refinery.store.query.dnf.DnfClause; @@ -34,6 +16,22 @@ import tools.refinery.store.query.term.StatelessAggregator; import tools.refinery.store.query.term.Variable; import tools.refinery.store.query.view.AnySymbolView; import tools.refinery.store.util.CycleDetectingMapper; +import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendFactory; +import tools.refinery.viatra.runtime.matchers.backend.QueryEvaluationHint; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.psystem.PBody; +import tools.refinery.viatra.runtime.matchers.psystem.PVariable; +import tools.refinery.viatra.runtime.matchers.psystem.aggregations.BoundAggregator; +import tools.refinery.viatra.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; +import tools.refinery.viatra.runtime.matchers.psystem.annotations.PAnnotation; +import tools.refinery.viatra.runtime.matchers.psystem.basicdeferred.*; +import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.*; +import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.Connectivity; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameterDirection; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; import java.util.ArrayList; import java.util.HashMap; @@ -42,7 +40,6 @@ import java.util.Map; import java.util.function.Function; public class Dnf2PQuery { - private static final Object P_CONSTRAINT_LOCK = new Object(); private final CycleDetectingMapper mapper = new CycleDetectingMapper<>(Dnf::name, this::doTranslate); private final QueryWrapperFactory wrapperFactory = new QueryWrapperFactory(this); @@ -91,22 +88,17 @@ public class Dnf2PQuery { pQuery.addAnnotation(functionalDependencyAnnotation); } - // The constructor of {@link org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint} mutates - // global static state (nextID) without locking. Therefore, we need to synchronize before creating - // any query literals to avoid a data race. - synchronized (P_CONSTRAINT_LOCK) { - for (DnfClause clause : dnfQuery.getClauses()) { - PBody body = new PBody(pQuery); - List parameterExports = new ArrayList<>(); - for (var parameter : dnfQuery.getSymbolicParameters()) { - PVariable pVar = body.getOrCreateVariableByName(parameter.getVariable().getUniqueName()); - parameterExports.add(new ExportedParameter(body, pVar, parameters.get(parameter))); - } - body.setSymbolicParameters(parameterExports); - pQuery.addBody(body); - for (Literal literal : clause.literals()) { - translateLiteral(literal, body); - } + for (DnfClause clause : dnfQuery.getClauses()) { + PBody body = new PBody(pQuery); + List parameterExports = new ArrayList<>(); + for (var parameter : dnfQuery.getSymbolicParameters()) { + PVariable pVar = body.getOrCreateVariableByName(parameter.getVariable().getUniqueName()); + parameterExports.add(new ExportedParameter(body, pVar, parameters.get(parameter))); + } + body.setSymbolicParameters(parameterExports); + pQuery.addBody(body); + for (Literal literal : clause.literals()) { + translateLiteral(literal, body); } } @@ -252,6 +244,10 @@ public class Dnf2PQuery { private void translateRepresentativeElectionLiteral(RepresentativeElectionLiteral literal, PBody body) { var substitution = translateSubstitution(literal.getArguments(), body); var pattern = wrapConstraintWithIdentityArguments(literal.getTarget()); - new RepresentativeElectionConstraint(body, substitution, pattern, literal.getConnectivity()); + var connectivity = switch (literal.getConnectivity()) { + case WEAK -> Connectivity.WEAK; + case STRONG -> Connectivity.STRONG; + }; + new RepresentativeElectionConstraint(body, substitution, pattern, connectivity); } } diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java index 502813e1..d21131e5 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java @@ -5,17 +5,17 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.psystem.PBody; +import tools.refinery.viatra.runtime.matchers.psystem.PVariable; +import tools.refinery.viatra.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PVisibility; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; import tools.refinery.store.query.Constraint; import tools.refinery.store.query.dnf.Dnf; import tools.refinery.store.query.dnf.DnfUtils; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java index 255738c5..06644bf2 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java @@ -5,14 +5,14 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.api.GenericQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.scope.QueryScope; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import tools.refinery.viatra.runtime.api.GenericQuerySpecification; +import tools.refinery.viatra.runtime.api.ViatraQueryEngine; +import tools.refinery.viatra.runtime.api.scope.QueryScope; +import tools.refinery.viatra.runtime.matchers.psystem.PBody; +import tools.refinery.viatra.runtime.matchers.psystem.annotations.PAnnotation; +import tools.refinery.viatra.runtime.matchers.psystem.queries.BasePQuery; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter; +import tools.refinery.viatra.runtime.matchers.psystem.queries.PVisibility; import tools.refinery.store.query.viatra.internal.RelationalScope; import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java deleted file mode 100644 index e146213e..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.pquery; - -import org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext; -import org.eclipse.viatra.query.runtime.matchers.psystem.*; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import tools.refinery.store.query.literal.Connectivity; - -import java.util.Set; - -public class RepresentativeElectionConstraint extends KeyedEnumerablePConstraint - implements IQueryReference, ITypeInfoProviderConstraint { - private final Connectivity connectivity; - - public RepresentativeElectionConstraint(PBody pBody, Tuple variablesTuple, PQuery supplierKey, - Connectivity connectivity) { - super(pBody, variablesTuple, supplierKey); - this.connectivity = connectivity; - } - - public Connectivity getConnectivity() { - return connectivity; - } - - @Override - public PQuery getReferredQuery() { - return supplierKey; - } - - @Override - public Set getImpliedJudgements(IQueryMetaContext context) { - return PositivePatternCall.getTypesImpliedByCall(supplierKey, variablesTuple); - } - - @Override - protected String keyToString() { - return supplierKey.getFullyQualifiedName() + "#representative"; - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java index 461416f7..ba99cf9a 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; +import tools.refinery.viatra.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; import tools.refinery.store.query.term.StatefulAggregate; import tools.refinery.store.query.term.StatefulAggregator; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java index 49175d75..bf2c2f4f 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; +import tools.refinery.viatra.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; import tools.refinery.store.query.term.StatelessAggregator; import java.util.stream.Stream; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java index a777613e..a774404e 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.context.common.BaseInputKeyWrapper; +import tools.refinery.viatra.runtime.matchers.context.common.BaseInputKeyWrapper; import tools.refinery.store.query.view.AnySymbolView; public class SymbolViewWrapper extends BaseInputKeyWrapper { diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java index 1187f57a..5df861a6 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java @@ -5,8 +5,8 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; -import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import tools.refinery.viatra.runtime.matchers.psystem.IExpressionEvaluator; +import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; import tools.refinery.store.query.term.Term; import tools.refinery.store.query.term.Variable; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java index 62cb8b3a..b9ae8ab2 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; import tools.refinery.store.query.term.DataVariable; import tools.refinery.store.query.valuation.Valuation; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyCopier.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyCopier.java deleted file mode 100644 index a833a37b..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyCopier.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.pquery.rewriter; - -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.IRewriterTraceCollector; -import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyCopier; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; -import tools.refinery.store.query.viatra.internal.pquery.RepresentativeElectionConstraint; - -public class RefineryPBodyCopier extends PBodyCopier { - public RefineryPBodyCopier(PBody body, IRewriterTraceCollector traceCollector) { - super(body, traceCollector); - } - - @Override - protected void copyConstraint(PConstraint constraint) { - if (constraint instanceof RepresentativeElectionConstraint representativeElectionConstraint) { - copyRepresentativeElectionConstraint(representativeElectionConstraint); - } else { - super.copyConstraint(constraint); - } - } - - private void copyRepresentativeElectionConstraint(RepresentativeElectionConstraint constraint) { - var mappedVariables = extractMappedVariables(constraint); - var variablesTuple = Tuples.flatTupleOf((Object[]) mappedVariables); - addTrace(constraint, new RepresentativeElectionConstraint(body, variablesTuple, constraint.getReferredQuery(), - constraint.getConnectivity())); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyNormalizer.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyNormalizer.java deleted file mode 100644 index ed85a843..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyNormalizer.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004-2010 Gabor Bergmann and Daniel Varro - * Copyright (c) 2023 The Refinery Authors - * 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.store.query.viatra.internal.pquery.rewriter; - -import org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; -import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyCopier; -import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyNormalizer; - -import java.util.LinkedHashSet; -import java.util.Set; - -public class RefineryPBodyNormalizer extends PBodyNormalizer { - public RefineryPBodyNormalizer(IQueryMetaContext context) { - super(context); - } - - @Override - public PDisjunction rewrite(PDisjunction disjunction) { - Set normalizedBodies = new LinkedHashSet<>(); - for (PBody body : disjunction.getBodies()) { - PBodyCopier copier = new RefineryPBodyCopier(body, getTraceCollector()); - PBody modifiedBody = copier.getCopiedBody(); - normalizeBody(modifiedBody); - normalizedBodies.add(modifiedBody); - modifiedBody.setStatus(PQuery.PQueryStatus.OK); - } - return new PDisjunction(normalizedBodies); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefinerySurrogateQueryRewriter.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefinerySurrogateQueryRewriter.java deleted file mode 100644 index dc288ba0..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefinerySurrogateQueryRewriter.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010-2015, Zoltan Ujhelyi, Istvan Rath and Daniel Varro - * Copyright (c) 2023 The Refinery Authors - * 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.store.query.viatra.internal.pquery.rewriter; - -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.context.surrogate.SurrogateQueryRegistry; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; -import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyCopier; -import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PDisjunctionRewriter; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; - -import java.util.LinkedHashSet; -import java.util.Set; - -public class RefinerySurrogateQueryRewriter extends PDisjunctionRewriter { - @Override - public PDisjunction rewrite(PDisjunction disjunction) { - Set replacedBodies = new LinkedHashSet<>(); - for (PBody body : disjunction.getBodies()) { - PBodyCopier copier = new RefineryPBodyCopier(body, getTraceCollector()) { - - @Override - protected void copyTypeConstraint(TypeConstraint typeConstraint) { - PVariable[] mappedVariables = extractMappedVariables(typeConstraint); - Tuple variablesTuple = Tuples.flatTupleOf((Object[]) mappedVariables); - final IInputKey supplierKey = typeConstraint.getSupplierKey(); - if (SurrogateQueryRegistry.instance().hasSurrogateQueryFQN(supplierKey)) { - PQuery surrogateQuery = SurrogateQueryRegistry.instance().getSurrogateQuery(supplierKey); - if (surrogateQuery == null) { - throw new IllegalStateException("Surrogate query for feature %s not found" - .formatted(supplierKey.getPrettyPrintableName())); - } - addTrace(typeConstraint, new PositivePatternCall(getCopiedBody(), variablesTuple, - surrogateQuery)); - } else { - addTrace(typeConstraint, new TypeConstraint(getCopiedBody(), variablesTuple, supplierKey)); - } - } - }; - PBody modifiedBody = copier.getCopiedBody(); - replacedBodies.add(modifiedBody); - modifiedBody.setStatus(PQuery.PQueryStatus.OK); - } - return new PDisjunction(replacedBodies); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteBackendFactory.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteBackendFactory.java deleted file mode 100644 index 517e511a..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteBackendFactory.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010-2014, Bergmann Gabor, Istvan Rath and Daniel Varro - * Copyright (c) 2023 The Refinery Authors - * 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.store.query.viatra.internal.rete; - -import org.eclipse.viatra.query.runtime.matchers.backend.*; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; -import org.eclipse.viatra.query.runtime.rete.construction.plancompiler.ReteRecipeCompiler; -import org.eclipse.viatra.query.runtime.rete.matcher.IncrementalMatcherCapability; -import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; -import org.eclipse.viatra.query.runtime.rete.matcher.TimelyConfiguration; -import org.eclipse.viatra.query.runtime.rete.util.Options; - -// Singleton implementations follows the VIATRA implementation. -@SuppressWarnings("squid:S6548") -public class RefineryReteBackendFactory implements IQueryBackendFactory { - /** - * EXPERIMENTAL - */ - protected static final int RETE_THREADS = 0; - - /** - * @since 2.0 - */ - public static final RefineryReteBackendFactory INSTANCE = new RefineryReteBackendFactory(); - - /** - * @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 RefineryReteEngine(context, RETE_THREADS, deleteAndReDeriveEvaluation, timelyConfiguration); - IQueryBackendHintProvider hintConfiguration = engine.getHintConfiguration(); - ReteRecipeCompiler compiler = new RefineryReteRecipeCompiler( - 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 getBackendClass() { - return ReteEngine.class; - } - - @Override - public int hashCode() { - return RefineryReteBackendFactory.class.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - return obj instanceof RefineryReteBackendFactory; - } - - /** - * @since 1.4 - */ - @Override - public IMatcherCapability calculateRequiredCapability(PQuery query, QueryEvaluationHint hint) { - return new IncrementalMatcherCapability(); - } - - @Override - public boolean isCaching() { - return true; - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteEngine.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteEngine.java deleted file mode 100644 index c088219b..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteEngine.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete; - -import org.apache.log4j.Logger; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext; -import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; -import org.eclipse.viatra.query.runtime.rete.matcher.TimelyConfiguration; -import org.eclipse.viatra.query.runtime.rete.network.Network; -import org.eclipse.viatra.query.runtime.rete.network.NodeProvisioner; -import org.eclipse.viatra.query.runtime.rete.network.ReteContainer; - -import java.io.IOException; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; - -public class RefineryReteEngine extends ReteEngine { - private static final MethodHandle REFINERY_NODE_FACTORY_CONSTRUCTOR; - private static final MethodHandle REFINERY_CONNECTION_FACTORY_CONSTRUCTOR; - private static final MethodHandle NETWORK_NODE_FACTORY_SETTER; - private static final MethodHandle RETE_CONTAINER_CONNECTION_FACTORY_SETTER; - private static final MethodHandle NODE_PROVISIONER_NODE_FACTORY_SETTER; - private static final MethodHandle NODE_PROVISIONER_CONNECTION_FACTORY_SETTER; - - static { - MethodHandles.Lookup lookup; - try { - lookup = MethodHandles.privateLookupIn(Network.class, MethodHandles.lookup()); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Cannot create private lookup", e); - } - var refineryNodeFactoryClass = defineClassFromFile(lookup, "RefineryNodeFactory"); - var refinaryConnectionFactoryClass = defineClassFromFile(lookup, "RefineryConnectionFactory"); - try { - REFINERY_NODE_FACTORY_CONSTRUCTOR = lookup.findConstructor(refineryNodeFactoryClass, - MethodType.methodType(Void.TYPE, Logger.class)); - REFINERY_CONNECTION_FACTORY_CONSTRUCTOR = lookup.findConstructor(refinaryConnectionFactoryClass, - MethodType.methodType(Void.TYPE, ReteContainer.class)); - } catch (NoSuchMethodException | IllegalAccessException e) { - throw new IllegalStateException("Cannot get constructor", e); - } - var nodeFactoryClass = refineryNodeFactoryClass.getSuperclass(); - var connectionFactoryClass = refinaryConnectionFactoryClass.getSuperclass(); - try { - NETWORK_NODE_FACTORY_SETTER = lookup.findSetter(Network.class, "nodeFactory", nodeFactoryClass); - RETE_CONTAINER_CONNECTION_FACTORY_SETTER = lookup.findSetter(ReteContainer.class, "connectionFactory", - connectionFactoryClass); - NODE_PROVISIONER_NODE_FACTORY_SETTER = lookup.findSetter(NodeProvisioner.class, "nodeFactory", - nodeFactoryClass); - NODE_PROVISIONER_CONNECTION_FACTORY_SETTER = lookup.findSetter(NodeProvisioner.class, "connectionFactory", - connectionFactoryClass); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException("Cannot get field setter", e); - } - } - - private static Class defineClassFromFile(MethodHandles.Lookup lookup, String name) { - byte[] classBytes; - try (var resource = Network.class.getResourceAsStream(name + ".class")) { - if (resource == null) { - throw new IllegalStateException("Cannot find %s class file".formatted(name)); - } - classBytes = resource.readAllBytes(); - } catch (IOException e) { - throw new IllegalStateException("Cannot read %s class file".formatted(name), e); - } - Class clazz; - try { - clazz = lookup.defineClass(classBytes); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Cannot define %s class".formatted(name), e); - } - return clazz; - } - - public RefineryReteEngine(IQueryBackendContext context, int reteThreads, boolean deleteAndReDeriveEvaluation, - TimelyConfiguration timelyConfiguration) { - super(context, reteThreads, deleteAndReDeriveEvaluation, timelyConfiguration); - installFactories(); - } - - private void installFactories() { - var logger = getLogger(); - Object nodeFactory; - try { - nodeFactory = REFINERY_NODE_FACTORY_CONSTRUCTOR.invoke(logger); - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Cannot construct node factory", e); - } - try { - NETWORK_NODE_FACTORY_SETTER.invoke(reteNet, nodeFactory); - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Cannot set factory", e); - } - for (var container : reteNet.getContainers()) { - Object connectionFactory; - try { - connectionFactory = REFINERY_CONNECTION_FACTORY_CONSTRUCTOR.invoke(container); - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Cannot construct connection factory", e); - } - var provisioner = container.getProvisioner(); - try { - RETE_CONTAINER_CONNECTION_FACTORY_SETTER.invoke(container, connectionFactory); - NODE_PROVISIONER_NODE_FACTORY_SETTER.invoke(provisioner, nodeFactory); - NODE_PROVISIONER_CONNECTION_FACTORY_SETTER.invoke(provisioner, connectionFactory); - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Cannot set factory", e); - } - } - } - - @Override - public IQueryBackendFactory getFactory() { - return RefineryReteBackendFactory.INSTANCE; - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteRecipeCompiler.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteRecipeCompiler.java deleted file mode 100644 index fd1b48d8..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/RefineryReteRecipeCompiler.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010-2014, Bergmann Gabor, Istvan Rath and Daniel Varro - * Copyright (c) 2023 The Refinery Authors - * 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.store.query.viatra.internal.rete; - -import org.apache.log4j.Logger; -import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendHintProvider; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryCacheContext; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext; -import org.eclipse.viatra.query.runtime.matchers.planning.IQueryPlannerStrategy; -import org.eclipse.viatra.query.runtime.matchers.planning.SubPlan; -import org.eclipse.viatra.query.runtime.matchers.planning.operations.PApply; -import org.eclipse.viatra.query.runtime.matchers.planning.operations.PEnumerate; -import org.eclipse.viatra.query.runtime.matchers.psystem.EnumerablePConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.analysis.QueryAnalyzer; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; -import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PDisjunctionRewriterCacher; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.rete.construction.plancompiler.CompilerHelper; -import org.eclipse.viatra.query.runtime.rete.construction.plancompiler.ReteRecipeCompiler; -import org.eclipse.viatra.query.runtime.rete.matcher.TimelyConfiguration; -import org.eclipse.viatra.query.runtime.rete.recipes.ReteNodeRecipe; -import org.eclipse.viatra.query.runtime.rete.traceability.CompiledSubPlan; -import org.eclipse.viatra.query.runtime.rete.traceability.PlanningTrace; -import org.eclipse.viatra.query.runtime.rete.util.ReteHintOptions; -import org.jetbrains.annotations.Nullable; -import tools.refinery.store.query.viatra.internal.pquery.RepresentativeElectionConstraint; -import tools.refinery.store.query.viatra.internal.rete.recipe.RefineryRecipesFactory; -import tools.refinery.store.query.viatra.internal.pquery.rewriter.RefineryPBodyNormalizer; -import tools.refinery.store.query.viatra.internal.pquery.rewriter.RefinerySurrogateQueryRewriter; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.lang.reflect.Field; -import java.util.Map; - -// Since we don't modify VIATRA code, this is our last resort. -@SuppressWarnings("squid:S3011") -public class RefineryReteRecipeCompiler extends ReteRecipeCompiler { - private static final MethodHandle GET_SUB_PLAN_COMPILER_CACHE; - private static final MethodHandle GET_COMPILER_BACK_TRACE; - private static final Field NORMALIZER_FIELD; - private static final MethodHandle DO_COMPILE_DISPATCH; - private static final MethodHandle COMPILE_TO_NATURAL_JOIN; - private static final MethodHandle REFER_QUERY; - - static { - MethodHandles.Lookup lookup; - try { - lookup = MethodHandles.privateLookupIn(ReteRecipeCompiler.class, MethodHandles.lookup()); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Failed to create lookup", e); - } - try { - GET_SUB_PLAN_COMPILER_CACHE = lookup.findGetter(ReteRecipeCompiler.class, "subPlanCompilerCache", - Map.class); - GET_COMPILER_BACK_TRACE = lookup.findGetter(ReteRecipeCompiler.class, "compilerBackTrace", Map.class); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException("Failed to find getter", e); - } - - try { - NORMALIZER_FIELD = ReteRecipeCompiler.class.getDeclaredField("normalizer"); - } catch (NoSuchFieldException e) { - throw new IllegalStateException("Failed to find field", e); - } - NORMALIZER_FIELD.setAccessible(true); - - try { - DO_COMPILE_DISPATCH = lookup.findVirtual(ReteRecipeCompiler.class, "doCompileDispatch", - MethodType.methodType(CompiledSubPlan.class, SubPlan.class)); - COMPILE_TO_NATURAL_JOIN = lookup.findVirtual(ReteRecipeCompiler.class, "compileToNaturalJoin", - MethodType.methodType(CompiledSubPlan.class, SubPlan.class, PlanningTrace.class, - PlanningTrace.class)); - REFER_QUERY = lookup.findVirtual(ReteRecipeCompiler.class, "referQuery", - MethodType.methodType(PlanningTrace.class, PQuery.class, SubPlan.class, Tuple.class)); - } catch (NoSuchMethodException | IllegalAccessException e) { - throw new IllegalStateException("Failed to find method", e); - } - } - - private final Map subPlanCompilerCache; - private final Map compilerBackTrace; - - public RefineryReteRecipeCompiler(IQueryPlannerStrategy plannerStrategy, Logger logger, - IQueryMetaContext metaContext, IQueryCacheContext queryCacheContext, - IQueryBackendHintProvider hintProvider, QueryAnalyzer queryAnalyzer, - boolean deleteAndReDeriveEvaluation, TimelyConfiguration timelyEvaluation) { - super(plannerStrategy, logger, metaContext, queryCacheContext, hintProvider, queryAnalyzer, - deleteAndReDeriveEvaluation, timelyEvaluation); - - var normalizer = new PDisjunctionRewriterCacher(new RefinerySurrogateQueryRewriter(), - new RefineryPBodyNormalizer(metaContext) { - - @Override - protected boolean shouldExpandWeakenedAlternatives(PQuery query) { - var hint = hintProvider.getQueryEvaluationHint(query); - return ReteHintOptions.expandWeakenedAlternativeConstraints.getValueOrDefault(hint); - } - - }); - try { - // https://docs.oracle.com/javase/specs/jls/se17/html/jls-17.html#jls-17.5.3 - // "The object should not be made visible to other threads, nor should the final fields be read, - // until all updates to the final fields of the object are complete." - // The {@code super} constructor only sets but doesn't read the {@code normalizer} field, - // therefore this is fine. - NORMALIZER_FIELD.set(this, normalizer); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Failed to set private final field", e); - } - - try { - @SuppressWarnings("unchecked") - var cache = (Map) GET_SUB_PLAN_COMPILER_CACHE.invokeExact( - (ReteRecipeCompiler) this); - subPlanCompilerCache = cache; - @SuppressWarnings("unchecked") - var backTrace = (Map) GET_COMPILER_BACK_TRACE.invokeExact( - (ReteRecipeCompiler) this); - compilerBackTrace = backTrace; - } catch (Error e) { - // Fatal JVM errors should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Failed to access private fields", e); - } - } - - @Override - public CompiledSubPlan getCompiledForm(SubPlan plan) { - CompiledSubPlan compiled = subPlanCompilerCache.get(plan); - if (compiled == null) { - compiled = doCompileDispatchExtension(plan); - if (compiled == null) { - compiled = superDoCompileDispatch(plan); - } - subPlanCompilerCache.put(plan, compiled); - compilerBackTrace.put(compiled.getRecipe(), plan); - } - return compiled; - } - - @Nullable - private CompiledSubPlan doCompileDispatchExtension(SubPlan plan) { - var operation = plan.getOperation(); - if (operation instanceof PEnumerate enumerateOperation) { - return doCompileEnumerateExtension(enumerateOperation.getEnumerablePConstraint(), plan); - } else if (operation instanceof PApply applyOperation && - applyOperation.getPConstraint() instanceof EnumerablePConstraint constraint) { - var secondaryParent = doEnumerateDispatchExtension(plan, constraint); - if (secondaryParent != null) { - var primaryParent = getCompiledForm(plan.getParentPlans().get(0)); - return superCompileToNaturalJoin(plan, primaryParent, secondaryParent); - } - } - return null; - } - - @Nullable - private CompiledSubPlan doCompileEnumerateExtension(EnumerablePConstraint constraint, SubPlan plan) { - var coreTrace = doEnumerateDispatchExtension(plan, constraint); - if (coreTrace == null) { - return null; - } - var trimmedTrace = CompilerHelper.checkAndTrimEqualVariables(plan, coreTrace); - return trimmedTrace.cloneFor(plan); - } - - @Nullable - private PlanningTrace doEnumerateDispatchExtension(SubPlan plan, EnumerablePConstraint constraint) { - if (constraint instanceof RepresentativeElectionConstraint representativeElectionConstraint) { - return compileEnumerableExtension(plan, representativeElectionConstraint); - } - return null; - } - - private PlanningTrace compileEnumerableExtension(SubPlan plan, RepresentativeElectionConstraint constraint) { - var referredQuery = constraint.getSupplierKey(); - var callTrace = superReferQuery(referredQuery, plan, constraint.getVariablesTuple()); - var recipe = RefineryRecipesFactory.eINSTANCE.createRepresentativeElectionRecipe(); - recipe.setParent(callTrace.getRecipe()); - recipe.setConnectivity(constraint.getConnectivity()); - return new PlanningTrace(plan, CompilerHelper.convertVariablesTuple(constraint), recipe, callTrace); - } - - private CompiledSubPlan superDoCompileDispatch(SubPlan plan) { - try { - return (CompiledSubPlan) DO_COMPILE_DISPATCH.invokeExact((ReteRecipeCompiler) this, plan); - } catch (Error | RuntimeException e) { - // Fatal JVM errors and runtime exceptions should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Failed to call doCompileDispatch", e); - } - } - - private CompiledSubPlan superCompileToNaturalJoin(SubPlan plan, PlanningTrace leftCompiled, - PlanningTrace rightCompiled) { - try { - return (CompiledSubPlan) COMPILE_TO_NATURAL_JOIN.invokeExact((ReteRecipeCompiler) this, plan, - leftCompiled, rightCompiled); - } catch (Error | RuntimeException e) { - // Fatal JVM errors and runtime exceptions should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Failed to call compileToNaturalJoin", e); - } - } - - private PlanningTrace superReferQuery(PQuery query, SubPlan plan, Tuple actualParametersTuple) { - try { - return (PlanningTrace) REFER_QUERY.invokeExact((ReteRecipeCompiler) this, query, plan, - actualParametersTuple); - } catch (Error | RuntimeException e) { - // Fatal JVM errors and runtime exceptions should not be wrapped. - throw e; - } catch (Throwable e) { - throw new IllegalStateException("Failed to call referQuery", e); - } - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryConnectionFactoryExtensions.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryConnectionFactoryExtensions.java deleted file mode 100644 index 0fe5ee27..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryConnectionFactoryExtensions.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.network; - -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.rete.network.Node; -import org.eclipse.viatra.query.runtime.rete.network.ReteContainer; -import org.eclipse.viatra.query.runtime.rete.network.Supplier; -import org.eclipse.viatra.query.runtime.rete.remote.Address; -import org.eclipse.viatra.query.runtime.rete.traceability.RecipeTraceInfo; -import tools.refinery.store.query.viatra.internal.rete.recipe.RepresentativeElectionRecipe; - -import java.util.ArrayList; - -public class RefineryConnectionFactoryExtensions { - private final ReteContainer reteContainer; - - public RefineryConnectionFactoryExtensions(ReteContainer reteContainer) { - this.reteContainer = reteContainer; - } - - public boolean connectToParents(RecipeTraceInfo recipeTrace, Node freshNode) { - var recipe = recipeTrace.getRecipe(); - if (recipe instanceof RepresentativeElectionRecipe representativeElectionRecipe) { - connectToParents(representativeElectionRecipe, (RepresentativeElectionNode) freshNode); - return true; - } - return false; - } - - private void connectToParents(RepresentativeElectionRecipe recipe, RepresentativeElectionNode freshNode) { - var parentRecipe = recipe.getParent(); - // Apparently VIATRA ensures that this cast is safe, see - // {@link org.eclipse.viatra.query.runtime.rete.network.ConnectionFactory.connectToParent}. - @SuppressWarnings("unchecked") - var parentAddress = (Address) reteContainer.getNetwork() - .getExistingNodeByRecipe(parentRecipe); - var parentSupplier = reteContainer.getProvisioner().asSupplier(parentAddress); - var tuples = new ArrayList(); - parentSupplier.pullInto(tuples, true); - freshNode.reinitializeWith(tuples); - reteContainer.connect(parentSupplier, freshNode); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryNodeFactoryExtensions.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryNodeFactoryExtensions.java deleted file mode 100644 index 82b63a55..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RefineryNodeFactoryExtensions.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.network; - -import org.eclipse.viatra.query.runtime.rete.network.ReteContainer; -import org.eclipse.viatra.query.runtime.rete.network.Supplier; -import org.eclipse.viatra.query.runtime.rete.recipes.ReteNodeRecipe; -import org.eclipse.viatra.query.runtime.rete.traceability.TraceInfo; -import org.jetbrains.annotations.Nullable; -import tools.refinery.store.query.viatra.internal.rete.recipe.RepresentativeElectionRecipe; - -public class RefineryNodeFactoryExtensions { - @Nullable - public Supplier createNode(ReteContainer reteContainer, ReteNodeRecipe recipe, TraceInfo... traces) { - var result = instantiateNode(reteContainer, recipe); - if (result == null) { - return null; - } - for (var traceInfo : traces) { - result.assignTraceInfo(traceInfo); - } - return result; - } - - @Nullable - private Supplier instantiateNode(ReteContainer reteContainer, ReteNodeRecipe recipe) { - if (recipe instanceof RepresentativeElectionRecipe representativeElectionRecipe) { - return instantiateRepresentativeElectionNode(reteContainer, representativeElectionRecipe); - } - return null; - } - - private Supplier instantiateRepresentativeElectionNode(ReteContainer reteContainer, - RepresentativeElectionRecipe recipe) { - RepresentativeElectionAlgorithm.Factory algorithmFactory = switch (recipe.getConnectivity()) { - case STRONG -> StronglyConnectedComponentAlgorithm::new; - case WEAK -> WeaklyConnectedComponentAlgorithm::new; - }; - return new RepresentativeElectionNode(reteContainer, algorithmFactory); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionAlgorithm.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionAlgorithm.java deleted file mode 100644 index ff5c7158..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionAlgorithm.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.network; - -import org.eclipse.viatra.query.runtime.base.itc.graphimpl.Graph; -import org.eclipse.viatra.query.runtime.base.itc.igraph.IGraphObserver; -import org.eclipse.viatra.query.runtime.matchers.util.Direction; - -import java.util.*; - -public abstract class RepresentativeElectionAlgorithm implements IGraphObserver { - protected final Graph graph; - protected final Map representatives = new HashMap<>(); - protected final Map> components = new HashMap<>(); - private RepresentativeElectionNode observer; - - protected RepresentativeElectionAlgorithm(Graph graph) { - this.graph = graph; - initializeComponents(); - graph.attachObserver(this); - } - - protected abstract void initializeComponents(); - - protected void initializeSet(Set set) { - var iterator = set.iterator(); - if (!iterator.hasNext()) { - // Set is empty. - return; - } - var representative = iterator.next(); - for (var node : set) { - var oldRepresentative = representatives.put(node, representative); - if (oldRepresentative != null && !representative.equals(oldRepresentative)) { - throw new IllegalStateException("Node %s is already in a set represented by %s, cannot add it to %s" - .formatted(node, oldRepresentative, set)); - } - } - components.put(representative, set); - } - - protected void merge(Object leftRepresentative, Object rightRepresentative) { - if (leftRepresentative.equals(rightRepresentative)) { - return; - } - var leftSet = getComponent(leftRepresentative); - var rightSet = getComponent(rightRepresentative); - if (leftSet.size() < rightSet.size()) { - merge(rightRepresentative, rightSet, leftRepresentative, leftSet); - } else { - merge(leftRepresentative, leftSet, rightRepresentative, rightSet); - } - } - - private void merge(Object preservedRepresentative, Set preservedSet, Object removedRepresentative, - Set removedSet) { - components.remove(removedRepresentative); - for (var node : removedSet) { - representatives.put(node, preservedRepresentative); - preservedSet.add(node); - notifyToObservers(node, removedRepresentative, preservedRepresentative); - } - } - - protected void assignNewRepresentative(Object oldRepresentative, Set set) { - var iterator = set.iterator(); - if (!iterator.hasNext()) { - return; - } - var newRepresentative = iterator.next(); - components.put(newRepresentative, set); - for (var node : set) { - var oldRepresentativeOfNode = representatives.put(node, newRepresentative); - if (!oldRepresentative.equals(oldRepresentativeOfNode)) { - throw new IllegalArgumentException("Node %s was not represented by %s but by %s" - .formatted(node, oldRepresentative, oldRepresentativeOfNode)); - } - notifyToObservers(node, oldRepresentative, newRepresentative); - } - } - - public void setObserver(RepresentativeElectionNode observer) { - this.observer = observer; - } - - public Map> getComponents() { - return components; - } - - public Object getRepresentative(Object node) { - return representatives.get(node); - } - - public Set getComponent(Object representative) { - return components.get(representative); - } - - public void dispose() { - graph.detachObserver(this); - } - - @Override - public void nodeInserted(Object n) { - var component = new HashSet<>(1); - component.add(n); - initializeSet(component); - notifyToObservers(n, n, Direction.INSERT); - } - - @Override - public void nodeDeleted(Object n) { - var representative = representatives.remove(n); - if (!representative.equals(n)) { - throw new IllegalStateException("Trying to delete node with dangling edges"); - } - components.remove(representative); - notifyToObservers(n, representative, Direction.DELETE); - } - - protected void notifyToObservers(Object node, Object oldRepresentative, Object newRepresentative) { - notifyToObservers(node, oldRepresentative, Direction.DELETE); - notifyToObservers(node, newRepresentative, Direction.INSERT); - } - - protected void notifyToObservers(Object node, Object representative, Direction direction) { - if (observer != null) { - observer.tupleChanged(node, representative, direction); - } - } - - interface Factory { - RepresentativeElectionAlgorithm create(Graph graph); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionNode.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionNode.java deleted file mode 100644 index 701f6ffe..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/RepresentativeElectionNode.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010-2012, Tamas Szabo, Gabor Bergmann, Istvan Rath and Daniel Varro - * Copyright (c) 2023 The Refinery Authors - * 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.store.query.viatra.internal.rete.network; - -import org.eclipse.viatra.query.runtime.base.itc.graphimpl.Graph; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; -import org.eclipse.viatra.query.runtime.matchers.util.Clearable; -import org.eclipse.viatra.query.runtime.matchers.util.Direction; -import org.eclipse.viatra.query.runtime.matchers.util.timeline.Timeline; -import org.eclipse.viatra.query.runtime.rete.network.ReteContainer; -import org.eclipse.viatra.query.runtime.rete.network.communication.Timestamp; -import org.eclipse.viatra.query.runtime.rete.single.SingleInputNode; - -import java.util.Collection; -import java.util.Map; - -public class RepresentativeElectionNode extends SingleInputNode implements Clearable { - private final RepresentativeElectionAlgorithm.Factory algorithmFactory; - private Graph graph; - private RepresentativeElectionAlgorithm algorithm; - - public RepresentativeElectionNode(ReteContainer reteContainer, - RepresentativeElectionAlgorithm.Factory algorithmFactory) { - super(reteContainer); - this.algorithmFactory = algorithmFactory; - graph = new Graph<>(); - algorithm = algorithmFactory.create(graph); - algorithm.setObserver(this); - reteContainer.registerClearable(this); - } - - @Override - public void networkStructureChanged() { - if (reteContainer.isTimelyEvaluation() && reteContainer.getCommunicationTracker().isInRecursiveGroup(this)) { - throw new IllegalStateException(this + " cannot be used in recursive differential dataflow evaluation!"); - } - super.networkStructureChanged(); - } - - public void reinitializeWith(Collection tuples) { - algorithm.dispose(); - graph = new Graph<>(); - for (var tuple : tuples) { - insertEdge(tuple.get(0), tuple.get(1)); - } - algorithm = algorithmFactory.create(graph); - algorithm.setObserver(this); - } - - public void tupleChanged(Object source, Object representative, Direction direction) { - var tuple = Tuples.staticArityFlatTupleOf(source, representative); - propagateUpdate(direction, tuple, Timestamp.ZERO); - } - - @Override - public void clear() { - algorithm.dispose(); - graph = new Graph<>(); - algorithm = algorithmFactory.create(graph); - } - - @Override - public void update(Direction direction, Tuple updateElement, Timestamp timestamp) { - var source = updateElement.get(0); - var target = updateElement.get(1); - switch (direction) { - case INSERT -> insertEdge(source, target); - case DELETE -> deleteEdge(source, target); - default -> throw new IllegalArgumentException("Unknown direction: " + direction); - } - } - - private void insertEdge(Object source, Object target) { - graph.insertNode(source); - graph.insertNode(target); - graph.insertEdge(source, target); - } - - private void deleteEdge(Object source, Object target) { - graph.deleteEdgeIfExists(source, target); - if (isIsolated(source)) { - graph.deleteNode(source); - } - if (!source.equals(target) && isIsolated(target)) { - graph.deleteNode(target); - } - } - - private boolean isIsolated(Object node) { - return graph.getTargetNodes(node).isEmpty() && graph.getSourceNodes(node).isEmpty(); - } - - @Override - public void pullInto(Collection collector, boolean flush) { - for (var entry : algorithm.getComponents().entrySet()) { - var representative = entry.getKey(); - for (var node : entry.getValue()) { - collector.add(Tuples.staticArityFlatTupleOf(node, representative)); - } - } - } - - @Override - public void pullIntoWithTimeline(Map> collector, boolean flush) { - // Use all zero timestamps because this node cannot be used in recursive groups anyway. - for (var entry : algorithm.getComponents().entrySet()) { - var representative = entry.getKey(); - for (var node : entry.getValue()) { - collector.put(Tuples.staticArityFlatTupleOf(node, representative), Timestamp.INSERT_AT_ZERO_TIMELINE); - } - } - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/StronglyConnectedComponentAlgorithm.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/StronglyConnectedComponentAlgorithm.java deleted file mode 100644 index 11155f3e..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/StronglyConnectedComponentAlgorithm.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.network; - -import org.eclipse.viatra.query.runtime.base.itc.alg.misc.GraphHelper; -import org.eclipse.viatra.query.runtime.base.itc.alg.misc.bfs.BFS; -import org.eclipse.viatra.query.runtime.base.itc.alg.misc.scc.SCC; -import org.eclipse.viatra.query.runtime.base.itc.graphimpl.Graph; - -import java.util.Collection; -import java.util.Set; - -public class StronglyConnectedComponentAlgorithm extends RepresentativeElectionAlgorithm { - public StronglyConnectedComponentAlgorithm(Graph graph) { - super(graph); - } - - @Override - protected void initializeComponents() { - var computedSCCs = SCC.computeSCC(graph).getSccs(); - for (var computedSCC : computedSCCs) { - initializeSet(computedSCC); - } - } - - @Override - public void edgeInserted(Object source, Object target) { - var sourceRoot = getRepresentative(source); - var targetRoot = getRepresentative(target); - if (sourceRoot.equals(targetRoot)) { - // New edge does not change strongly connected components. - return; - } - if (BFS.isReachable(target, source, graph)) { - merge(sourceRoot, targetRoot); - } - } - - @Override - public void edgeDeleted(Object source, Object target) { - var sourceRoot = getRepresentative(source); - var targetRoot = getRepresentative(target); - if (!sourceRoot.equals(targetRoot)) { - // New edge does not change strongly connected components. - return; - } - var component = GraphHelper.getSubGraph(getComponent(sourceRoot), graph); - if (!BFS.isReachable(source, target, component)) { - var newSCCs = SCC.computeSCC(component).getSccs(); - split(sourceRoot, newSCCs); - } - } - - private void split(Object preservedRepresentative, Collection> sets) { - for (var set : sets) { - if (set.contains(preservedRepresentative)) { - components.put(preservedRepresentative, set); - } else { - assignNewRepresentative(preservedRepresentative, set); - } - } - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/WeaklyConnectedComponentAlgorithm.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/WeaklyConnectedComponentAlgorithm.java deleted file mode 100644 index 118004dd..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/network/WeaklyConnectedComponentAlgorithm.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.network; - -import org.eclipse.viatra.query.runtime.base.itc.graphimpl.Graph; - -import java.util.ArrayDeque; -import java.util.HashSet; -import java.util.Set; - -public class WeaklyConnectedComponentAlgorithm extends RepresentativeElectionAlgorithm { - public WeaklyConnectedComponentAlgorithm(Graph graph) { - super(graph); - } - - @Override - protected void initializeComponents() { - for (var node : graph.getAllNodes()) { - if (representatives.containsKey(node)) { - continue; - } - var reachable = getReachableNodes(node); - initializeSet(reachable); - } - } - - @Override - public void edgeInserted(Object source, Object target) { - var sourceRoot = getRepresentative(source); - var targetRoot = getRepresentative(target); - merge(sourceRoot, targetRoot); - } - - @Override - public void edgeDeleted(Object source, Object target) { - var sourceRoot = getRepresentative(source); - var targetRoot = getRepresentative(target); - if (!sourceRoot.equals(targetRoot)) { - throw new IllegalArgumentException("Trying to remove edge not in graph"); - } - var targetReachable = getReachableNodes(target); - if (!targetReachable.contains(source)) { - split(sourceRoot, targetReachable); - } - } - - private void split(Object sourceRepresentative, Set targetReachable) { - var sourceComponent = getComponent(sourceRepresentative); - sourceComponent.removeAll(targetReachable); - if (targetReachable.contains(sourceRepresentative)) { - components.put(sourceRepresentative, targetReachable); - assignNewRepresentative(sourceRepresentative, sourceComponent); - } else { - assignNewRepresentative(sourceRepresentative, targetReachable); - } - } - - private Set getReachableNodes(Object source) { - var retSet = new HashSet<>(); - retSet.add(source); - var nodeQueue = new ArrayDeque<>(); - nodeQueue.addLast(source); - - while (!nodeQueue.isEmpty()) { - var node = nodeQueue.removeFirst(); - for (var neighbor : graph.getTargetNodes(node).distinctValues()) { - if (!retSet.contains(neighbor)) { - retSet.add(neighbor); - nodeQueue.addLast(neighbor); - } - } - for (var neighbor : graph.getSourceNodes(node).distinctValues()) { - if (!retSet.contains(neighbor)) { - retSet.add(neighbor); - nodeQueue.addLast(neighbor); - } - } - } - - return retSet; - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactory.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactory.java deleted file mode 100644 index 1f8b3034..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.recipe; - -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EFactory; -import tools.refinery.store.query.literal.Connectivity; - -// Naming and index computation follows EMF conventions. -@SuppressWarnings("squid:S115") -public interface RefineryRecipesFactory extends EFactory { - RefineryRecipesFactory eINSTANCE = RefineryRecipesFactoryImpl.init(); - - RepresentativeElectionRecipe createRepresentativeElectionRecipe(); - - Connectivity createConnectivityFromString(EDataType eDataType, String initialValue); - - String convertConnectivityToString(EDataType eDataType, Object instanceValue); -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactoryImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactoryImpl.java deleted file mode 100644 index 4e2a695c..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesFactoryImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.recipe; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EFactoryImpl; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import tools.refinery.store.query.literal.Connectivity; - -public class RefineryRecipesFactoryImpl extends EFactoryImpl implements RefineryRecipesFactory { - public static RefineryRecipesFactory init() { - try { - var factory = (RefineryRecipesFactory) EPackage.Registry.INSTANCE.getEFactory( - RefineryRecipesPackage.eNS_URI); - if (factory != null) { - return factory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new RefineryRecipesFactoryImpl(); - } - - @Override - public EObject create(EClass eClass) { - if (eClass.getClassifierID() == RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE) { - return createRepresentativeElectionRecipe(); - } else { - throw new IllegalArgumentException("The class '%s' is not a valid classifier".formatted(eClass.getName())); - } - } - - @Override - public Object createFromString(EDataType eDataType, String stringValue) { - if (eDataType.getClassifierID() == RefineryRecipesPackage.CONNECTIVITY) { - return createConnectivityFromString(eDataType, stringValue); - } else { - throw new IllegalArgumentException("The datatype '%s' is not a valid classifier" - .formatted(eDataType.getName())); - } - } - - @Override - public String convertToString(EDataType eDataType, Object objectValue) { - if (eDataType.getClassifierID() == RefineryRecipesPackage.CONNECTIVITY) { - return convertConnectivityToString(eDataType, objectValue); - } else { - throw new IllegalArgumentException("The datatype '%s' is not a valid classifier" - .formatted(eDataType.getName())); - } - } - - @Override - public RepresentativeElectionRecipe createRepresentativeElectionRecipe() { - return new RepresentativeElectionRecipeImpl(); - } - - @Override - public Connectivity createConnectivityFromString(EDataType eDataType, String initialValue) { - return (Connectivity) super.createFromString(eDataType, initialValue); - } - - @Override - public String convertConnectivityToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackage.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackage.java deleted file mode 100644 index 6c933c45..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackage.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.recipe; - -import org.eclipse.emf.ecore.*; -import org.eclipse.viatra.query.runtime.rete.recipes.RecipesPackage; - -// Naming and index computation follows EMF conventions. -@SuppressWarnings({"squid:S100", "squid:S115", "PointlessArithmeticExpression"}) -public interface RefineryRecipesPackage extends EPackage { - String eNAME = "refineryReteRecipes"; - - String eNS_URI = "https://refinery.tools/emf/2021/RefineryReteRecipes"; - - String eNS_PREFIX = "refineryReteRecipes"; - - RefineryRecipesPackage eINSTANCE = RefineryRecipesPackageImpl.init(); - - int REPRESENTATIVE_ELECTION_RECIPE = 0; - - int REPRESENTATIVE_ELECTION_RECIPE__CONNECTIVITY = RecipesPackage.ALPHA_RECIPE_FEATURE_COUNT + 0; - - int REPRESENTATIVE_ELECTION_RECIPE_FEATURE_COUNT = RecipesPackage.ALPHA_RECIPE_FEATURE_COUNT + 1; - - int REPRESENTATIVE_ELECTION_RECIPE__GET_ARITY = RecipesPackage.ALPHA_RECIPE_OPERATION_COUNT + 0; - - int REPRESENTATIVE_ELECTION_RECIPE_OPERATION_COUNT = RecipesPackage.ALPHA_RECIPE_OPERATION_COUNT + 1; - - int CONNECTIVITY = 1; - - EClass getRepresentativeElectionRecipe(); - - EAttribute getRepresentativeElectionRecipe_Connectivity(); - - EOperation getRepresentativeElectionRecipe_GetArity(); - - EDataType getConnectivity(); -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackageImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackageImpl.java deleted file mode 100644 index d5073402..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RefineryRecipesPackageImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.recipe; - -import org.eclipse.emf.ecore.*; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.viatra.query.runtime.rete.recipes.RecipesPackage; -import tools.refinery.store.query.literal.Connectivity; - -public class RefineryRecipesPackageImpl extends EPackageImpl implements RefineryRecipesPackage { - private static boolean isInstanceInitialized; - private boolean isCreated; - private boolean isInitialized; - private EClass representativeElectionRecipe; - private EDataType connectivity; - - public static RefineryRecipesPackage init() { - if (isInstanceInitialized) { - return (RefineryRecipesPackage) Registry.INSTANCE.getEPackage(eNS_URI); - } - var thePackage = Registry.INSTANCE.get(eNS_URI) instanceof RefineryRecipesPackageImpl impl ? impl : - new RefineryRecipesPackageImpl(); - isInstanceInitialized = true; - thePackage.createPackageContents(); - thePackage.initializePackageContents(); - thePackage.freeze(); - Registry.INSTANCE.put(eNS_URI, thePackage); - return thePackage; - } - - private RefineryRecipesPackageImpl() { - super(eNS_URI, RefineryRecipesFactory.eINSTANCE); - } - - @Override - public EClass getRepresentativeElectionRecipe() { - return representativeElectionRecipe; - } - - @Override - public EAttribute getRepresentativeElectionRecipe_Connectivity() { - return (EAttribute) representativeElectionRecipe.getEStructuralFeatures().get(0); - } - - @Override - public EOperation getRepresentativeElectionRecipe_GetArity() { - return representativeElectionRecipe.getEOperations().get(0); - } - - @Override - public EDataType getConnectivity() { - return connectivity; - } - - public void createPackageContents() { - if (isCreated) { - return; - } - isCreated = true; - - representativeElectionRecipe = createEClass(REPRESENTATIVE_ELECTION_RECIPE); - createEAttribute(representativeElectionRecipe, REPRESENTATIVE_ELECTION_RECIPE__CONNECTIVITY); - createEOperation(representativeElectionRecipe, REPRESENTATIVE_ELECTION_RECIPE__GET_ARITY); - - connectivity = createEDataType(CONNECTIVITY); - } - - public void initializePackageContents() { - if (isInitialized) { - return; - } - isInitialized = true; - - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - representativeElectionRecipe.getESuperTypes().add(RecipesPackage.Literals.ALPHA_RECIPE); - - initEClass(representativeElectionRecipe, RepresentativeElectionRecipe.class, - "RepresentativeElectionRecipe", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getRepresentativeElectionRecipe_Connectivity(), getConnectivity(), "connectivity", null, 0, 1, - RepresentativeElectionRecipe.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, - IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEOperation(getRepresentativeElectionRecipe_GetArity(), EcorePackage.Literals.EINT, "getArity", 0, 1, - !IS_UNIQUE, IS_ORDERED); - - initEDataType(connectivity, Connectivity.class, "Connectivity", IS_SERIALIZABLE, - !IS_GENERATED_INSTANCE_CLASS); - - createResource(eNS_URI); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipe.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipe.java deleted file mode 100644 index def825c2..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipe.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.recipe; - -import org.eclipse.viatra.query.runtime.rete.recipes.AlphaRecipe; -import tools.refinery.store.query.literal.Connectivity; - -public interface RepresentativeElectionRecipe extends AlphaRecipe { - Connectivity getConnectivity(); - - void setConnectivity(Connectivity connectivity); - - int getArity(); -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipeImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipeImpl.java deleted file mode 100644 index 959836d2..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/rete/recipe/RepresentativeElectionRecipeImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The Refinery Authors - * - * SPDX-License-Identifier: EPL-2.0 - */ -package tools.refinery.store.query.viatra.internal.rete.recipe; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.viatra.query.runtime.rete.recipes.RecipesPackage; -import org.eclipse.viatra.query.runtime.rete.recipes.ReteNodeRecipe; -import org.eclipse.viatra.query.runtime.rete.recipes.impl.AlphaRecipeImpl; -import tools.refinery.store.query.literal.Connectivity; - -import java.lang.reflect.InvocationTargetException; - -public class RepresentativeElectionRecipeImpl extends AlphaRecipeImpl implements RepresentativeElectionRecipe { - private Connectivity connectivity; - - @Override - protected EClass eStaticClass() { - return RefineryRecipesPackage.eINSTANCE.getRepresentativeElectionRecipe(); - } - - @Override - public Connectivity getConnectivity() { - return connectivity; - } - - @Override - public void setConnectivity(Connectivity newStrong) { - var oldConnectivity = connectivity; - connectivity = newStrong; - if (eNotificationRequired()) { - eNotify(new ENotificationImpl(this, Notification.SET, - RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE__CONNECTIVITY, oldConnectivity, - connectivity)); - } - } - - @Override - public int getArity() { - return 2; - } - - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - if (featureID == RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE__CONNECTIVITY) { - return getConnectivity(); - } - return super.eGet(featureID, resolve, coreType); - } - - @Override - public void eSet(int featureID, Object newValue) { - if (featureID == RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE__CONNECTIVITY) { - setConnectivity((Connectivity) newValue); - } else { - super.eSet(featureID, newValue); - } - } - - @Override - public void eUnset(int featureID) { - if (featureID == RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE__CONNECTIVITY) { - setConnectivity(null); - } else { - super.eUnset(featureID); - } - } - - @Override - public boolean eIsSet(int featureID) { - if (featureID == RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE__CONNECTIVITY) { - return connectivity != null; - } - return super.eIsSet(featureID); - } - - @Override - public int eDerivedOperationID(int baseOperationID, Class baseClass) { - if (baseClass == ReteNodeRecipe.class && baseOperationID == RecipesPackage.RETE_NODE_RECIPE___GET_ARITY) { - return RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE__GET_ARITY; - } - return super.eDerivedOperationID(baseOperationID, baseClass); - } - - @Override - public Object eInvoke(int operationID, EList arguments) throws InvocationTargetException { - if (operationID == RefineryRecipesPackage.REPRESENTATIVE_ELECTION_RECIPE__GET_ARITY) { - return getArity(); - } - return super.eInvoke(operationID, arguments); - } - - @Override - public String toString() { - if (eIsProxy()) { - return super.toString(); - } - return "%s (connectivity: %s)".formatted(super.toString(), connectivity); - } -} diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java index 986bb0b1..e1bc9efc 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java @@ -5,9 +5,9 @@ */ package tools.refinery.store.query.viatra.internal.update; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener; -import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContextListener; +import tools.refinery.viatra.runtime.matchers.tuple.ITuple; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; import tools.refinery.store.query.view.AnySymbolView; import tools.refinery.store.query.view.SymbolView; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/RelationViewFilter.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/RelationViewFilter.java index efdbfcbe..73c4a3f9 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/RelationViewFilter.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/RelationViewFilter.java @@ -5,10 +5,10 @@ */ package tools.refinery.store.query.viatra.internal.update; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener; -import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContextListener; +import tools.refinery.viatra.runtime.matchers.tuple.ITuple; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; import java.util.Arrays; import java.util.Objects; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/SymbolViewUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/SymbolViewUpdateListener.java index f1a2ac7c..d0cdda72 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/SymbolViewUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/SymbolViewUpdateListener.java @@ -5,10 +5,10 @@ */ package tools.refinery.store.query.viatra.internal.update; -import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; -import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener; -import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.context.IInputKey; +import tools.refinery.viatra.runtime.matchers.context.IQueryRuntimeContextListener; +import tools.refinery.viatra.runtime.matchers.tuple.ITuple; +import tools.refinery.viatra.runtime.matchers.tuple.Tuple; import tools.refinery.store.model.Interpretation; import tools.refinery.store.model.InterpretationListener; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java index 45d35571..9dc739f1 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.update; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; import tools.refinery.store.model.Interpretation; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; import tools.refinery.store.query.view.SymbolView; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingViewUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingViewUpdateListener.java index c18dbafb..7dbd50b3 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingViewUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingViewUpdateListener.java @@ -5,7 +5,7 @@ */ package tools.refinery.store.query.viatra.internal.update; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; import tools.refinery.store.model.Interpretation; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; import tools.refinery.store.query.view.TuplePreservingView; -- cgit v1.2.3-54-g00ecf