X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FNodesRequest.java;h=f3f1177fc4d1f613950bc7b4f7d56e2ec010105f;hb=6ff5e65793559d92443fcd1eb7e8d12a3bed9e9e;hp=11bf514c3440793b620ec0022c3c6201f4ff01ec;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodesRequest.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodesRequest.java index 11bf514c3..f3f1177fc 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodesRequest.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodesRequest.java @@ -1,47 +1,47 @@ -package org.simantics.document.server.request; - -import gnu.trove.set.hash.THashSet; - -import java.util.Collection; -import java.util.Collections; -import java.util.Set; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.VariableChildren; -import org.simantics.db.layer0.request.VariableRead; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.structural.stubs.StructuralResource2; - -public class NodesRequest extends VariableRead> { - - public NodesRequest(Variable var) { - super(var); - } - - @Override - public Set perform(ReadGraph graph) throws DatabaseException { - - long s = System.nanoTime(); - - StructuralResource2.getInstance(graph); - if(variable == null) - return Collections.emptySet(); - - Set nodes = new THashSet(); - Collection children = graph.syncRequest(new VariableChildren(variable)); - for(Variable child : children) { - Set childNodes = graph.syncRequest(new NodesRequest2(child)); - nodes.addAll(childNodes); - } - - if(DocumentRequest.PROFILE) { - long dura = System.nanoTime()-s; - System.err.println("NodesRequest " + System.identityHashCode(this) + " " + variable.getURI(graph) + " in " + 1e-6*dura + "ms."); - } - - return nodes; - - } - +package org.simantics.document.server.request; + +import gnu.trove.set.hash.THashSet; + +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.VariableChildren; +import org.simantics.db.layer0.request.VariableRead; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.structural.stubs.StructuralResource2; + +public class NodesRequest extends VariableRead> { + + public NodesRequest(Variable var) { + super(var); + } + + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + + long s = System.nanoTime(); + + StructuralResource2.getInstance(graph); + if(variable == null) + return Collections.emptySet(); + + Set nodes = new THashSet(); + Collection children = graph.syncRequest(new VariableChildren(variable)); + for(Variable child : children) { + Set childNodes = graph.syncRequest(new NodesRequest2(child)); + nodes.addAll(childNodes); + } + + if(DocumentRequest.PROFILE) { + long dura = System.nanoTime()-s; + System.err.println("NodesRequest " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph)); + } + + return nodes; + + } + } \ No newline at end of file