- }
-
- @Override
- public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
-
- long s = System.nanoTime();
-
- StructuralResource2.getInstance(graph);
- if(variable == null)
- return Collections.emptySet();
-
- Set<Variable> nodes = new THashSet<Variable>();
- Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
- for(Variable child : children) {
- Set<Variable> childNodes = graph.syncRequest(new NodesRequest2(child));
- nodes.addAll(childNodes);
- }
-
+ }
+
+ static class CollectNodesRequest2 extends UnaryRead<Collection<Variable>, Set<Variable>> {
+
+ public CollectNodesRequest2(Collection<Variable> nodes) {
+ super(nodes);
+ }
+
+ @Override
+ public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
+ HashSet<Variable> rs = new HashSet<>(); // result
+ for(Variable child : parameter) {
+ Set<Variable> childNodes = graph.syncRequest(new NodesRequest2(child));
+ rs.addAll(childNodes);
+ }
+ return rs;
+ }
+
+ }
+
+ @Override
+ public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
+
+ long s = System.nanoTime();
+
+ StructuralResource2.getInstance(graph);
+ if(variable == null)
+ return Collections.emptySet();
+
+ Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
+
+ Set<Variable> nodes = graph.syncRequest(new CollectNodesRequest2(children));
+