[jira] [Commented] (TINKERPOP-1849) Provide a way to fold() with an index

2018-12-17 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on TINKERPOP-1849:
---

asfgit closed pull request #1011: TINKERPOP-1849 Provide a way to fold() with 
an index
URL: https://github.com/apache/tinkerpop/pull/1011
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Provide a way to fold() with an index
> -
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: stephen mallette
>Assignee: Daniel Kuppitz
>Priority: Major
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin> 
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
>  select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we 
> can add an option to {{fold()}} that would take an enum of "fold operators".



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (TINKERPOP-1849) Provide a way to fold() with an index

2018-12-05 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on TINKERPOP-1849:
---

dkuppitz opened a new pull request #1011: TINKERPOP-1849 Provide a way to 
fold() with an index
URL: https://github.com/apache/tinkerpop/pull/1011
 
 
   https://issues.apache.org/jira/projects/TINKERPOP/issues/TINKERPOP-1849
   
   `docker/build.sh -t -i -n` passed and the docs built with `docker/build.sh 
-d` look good.
   
   VOTE +1


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Provide a way to fold() with an index
> -
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: stephen mallette
>Assignee: Daniel Kuppitz
>Priority: Major
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin> 
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
>  select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we 
> can add an option to {{fold()}} that would take an enum of "fold operators".



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (TINKERPOP-1849) Provide a way to fold() with an index

2018-11-08 Thread Daniel Kuppitz (JIRA)


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

Daniel Kuppitz commented on TINKERPOP-1849:
---

I don't know when I will start to work on this, so - as a reminder - here are 
just the thoughts from our latest discussion:

We should only implement a local version of this step, because

# it's not too much to ask a user to do the {{fold()}}
# by explicitly using {{fold()}} the user is made aware of the memory 
consumption
# it will just work in OLTP and OLAP

This is how could look like:

{noformat}
gremlin> g.V().index()
==>[v[1], 0]
==>[v[2], 0]
==>[v[3], 0]
==>[v[4], 0]
==>[v[5], 0]
==>[v[6], 0]
gremlin> g.V().fold().index()
==>[[v[1],0],[v[2],1],[v[3],2],[v[4],3],[v[5],4],[v[6],5]]
gremlin> g.V().fold().index().by('e').by('i')
==>[[e:v[1],i:0],[e:v[2],i:1],[e:v[3],i:2],[e:v[4],i:3],[e:v[5],i:4],[e:v[6],i:5]]
{noformat}

> Provide a way to fold() with an index
> -
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: stephen mallette
>Assignee: Daniel Kuppitz
>Priority: Major
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin> 
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
>  select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we 
> can add an option to {{fold()}} that would take an enum of "fold operators".



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (TINKERPOP-1849) Provide a way to fold() with an index

2017-12-22 Thread stephen mallette (JIRA)

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

stephen mallette commented on TINKERPOP-1849:
-

I'd let this issue simmer a bit during release of 3.2.7/3.3.1 - I guess the 
flag would be the right approach with "all reduction (happening) on the master 
traversal".  As for the "more general problem", perhaps that is an issue of 
convention and documentation? We have no real way to control that, so all we 
can do is tell users that if they write their own lambda there, then they 
better make sure it fits those properties. Does that make sense?

> Provide a way to fold() with an index
> -
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: stephen mallette
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin> 
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
>  select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we 
> can add an option to {{fold()}} that would take an enum of "fold operators".



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (TINKERPOP-1849) Provide a way to fold() with an index

2017-12-07 Thread Marko A. Rodriguez (JIRA)

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

Marko A. Rodriguez commented on TINKERPOP-1849:
---

After bagging to [~dkuppitz] about my solution, he said: "Does it work on 
GraphComputer?" I immediately thought: "no" and tested it and it doesn't. Why? 
{{FoldStep}} is a {{ReducingBarrierStep}} and thus, can only work with 
associative and commutative operations. {{addWithIndex}} is not. It requires a 
serial ordering during "folding" in order to get an index. Thus, this raises 
two solutions:

Do we provide a "flag" on {{Operators}} to say whether they are associative and 
commutative?
  1. If so, then if it is not, then all reduction must happen on the master 
traversal.
  2. Or, simply through a {{ComputerVerificationException}} is such operators 
are used.

The more general problem would be provided lambdas that are NOT commutative nor 
associative. How is Gremlin to know?

> Provide a way to fold() with an index
> -
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: stephen mallette
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin> 
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
>  select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we 
> can add an option to {{fold()}} that would take an enum of "fold operators".



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (TINKERPOP-1849) Provide a way to fold() with an index

2017-12-06 Thread stephen mallette (JIRA)

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

stephen mallette commented on TINKERPOP-1849:
-

we could deprecate `addAll` on tp32 and go with just `add` which would leave us 
with `addWithIndex` more consistently.

> Provide a way to fold() with an index
> -
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: stephen mallette
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin> 
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
>  select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we 
> can add an option to {{fold()}} that would take an enum of "fold operators".



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (TINKERPOP-1849) Provide a way to fold() with an index

2017-12-06 Thread Marko A. Rodriguez (JIRA)

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

Marko A. Rodriguez commented on TINKERPOP-1849:
---

So {{fold()}} does support a seed and a binary operator. For instance:

{code}
sum() <=> fold(0, a,b -> a + b)
{code}

Thus, true {{fold()}} is

{code}
fold([], a,b -> {a.add(b); a})
{code}

However, the binary operator is not necessary as we have {{Operator.addAll}}. 
Thus, the above is:

{code}
fold([], addAll)
{code}

...such that:

{code}
gremlin> g.V().fold([], addAll)
==>[v[1],v[2],v[3],v[4],v[5],v[6]]
{code}

If you were to generalize that to support indices, you would do something like 
this:

{code}
c = 0
fold([], a,b -> a.add([b,c++]); a) 
{code}

...such that, in Gremlin-Groovy:

{code}
gremlin> c = 0
==>0
gremlin> g.V().fold([], {a,b -> a.add([b,c++]); a})
==>[[v[1],0],[v[2],1],[v[3],2],[v[4],3],[v[5],4],[v[6],5]]
{code}

The problem here is that we have a {{c}} defined outside the closure and thus, 
outside the scope of the traversal. Well, let us rewrite the above with {{c}} 
scoped accordingly. That is, make sure that the binary operator can handle the 
index increment.

{code}
gremlin> g.V().fold([], {a, b ->
..1>   if(a.isEmpty())
..2> a.add([b,0]);
..3>   else
..4> a.add([b,a.get(a.size()-1)[1]+1]);
..5>   a;
..6> })
==>[[v[1],0],[v[2],1],[v[3],2],[v[4],3],[v[5],4],[v[6],5]]
{code}

Tada! Thus, given the already existing {{fold()}} constructs, it is possible to 
simply create a new {{Operator}}. I would call this operator 
{{addAllWithIndex}} and it would be defined as above. In use it would look like 
this:

{code}
g.V().fold([], addAllWithIndex)
{code}

...sorta don't like {{addAllWithIndex}}... a mouthful. I wonder why we didn't 
simply call it {{Operator.add}}. Perhaps you just do {{Operator.addWithIndex}} 
???

Anywho, that is the theory.






> Provide a way to fold() with an index
> -
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: stephen mallette
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin> 
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
>  select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we 
> can add an option to {{fold()}} that would take an enum of "fold operators".



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)