@Override
    public Iterator<Vertex> vertices(final Object... vertexIds) {
        try {
            if (0 == vertexIds.length) {
                return new HadoopVertexIterator(this);
            } else {
                // attach vertices if detached instances are passed in otherwise they won't be reloaded and will
                // basically be useless without properties
                final Stream<Vertex> idsThatWereAttachedVertices = Stream.of(vertexIds).
                        filter(id -> id instanceof Vertex).map(
                                id -> id instanceof Attachable ? ((Attachable<Vertex>) id).attach(Attachable.Method.get(this)) : (Vertex) id);

                final Stream<Vertex> verticesFromHadoopGraph = StreamSupport.stream(Spliterators.spliteratorUnknownSize(
                        IteratorUtils.filter(new HadoopVertexIterator(this),
                                vertex -> ElementHelper.idExists(vertex.id(), vertexIds)), Spliterator.ORDERED), false);

                // if the vertexIds are all Vertex objects then abort the iteration of the full HadoopGraph as there
                // is no need to refresh the data in this use case as other graphs might
                final AbortiveMultiIterator<Vertex> iterator = new AbortiveMultiIterator<>();
                iterator.addIterator(idsThatWereAttachedVertices.iterator());
                iterator.addIterator(verticesFromHadoopGraph.iterator(), c -> c != vertexIds.length);
                return iterator;
            }
        } catch (final IOException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java