X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fprocedures%2FCreateInverseRelations.java;fp=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fprocedures%2FCreateInverseRelations.java;h=42ab8fde24f8f3cafb5f5a4a2c5d528f69befa95;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/CreateInverseRelations.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/CreateInverseRelations.java new file mode 100644 index 000000000..42ab8fde2 --- /dev/null +++ b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/CreateInverseRelations.java @@ -0,0 +1,88 @@ +package org.simantics.graph.compiler.internal.procedures; + +import gnu.trove.list.array.TIntArrayList; +import gnu.trove.map.hash.TIntIntHashMap; + +import org.simantics.graph.query.IGraph; +import org.simantics.graph.query.Paths; +import org.simantics.graph.query.Res; +import org.simantics.graph.store.GraphStore; +import org.simantics.graph.store.StatementStore; + +public class CreateInverseRelations implements Runnable { + IGraph graph; + GraphStore store; + + public CreateInverseRelations(IGraph graph, GraphStore store) { + this.graph = graph; + this.store = store; + } + + @Override + public void run() { + Paths paths = graph.getPaths(); + int subrelationOf = store.identities.pathToId(paths.SubrelationOf); + if(subrelationOf < 0) + return; + + int inverseOf = store.identities.createPathToId(paths.InverseOf); + + int resourceCount = store.identities.getResourceCount(); + TIntIntHashMap inverseMap = new TIntIntHashMap(); + StatementStore statements = store.statements; + for(int id = 0;id= 0) { + invSuperrelations.set(i, + invSuperrelations.get(invSuperrelations.size()-1)); + invSuperrelations.removeAt(invSuperrelations.size()-1); + } + } + } + + for(int invSuperrelation : invSuperrelations.toArray()) + store.statements.add(inverse, subrelationOf, invSuperrelation); + } + } + } + } +}