You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Stephen Mallette (Jira)" <ji...@apache.org> on 2019/10/01 16:40:00 UTC

[jira] [Commented] (TINKERPOP-2014) Allow an ability to specify seeding for random methods such as coin, sample and Order.shuffle

    [ https://issues.apache.org/jira/browse/TINKERPOP-2014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16942130#comment-16942130 ] 

Stephen Mallette commented on TINKERPOP-2014:
---------------------------------------------

Pulled a use case from my notes about my previous comment - here's a use case outside of testing that [~dkuppitz] presented a while back:

{code}
gremlin> g.V(4).both().sample(1).out('created').aggregate('x').by('name').cap('x').
......1>   V(4).both().sample(1).both('knows').hasId(neq(4)).values('name').fold().
......2>   project('friends of josh created','friends of josh\'s friends').
......3>     by(select('x').unfold().fold()).
......4>     by().
......5>   unfold()
==>friends of josh created=[]
==>friends of josh's friends=[]
gremlin> g.V(4).both().sample(1).out('created').aggregate('x').by('name').cap('x').
......1>   V(4).both().sample(1).both('knows').hasId(neq(4)).values('name').fold().
......2>   project('friends of josh created','friends of josh\'s friends').
......3>     by(select('x').unfold().fold()).
......4>     by().
......5>   unfold()
==>friends of josh created=[]
==>friends of josh's friends=[vadas]
gremlin> g.V(4).both().sample(1).out('created').aggregate('x').by('name').cap('x').
......1>   V(4).both().sample(1).both('knows').hasId(neq(4)).values('name').fold().
......2>   project('friends of josh created','friends of josh\'s friends').
......3>     by(select('x').unfold().fold()).
......4>     by().
......5>   unfold()
==>friends of josh created=[lop]
==>friends of josh's friends=[]
gremlin> g.V(4).both().sample(1).out('created').aggregate('x').by('name').cap('x').
......1>   V(4).both().sample(1).both('knows').hasId(neq(4)).values('name').fold().
......2>   project('friends of josh created','friends of josh\'s friends').
......3>     by(select('x').unfold().fold()).
......4>     by().
......5>   unfold()
==>friends of josh created=[lop]
==>friends of josh's friends=[vadas]
{code} 

{quote}If I'm not able to specify a seed for the sample step, I can't ensure that the software listed in the result was created by the same friends of josh, that are also friends of the people listed in the result. (edited) 
I could by aggregating those friends in another collection, emitting in cap and do some matching in the second query. But that would complicate things.{quote}

> Allow an ability to specify seeding for random methods such as coin, sample and Order.shuffle
> ---------------------------------------------------------------------------------------------
>
>                 Key: TINKERPOP-2014
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2014
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.3.3
>            Reporter: Sam Rosen
>            Priority: Minor
>
> Currently, all the methods that have non-deterministic behavior such as coin and sample have no ability to set a seed. The ability to set a seed will allow for reproducible and testable behavior as well as more control flow for random processes. If a certain backend does not support seeding, they could simply ignore it. Some possible API changes:
> graph.traversal.V().withSeed(2L).coin(.5)
> graph.traversal.V().sample(3, 0L)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)