Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing dynamic value inside sample method in gremlin is not working

I am a newbie to the gremlin. I am trying to get some random vertices based on some condition. But if I am using sample method with some mathematical computation it is not working. But if I give integer values it is working fine.

The following query is working fine:

g.V().hasLabel('Person').sample(1)

The following query is not working:

g.V().hasLabel('Person').sample(math('4/2'))

Actually, based on the number of persons I should perform some mathematical computations inside sample method. Thanks in advance

like image 785
rajashekar Avatar asked Sep 03 '20 07:09

rajashekar


1 Answers

That's an interesting bit of Gremlin you are trying to run. I've not seen anyone try that before. Sadly, it won't work because sample() does not take a Traversal as an argument. It only takes a number. There is no workaround for this issue aside from doing the computation outside of Gremlin which isn't helpful if you need to choose your sample size based on data in your query. sample() isn't the only step that behaves this way. I've created TINKERPOP-2414 to track this issue.

like image 175
stephen mallette Avatar answered Oct 21 '22 22:10

stephen mallette