Re: [DISCUSS] Union of Traversals

2023-02-24 Thread Kelvin Lawrence
I think making union() a start step makes a lot of sense. It enables several 
useful query patterns. 
Cheers, Kelvin  

On Wednesday, February 22, 2023 at 06:33:25 AM CST, Martin 
 wrote:  
 
 Dear TinkerPop developers!

I was recently faced with the task to create the union of a given list 
of (anonymous) traversals, each of which had defined start and end 
steps. The intended effect was similar to a "UNION ALL" in SQL. This 
turned out to be tricky to achieve in Gremlin. Please find the details, 
the workaround, and my proposed solution (having "union" as a traversal 
start step) here:

https://issues.apache.org/jira/browse/TINKERPOP-2873?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&focusedCommentId=17692159#comment-17692159

I'm happy to discuss this matter. Thank you for your consideration.

Kind regards,

Martin Häusler

  

[jira] [Commented] (TINKERPOP-2767) Repeat Out Times traversal hangs indefinitely on first execution

2023-02-24 Thread ASF GitHub Bot (Jira)


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

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

xiazcy commented on PR #1979:
URL: https://github.com/apache/tinkerpop/pull/1979#issuecomment-1444142109

   Thanks Cole! Merging this as it's cherry picked from an approved PR. 




> Repeat Out Times traversal hangs indefinitely on first execution
> 
>
> Key: TINKERPOP-2767
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2767
> Project: TinkerPop
>  Issue Type: Bug
>  Components: server
>Affects Versions: 3.5.3
> Environment: Windows 10
>Reporter: Simon Zhao
>Priority: Major
> Fix For: 3.5.6
>
>
> Originally encountered when fixing TINKERPOP-2754
>  
> The following traversal in JS seems to cause hanging the first time you run 
> it on a newly launched gremlin-server (3.5.3) via docker
>  
> {{await g.V('1').repeat(_.out()).times(1500).next();}}
>  
> The same hanging occurs in gremlin-go. 
>  
> {code:java}
> _, err = g.With("evaluationTimeout", 
> 1000).V("1").Repeat(gremlingo.T__.Out()).Times(int32(1500)).Next() {code}
>  
> The timeout is optional, but indicates that something is going wrong since it 
> is not returning. Interestingly enough, if the timeout is very low, then it 
> won't hang because it will say the timeout was exceeded. This indicates that 
> if the traversal is completed within the timeout, it's just not returning for 
> some reason on the first call.
>  
> If you were to write a script and invoke this snippet of code, it will hang. 
> If you forcefully terminate the script and rerun it, then it doesn't hang.
>  
> main.go
> {code:java}
> package main
> import (
>gremlingo "github.com/apache/tinkerpop/gremlin-go/v3/driver"
>"log"
> )
> func main() {
>driver, err := 
> gremlingo.NewDriverRemoteConnection("ws://localhost:45940/gremlin")
>if err != nil {
>   log.Print("Err creating DRC")
>   return
>}
>defer driver.Close()
>log.Println("Start")
>g := gremlingo.Traversal_().WithRemote(driver)
>LABEL := "test"
>_, err = g.V().HasLabel(LABEL).Drop().Next()
>_, err = g.AddV(LABEL).Property(gremlingo.T.Id, "1").Next()
>_, err = g.AddV(LABEL).Property(gremlingo.T.Id, "2").Next()
>_, err = 
> g.AddE(LABEL).From(gremlingo.T__.V("1")).To(gremlingo.T__.V("2")).Property(gremlingo.T.Id,
>  "e1").Next()
>_, err = 
> g.AddE(LABEL).From(gremlingo.T__.V("2")).To(gremlingo.T__.V("1")).Property(gremlingo.T.Id,
>  "e2").Next()
>if err != nil {
>   log.Println("Error during setup")
>   return
>}
>log.Println("Start the problematic traversal")
>_, err = g.With("evaluationTimeout", 
> 1000).V("1").Repeat(gremlingo.T__.Out()).Times(int32(1500)).Next()
>if err != nil {
>   log.Println("Error with the problematic traversal, but we didn't hang")
>   return
>}
>log.Println("End")
> } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (TINKERPOP-2767) Repeat Out Times traversal hangs indefinitely on first execution

2023-02-24 Thread ASF GitHub Bot (Jira)


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

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

xiazcy merged PR #1979:
URL: https://github.com/apache/tinkerpop/pull/1979




> Repeat Out Times traversal hangs indefinitely on first execution
> 
>
> Key: TINKERPOP-2767
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2767
> Project: TinkerPop
>  Issue Type: Bug
>  Components: server
>Affects Versions: 3.5.3
> Environment: Windows 10
>Reporter: Simon Zhao
>Priority: Major
> Fix For: 3.5.6
>
>
> Originally encountered when fixing TINKERPOP-2754
>  
> The following traversal in JS seems to cause hanging the first time you run 
> it on a newly launched gremlin-server (3.5.3) via docker
>  
> {{await g.V('1').repeat(_.out()).times(1500).next();}}
>  
> The same hanging occurs in gremlin-go. 
>  
> {code:java}
> _, err = g.With("evaluationTimeout", 
> 1000).V("1").Repeat(gremlingo.T__.Out()).Times(int32(1500)).Next() {code}
>  
> The timeout is optional, but indicates that something is going wrong since it 
> is not returning. Interestingly enough, if the timeout is very low, then it 
> won't hang because it will say the timeout was exceeded. This indicates that 
> if the traversal is completed within the timeout, it's just not returning for 
> some reason on the first call.
>  
> If you were to write a script and invoke this snippet of code, it will hang. 
> If you forcefully terminate the script and rerun it, then it doesn't hang.
>  
> main.go
> {code:java}
> package main
> import (
>gremlingo "github.com/apache/tinkerpop/gremlin-go/v3/driver"
>"log"
> )
> func main() {
>driver, err := 
> gremlingo.NewDriverRemoteConnection("ws://localhost:45940/gremlin")
>if err != nil {
>   log.Print("Err creating DRC")
>   return
>}
>defer driver.Close()
>log.Println("Start")
>g := gremlingo.Traversal_().WithRemote(driver)
>LABEL := "test"
>_, err = g.V().HasLabel(LABEL).Drop().Next()
>_, err = g.AddV(LABEL).Property(gremlingo.T.Id, "1").Next()
>_, err = g.AddV(LABEL).Property(gremlingo.T.Id, "2").Next()
>_, err = 
> g.AddE(LABEL).From(gremlingo.T__.V("1")).To(gremlingo.T__.V("2")).Property(gremlingo.T.Id,
>  "e1").Next()
>_, err = 
> g.AddE(LABEL).From(gremlingo.T__.V("2")).To(gremlingo.T__.V("1")).Property(gremlingo.T.Id,
>  "e2").Next()
>if err != nil {
>   log.Println("Error during setup")
>   return
>}
>log.Println("Start the problematic traversal")
>_, err = g.With("evaluationTimeout", 
> 1000).V("1").Repeat(gremlingo.T__.Out()).Times(int32(1500)).Next()
>if err != nil {
>   log.Println("Error with the problematic traversal, but we didn't hang")
>   return
>}
>log.Println("End")
> } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Closed] (TINKERPOP-2767) Repeat Out Times traversal hangs indefinitely on first execution

2023-02-24 Thread Yang Xia (Jira)


 [ 
https://issues.apache.org/jira/browse/TINKERPOP-2767?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yang Xia closed TINKERPOP-2767.
---
Fix Version/s: 3.6.3
   Resolution: Fixed

> Repeat Out Times traversal hangs indefinitely on first execution
> 
>
> Key: TINKERPOP-2767
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2767
> Project: TinkerPop
>  Issue Type: Bug
>  Components: server
>Affects Versions: 3.5.3
> Environment: Windows 10
>Reporter: Simon Zhao
>Priority: Major
> Fix For: 3.6.3, 3.5.6
>
>
> Originally encountered when fixing TINKERPOP-2754
>  
> The following traversal in JS seems to cause hanging the first time you run 
> it on a newly launched gremlin-server (3.5.3) via docker
>  
> {{await g.V('1').repeat(_.out()).times(1500).next();}}
>  
> The same hanging occurs in gremlin-go. 
>  
> {code:java}
> _, err = g.With("evaluationTimeout", 
> 1000).V("1").Repeat(gremlingo.T__.Out()).Times(int32(1500)).Next() {code}
>  
> The timeout is optional, but indicates that something is going wrong since it 
> is not returning. Interestingly enough, if the timeout is very low, then it 
> won't hang because it will say the timeout was exceeded. This indicates that 
> if the traversal is completed within the timeout, it's just not returning for 
> some reason on the first call.
>  
> If you were to write a script and invoke this snippet of code, it will hang. 
> If you forcefully terminate the script and rerun it, then it doesn't hang.
>  
> main.go
> {code:java}
> package main
> import (
>gremlingo "github.com/apache/tinkerpop/gremlin-go/v3/driver"
>"log"
> )
> func main() {
>driver, err := 
> gremlingo.NewDriverRemoteConnection("ws://localhost:45940/gremlin")
>if err != nil {
>   log.Print("Err creating DRC")
>   return
>}
>defer driver.Close()
>log.Println("Start")
>g := gremlingo.Traversal_().WithRemote(driver)
>LABEL := "test"
>_, err = g.V().HasLabel(LABEL).Drop().Next()
>_, err = g.AddV(LABEL).Property(gremlingo.T.Id, "1").Next()
>_, err = g.AddV(LABEL).Property(gremlingo.T.Id, "2").Next()
>_, err = 
> g.AddE(LABEL).From(gremlingo.T__.V("1")).To(gremlingo.T__.V("2")).Property(gremlingo.T.Id,
>  "e1").Next()
>_, err = 
> g.AddE(LABEL).From(gremlingo.T__.V("2")).To(gremlingo.T__.V("1")).Property(gremlingo.T.Id,
>  "e2").Next()
>if err != nil {
>   log.Println("Error during setup")
>   return
>}
>log.Println("Start the problematic traversal")
>_, err = g.With("evaluationTimeout", 
> 1000).V("1").Repeat(gremlingo.T__.Out()).Times(int32(1500)).Next()
>if err != nil {
>   log.Println("Error with the problematic traversal, but we didn't hang")
>   return
>}
>log.Println("End")
> } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (TINKERPOP-2824) Properties on Elements

2023-02-24 Thread ASF GitHub Bot (Jira)


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

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

vkagamlyk commented on code in PR #1843:
URL: https://github.com/apache/tinkerpop/pull/1843#discussion_r1117575914


##
gremlin-python/src/main/python/tests/structure/io/test_functionalityio.py:
##
@@ -25,6 +25,34 @@
 from gremlin_python.statics import *
 
 
+def test_vertex(remote_connection):
+g = Graph().traversal().withRemote(remote_connection)
+vertex = g.V(1).next()
+assert vertex.id == 1
+assert len(vertex.properties) == 2
+assert vertex.properties[0].key == 'name'
+assert vertex.properties[0].value == 'marko'
+assert vertex.properties[1].key == 'age'
+assert vertex.properties[1].value == 29
+
+
+def test_vertex_without_properties(remote_connection):
+g = Graph().traversal().withRemote(remote_connection)
+vertex = g.with_('materializeProperties', 'tokens').V(1).next()
+assert vertex.id == 1
+# empty array for GraphBinary and missing field for GraphSON
+assert vertex.properties is None or len(vertex.properties) == 0
+
+
+def test_edge(remote_connection):

Review Comment:
   added in 
https://github.com/apache/tinkerpop/pull/1843/commits/9e9520b1c4aefa027445a351af19900cdd0bdeb9





> Properties on Elements
> --
>
> Key: TINKERPOP-2824
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2824
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: dotnet, driver, go, javascript, process, python
>Affects Versions: 3.5.4
>Reporter: Valentyn Kahamlyk
>Assignee: Valentyn Kahamlyk
>Priority: Major
>
> Problem: When a user writes `g.V()` they get back a Vertex object. The 
> problem is that depending on the execution context of the traversal, the 
> result could be quite different, with or without properties.
> Solution: Implement new finalization strategy DetachStrategy(detachMode, 
> properties) where mode is one of ALL, NONE or CUSTOM. `properties` is list of 
> properties name, are taken into account only for CUSTOM mode.
> Discussion thread in dev list: [Proposal to handle properties on response 
> Elements-Apache Mail 
> Archives|https://lists.apache.org/thread/l8rw7ydj7kym8vhtwk50nhbp45ng9986]
> Stephen's thread in dev list: [The Issue of Detachment-Apache Mail 
> Archives|https://lists.apache.org/thread/xltcon4zxnwq4fyw2r2126syyrqm8spy]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (TINKERPOP-2873) Allow Union of Traversals

2023-02-24 Thread Stephen Mallette (Jira)


 [ 
https://issues.apache.org/jira/browse/TINKERPOP-2873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stephen Mallette updated TINKERPOP-2873:

Issue Type: Improvement  (was: New Feature)

> Allow Union of Traversals
> -
>
> Key: TINKERPOP-2873
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2873
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: language
>Affects Versions: 3.6.2
>Reporter: Martin Häusler
>Priority: Minor
>
> Currently, it is possible to use the gremlin "union(...)" step as a union 
> based on *traversers*. The union takes each incoming traverser, and clones it 
> for each sub-traversal and feeds it to the sub-traversal as input.
> There is another type of union, which relates more to a SQL "UNION ALL" 
> command. This second type of union is the union of *Traversals*. So we have 
> *independent* traversals with their own start and end steps, and we want to 
> combine them into a single traversal. The outcome of this traversal is the 
> union of the outcome of all sub-traversals.
> One way to achieve this would be to allow "union(...)" step as the initial 
> step for a traversal:
> {code:java}
> g.traversal().union(t1, t2, t3) ...  // traversal continues here
> {code}
> The purpose of this mechanism is:
> * The root traversal after the "union(...)" step has access to all of the 
> labels and side effect keys of the sub-traversals and can operate on them.
> * The root traversal can operate on the resulting traversers and continue to 
> filter them, perform navigation steps, etc.
> Currently, the workaround for this kind of "traversal union" is:
> {code:java}
> g.traversal().inject(0).union(t1, t2, t3) ...  // traversal continues here
> {code}
> Here, we inject a dummy value of 0 into the traversal which only exists to 
> trigger the union step, where it is discarded immediately by all alternatives 
> (which come with their own start steps). This works as intended and also 
> shares side effect keys etc. but is syntactically unpleasant and rather 
> confusing to read.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)