use of com.baidu.hugegraph.traversal.algorithm.CountTraverser in project incubator-hugegraph by apache.
the class CountAPI method post.
@POST
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String post(@Context GraphManager manager, @PathParam("graph") String graph, CountRequest request) {
LOG.debug("Graph [{}] get count from '{}' with request {}", graph, request);
E.checkArgumentNotNull(request.source, "The source of request can't be null");
Id sourceId = HugeVertex.getIdValue(request.source);
E.checkArgumentNotNull(request.steps != null && !request.steps.isEmpty(), "The steps of request can't be null or empty");
E.checkArgumentNotNull(request.dedupSize == NO_LIMIT || request.dedupSize >= 0L, "The dedup size of request " + "must >= 0 or == -1, but got: '%s'", request.dedupSize);
HugeGraph g = graph(manager, graph);
List<EdgeStep> steps = steps(g, request);
CountTraverser traverser = new CountTraverser(g);
long count = traverser.count(sourceId, steps, request.containsTraversed, request.dedupSize);
return manager.serializer(g).writeMap(ImmutableMap.of("count", count));
}
Aggregations