Skip to content

Conversation

maguec
Copy link
Contributor

@maguec maguec commented Nov 21, 2018

Running the following

package main import ( "fmt" "github.com/gomodule/redigo/redis" rg "github.com/redislabs/redisgraph-go" ) func main() { conn, _ := redis.Dial("tcp", "localhost:6379") defer conn.Close() graph := rg.Graph{}.New("social", conn) users := [3]string{"Barney", "Betty", "Bam-Bam"} for k, user := range users { family := rg.Node{ Label: "person", Properties: map[string]interface{}{ "name": fmt.Sprintf("%s Rubble", user), "age": 66 / (k + 2), }, } graph.AddNode(&family) graph.Commit() } query := "MATCH (p:person) RETURN p.name" rs, _ := graph.Query(query) rs.PrettyPrint() } 

Returns:

+----------------+ | p.name | +----------------+ | Barney Rubble | | Barney Rubble | | Betty Rubble | | Barney Rubble | | Betty Rubble | | Bam-Bam Rubble | +----------------+ 

Running Monitor seems to show that the node map is not being cleared after commiit

1542758947.998021 [0 127.0.0.1:61749] "GRAPH.QUERY" "social" "CREATE (BbUuWmSqQS:person{name:\"Barney Rubble\",age:33})" 1542758947.998647 [0 127.0.0.1:61749] "GRAPH.QUERY" "social" "CREATE (BbUuWmSqQS:person{name:\"Barney Rubble\",age:33}),(TfTgQICgTE:person{name:\"Betty Rubble\",age:22})" 1542758947.999356 [0 127.0.0.1:61749] "GRAPH.QUERY" "social" "CREATE (BbUuWmSqQS:person{name:\"Barney Rubble\",age:33}),(TfTgQICgTE:person{name:\"Betty Rubble\",age:22}),(nrTQwhTlDQ:person{name:\"Bam-Bam Rubble\",age:16})" 1542758947.999977 [0 127.0.0.1:61749] "GRAPH.QUERY" "social" "MATCH (p:person) RETURN p.name" 
@itamarhaber
Copy link
Contributor

Thanks @maguec - @swilly22 this is ported from redisgraph-py, WDUT?

@swilly22
Copy link
Contributor

The issue is with the multiple calls to graph.commit,
The idea is to introduce all nodes to the graph before committing it,
The example above calls commit multiple times, each time with a graph bigger by one node from the previous iteration.

@swilly22
Copy link
Contributor

For some use-cases it would make sense to clear after commit, but there might be situations where you would like to keep the Go graph representation, I don't mind introducing an explicit clear function but that would need to take into account both nodes and edges.

@maguec
Copy link
Contributor Author

maguec commented Nov 26, 2018

I will rewrite with a specific flush funciont

@maguec maguec closed this Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants