@Override
    public CloseableIterator<Long> execute(final ServiceCallContext ctx, final Traverser.Admin<Vertex> in, final Map params) {
        final Direction direction = (Direction) params.getOrDefault(Params.DIRECTION, Direction.IN);

        final Vertex v = in.get();
        final long count;
        try (CloseableIterator<Edge> it = CloseableIterator.of(v.edges(direction))) {
            count = IteratorUtils.count(it);
        };

        return CloseableIterator.of(LongStream.range(0, in.bulk()).map(i -> count).iterator());
    }
Count the IN/OUT/BOTH edges for a set of vertices. Demonstrates a {@link Service.Type#Streaming} service.
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/services/TinkerDegreeCentralityFactory.java