Skip to content

Commit

Permalink
Edit Java modern comment, add simple JS query to test config, add wai…
Browse files Browse the repository at this point in the history
…ts after Iterate() in Go
  • Loading branch information
ryn5 committed Oct 7, 2023
1 parent 4155787 commit 1fe2a48
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 1 addition & 5 deletions gremlin-driver/src/main/java/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ private static void basicGremlinExample() {
}

private static void modernTraversalExample() {
/*
This example requires the Modern toy graph to be preloaded upon launching the Gremlin server.
For details, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-server-docker-image and use
conf/gremlin-server-modern.yaml.
*/
// Performs basic traversals on the Modern toy graph which can be created using TinkerFactory
Graph modern = TinkerFactory.createModern();
GraphTraversalSource g = traversal().withEmbedded(modern);

Expand Down
15 changes: 9 additions & 6 deletions gremlin-go/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package main

import (
"fmt"

gremlingo "github.com/apache/tinkerpop/gremlin-go/driver"
)

Expand Down Expand Up @@ -83,8 +84,14 @@ func basicGremlinExample() {

// Be sure to use a terminating step like next() or iterate() so that the traversal "executes"
// Iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database)
g.V(v1Vertex).AddE("knows").To(v2Vertex).Property("weight", 0.75).Iterate()
g.V(v1Vertex).AddE("knows").To(v3Vertex).Property("weight", 0.75).Iterate()
promise := g.V(v1Vertex).AddE("knows").To(v2Vertex).Property("weight", 0.75).Iterate()
err = <-promise
promise = g.V(v1Vertex).AddE("knows").To(v3Vertex).Property("weight", 0.75).Iterate()
err = <-promise
if err != nil {
fmt.Println(err)
return
}

// Retrieve the data from the "marko" vertex
marko, err := g.V().Has("person", "name", "marko").Values("name").Next()
Expand All @@ -95,7 +102,6 @@ func basicGremlinExample() {
for _, person := range peopleMarkoKnows {
fmt.Println("marko knows", person.GetString())
}

}

func modernTraversalExample() {
Expand All @@ -112,9 +118,6 @@ func modernTraversalExample() {
For details, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-server-docker-image and use
conf/gremlin-server-modern.yaml.
*/
//e1, err := g.V().Next() // (1)
//fmt.Println(e1)

e1, err := g.V(1).BothE().ToList() // (1)
e2, err := g.V().BothE().Where(__.OtherV().HasId(2)).ToList() // (2)
v1, err := g.V(1).Next()
Expand Down
15 changes: 9 additions & 6 deletions gremlin-javascript/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,31 @@ const serializer = gremlin.structure.io.graphserializer;
const testing = Direction.to;

async function main() {
await connectionExample();
// await connectionExample();
await basicGremlinExample();
await modernTraversalExample();
}



async function connectionExample() {
// Connecting to the server
let dc = new DriverRemoteConnection('ws://localhost:8182/gremlin');
let g = traversal().withRemote(dc);

// Connecting and customizing configurations
g = traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', {
dc = new DriverRemoteConnection('ws://localhost:8182/gremlin', {
mimeType: 'application/vnd.gremlin-v3.0+json',
reader: serializer,
writer: serializer,
rejectUnauthorized: false,
traversalSource: 'g',
}));
})
g = traversal().withRemote(dc);

// Simple query to verify connection
const v = await g.addV().iterate();
const count = await g.V().count().next();
console.log(count.value);

// Cleanup
await dc.close();
}
Expand Down Expand Up @@ -103,7 +107,6 @@ async function modernTraversalExample() {
For details, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-server-docker-image and use
conf/gremlin-server-modern.yaml.
*/

let dc = new DriverRemoteConnection('ws://localhost:8182/gremlin');
let g = traversal().withRemote(dc);

Expand Down

0 comments on commit 1fe2a48

Please sign in to comment.