I have a piece of code where i evaluate to drop vertices but only if a pre-fetch of
g.V().<filters>.hasNext()
returns true.
Problem is on my subsequent call to fetch the nodes themselves it is getting stuck for some reason.
hasNext, err := g.V().<filter>.hasNext()
if err != nil {
return err
}
if hasNext {
// Program is stuck here
ids, err := g.V().<filter>.Id().ToList()
....
}
I found out what was causing this to be stuck indefinitely.
It looks like the go version of gremlingo has a weird implementation of HasNext()
. Instead of adding it as a strategy
it fetches the complete results, and then returns if the results are non-empty, which in my opinion is not helpful at all when checking for any results.
Error: https://github.com/apache/tinkerpop/blob/master/gremlin-go/driver/traversal.go#L99
This seems to wait until receiving a signal on the waitChannel
externally.
https://github.com/apache/tinkerpop/blob/master/gremlin-go/driver/resultSet.go#L107
There doesnt seem to be a way to signal this to stop.
Python:
The python version of the gremlin library and im sure other versions as well, use this function as a strategy.
I needed a lightweight query to tell me if there are more results in my query criteria and i used this instead of the HasNext()
res, err := g.V().<filters>.Limit(1).ToList()
if len(res) == 0 {
// no more results
} else {
// results available
}