Github user dalaro commented on the issue:
https://github.com/apache/tinkerpop/pull/372
I pulled master (@ fc79de813c788ee141175bbf1ea6d0cdefa94a0f) and confirmed
that the bug still existed. I didn't apply your proposed change right away.
Here a `gremlin.sh` session that shows the buggy behavior. I'm also pushing a
unit test that I developed first, but it's easier to see what's going wrong in
this `gremlin.sh` session than in the source code for a unit test.
```
$ `find gremlin-console/target -name gremlin.sh`
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> sg =
org.apache.tinkerpop.gremlin.structure.util.star.StarGraph.open()
==>stargraph[starOf:null]
gremlin> v = sg.addVertex('name', 'foo')
==>v[0]
gremlin> v.addEdge('self', v)
==>e[2][0-self->0]
gremlin> sg.traversal().V().inE('self')
==>e[2][0-self->0]
gremlin> sg.traversal().V().outE('self')
==>e[2][0-self->0]
gremlin> sg.traversal().V().bothE('self')
==>e[2][0-self->0]
==>e[2][0-self->0]
// NOTE: StarOutEdge in the inEdges datastructure
gremlin> v.inEdges.values().iterator().next().get(0).getClass()
==>class
org.apache.tinkerpop.gremlin.structure.util.star.StarGraph$StarOutEdge
gremlin> filter = new
org.apache.tinkerpop.gremlin.process.computer.GraphFilter()
==>graphfilter[none]
gremlin> filter.setEdgeFilter(__.bothE("self"))
==>null
gremlin> sg.applyGraphFilter(filter)
==>Optional[stargraph[starOf:v[0]]]
// NOTE: no inE results, double outE results after GraphFilter is applied
gremlin> sg.traversal().V().inE('self')
gremlin> sg.traversal().V().outE('self')
==>e[2][0-self->0]
==>e[2][0-self->0]
gremlin> sg.traversal().V().bothE('self')
==>e[2][0-self->0]
==>e[2][0-self->0]
gremlin>
```
There are a couple of things worth noting above:
* the `inEdges` datastructure contains a `StarOutEdge` when we construct
the graph this way
* the final post-filtering `inE` and `outE` are incorrect (an indirect
consequence of the first point)
These steps produce different behavior depending on whether I invoke
`StarGraph.open()` or call `StarGraph.of(<some self-looped tinkervertex>)`. If
I do the latter, I get a `StarInEdge` in the `inEdges` map and a `StarOutEdge`
in the `outEdges` map, and in turn avoid this particular filtering bug.
**Good news**: your change makes sense and fixes the bug I initially
reported (both-filtering).
**Bad news**: I think there are more graph filtering bugs on StarGraph that
can create half-edges
When I filter a self-loop star graph for either in or out, I get stuff like
this (symmetrical for `.inE`):
```
gremlin> filter = new
org.apache.tinkerpop.gremlin.process.computer.GraphFilter()
==>graphfilter[none]
gremlin> filter.setEdgeFilter(__.outE("self"))
==>null
gremlin> sg.applyGraphFilter(filter)
==>Optional[stargraph[starOf:v[0]]]
gremlin> sg.traversal().V()
==>v[0]
gremlin> sg.traversal().V().inE('self')
gremlin> sg.traversal().V().outE('self')
==>e[2][0-self->0]
gremlin> sg.traversal().V().bothE('self')
==>e[2][0-self->0]
gremlin>
```
@okram: This doesn't look correct, but then again, I don't really know what
it should do. Should it completely destroy the self-loop, so that
inE/bothE/outE all fail to emit anything associated with the self-loop? Should
it transform the self-loop into a single-directional edge (which seems like one
interpretation for what it does now, in which case it might be correct)?
I noticed that the name of my original branch is nonsense ("DSP-1397"). I
don't think that can be changed after a PR is created. So, I'm opening a pair
of new PRs: one for tp31 and one for master.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---