- }
-
- @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);
- }
-
- 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;
-
- }
+ }
+
+ @Override
+ public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
+
+ ITask task = DocumentRequest.PROFILE ? ThreadLogger.task(this) : null;
+
+ StructuralResource2.getInstance(graph);
+ if(variable == null)
+ return Collections.emptySet();
+
+ Set<Variable> nodes = new THashSet<Variable>();
+
+ Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
+
+ graph.syncRequest(new AsyncReadRequest() {
+
+ @Override
+ public void run(AsyncReadGraph graph) throws DatabaseException {
+
+ for(Variable child : children) {
+ graph.asyncRequest(new NodesRequest2(child), new AsyncProcedure<Set<Variable>>() {
+
+ @Override
+ public void execute(AsyncReadGraph graph, Set<Variable> result) {
+ synchronized(nodes) {
+ nodes.addAll(result);
+ }
+ }
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ }
+
+ });
+ }
+
+ }
+
+ });
+
+ if(DocumentRequest.PROFILE) task.finish();
+
+ return nodes;
+
+ }