Gremlin (with Python + Neptune) Out of Memory Error with .toList()[0], .next() Fixes It. But Why?

This is not really a question, but more of a discussions on how internally this would cause an out of memory error. I have the following construct and last night, it resulted in out of memory error. * path_v is a single well defined V. I am expecting it is returning a single V. * All values in valueMap() I wanted were single cardinality string values. * I know that it is obvious that toList() will not be efficient if I am only interested in one value, however, this only should return a single record set, so even though it isn't efficient, it should not blow up the memory.
vm = g.V(path_v).valueMap("kind", "tag", "uuid").toList()[0]
vm = g.V(path_v).valueMap("kind", "tag", "uuid").toList()[0]
The change to the following seems to fix this. Obviously this will be asking for a single value from a cursor type interaction
vm = g.V(path_v).valueMap("kind", "tag", "uuid").next()
vm = g.V(path_v).valueMap("kind", "tag", "uuid").next()
Very intriguing...
1 Reply
spmallette
spmallette13mo ago
hmm, that's strange. you stated it pretty plainly but I feel like I have to ask: are you completely certain that "path_v" is returning one vertex? what happens if you do:
g.V(path_v).limit(10).count()
g.V(path_v).limit(10).count()
does that return 1?
Want results from more Discord servers?
Add your server