public Subgraph at( Location location ) { return new SubgraphResults(requests.readBranch(location, getCurrentWorkspaceName(), depth)); }
@Override public void run( FunctionContext context ) { // Read the input parameter(s) ... int maxDepth = context.input("maxDepth", PropertyType.LONG, new Long(Integer.MAX_VALUE)).intValue(); // Read the subgraph under the location ... ReadBranchRequest readSubgraph = context.builder().readBranch(context.appliedAt(), context.workspace(), maxDepth); // Process that request ... if (readSubgraph.hasError()) { readSubgraph.getError().printStackTrace(); context.setError(readSubgraph.getError()); } else { // And count the number of nodes within the subgraph ... int counter = 0; for (Location location : readSubgraph) { if (location != null) ++counter; } // And write the count as an output parameter ... context.setOutput("nodeCount", counter); } } }