@Override
    public Iterator<Edge> edges(final Object... edgeIds) {
        try {
            if (0 == edgeIds.length) {
                return new HadoopEdgeIterator(this);
            } else {
                final Stream<Edge> idsThatWereEdges = Stream.of(edgeIds).
                        filter(id -> id instanceof Edge).map(id -> (Edge) id);
                final Stream<Edge> edgesFromHadoopGraph = StreamSupport.stream(Spliterators.spliteratorUnknownSize(
                        IteratorUtils.filter(new HadoopEdgeIterator(this),
                                edge -> ElementHelper.idExists(edge.id(), edgeIds)), Spliterator.ORDERED), false);

                // if the edgeIds are all Edge 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<Edge> iterator = new AbortiveMultiIterator<>();
                iterator.addIterator(idsThatWereEdges.iterator());
                iterator.addIterator(edgesFromHadoopGraph.iterator(), c -> c != edgeIds.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