Skip to content

Speed up Graph#getEdgeIteratorState #1847

Open

Description

@easbar

Obtaining an EdgeIteratorState given an integer edge id is unnecessarily expensive, because Graph#getEdgeIteratorState creates an object instead of simply updating the edge id being in use as we do with the other EdgeExplorers. We need something like RandomAccessEdgeExplorer.setEdge(edgeId) in analogy to EdgeExplorer.setBaseNode(node).

For example this method is a bottleneck in Path#forEveryEdge like in Path#calcPoints.

Probably we should do this after #1780.

Activity

  1. michaz commented on Jan 8, 2020

    @michaz
    Member

    Can I ask something outrageous? Do you thing we could -- in the long run -- a) rename these things to *Cursor, and b) refactor them so that we can make them Iterable, like in the primitive-collections library we are using?

  2. easbar commented on Jan 8, 2020

    @easbar
    MemberAuthor

    Doesn't sound so outrageous :) I don't really care about Iterator vs. Cursor what do you think makes the difference ? What do you mean making them iterable ? You mean having something like prev() in addition to next() ? Ah you mean java.lang.Iterable ?

  3. michaz commented on Jan 8, 2020

    @michaz
    Member

    Yes. java.lang.iterable. The things in carrotsearch-collections, for example: You can for-each them, even though they iterate with a cursor rather than with value objects. That‘s kind of cool, I was thinking, maybe we could emulate that.

    But I‘m not pushing here. Maybe just for new stuff, or experiment with a wrapper which provides that kind of interface.. don‘t know.

  4. michaz commented on Jan 8, 2020

    @michaz
    Member

    I can‘t imagine how it could be slower than manually writing a hasNext()-next()-loop. In fact I think it‘s literally compiled to that.

    I think when people say for-each is slower, they usually mean that it is slower than using a for loop with an array index (not an iterator at all). Which makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions