@Override
    protected Long map(final Traverser.Admin<S> traverser) {
        final S item = traverser.get();
        return (item instanceof Collection) ? ((Collection) item).size()
                : (item instanceof Map) ? ((Map) item).size()
                : (item instanceof Path) ? ((Path) item).size()
                : IteratorUtils.count(IteratorUtils.asIterator(item));
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
@author Daniel Kuppitz (http://gremlin.guru)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountLocalStep.java