Jamie Burns
JJanusGraph
•Created by Jamie Burns on 3/11/2024 in #questions
script in empty-sample.groovy is called twice
I haven't tried doing that more than once in the same session, but yes, when i execute :remote connect + :remote console, the vertices are created again as you describe above. I'll try connect+console multiple times in the same session and let you know if vertices are being created again each time.
9 replies
JJanusGraph
•Created by Jamie Burns on 3/11/2024 in #questions
script in empty-sample.groovy is called twice
remote.yaml
hosts: [localhost]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1, config: { serializeResultToString: true }}
9 replies
JJanusGraph
•Created by Jamie Burns on 3/11/2024 in #questions
script in empty-sample.groovy is called twice
gremlin connection
:remote connect tinkerpop.server conf/remote.yaml session
:remote console
the duplicates are made on executing :remote console
9 replies
JJanusGraph
•Created by Jamie Burns on 3/11/2024 in #questions
script in empty-sample.groovy is called twice
empty-sample.groovy
I've added a test in buildGraph as a workaround. Without the test, i get duplicate vertices
// an init script that returns a Map allows explicit setting of global bindings.
def globals = [:]
// defines a sample LifeCycleHook that prints some output to the Gremlin Server console.
// note that the name of the key in the "global" map is unimportant.
globals << [hook : [
onStartUp: { ctx ->
ctx.logger.info("Executed once at startup of Gremlin Server.")
},
onShutDown: { ctx ->
ctx.logger.info("Executed once at shutdown of Gremlin Server.")
}
] as LifeCycleHook]
System.out.println( ">>>>> mapping traversal sources" )
// define the default TraversalSource to bind queries to - this one will be named "g".
globals << [ g : graph.traversal(),
g_garden : gardengraph.traversal(),
g_pbr : pbrgraph.traversal()
]
System.out.println( ">>>>> mapped traversal sources" )
globals.values().forEach( System.out::println )
buildGraph()
void buildGraph()
{
g = graph.traversal()
if( g.V().hasNext() )
{
return
}
rV = g.addV('r').property('name', 'r-name').next()
bV = g.addV('b').property('name', 'b-name').next()
lV = g.addV('l').property('name', 'l-name').next()
g.V(rV).addE('c').to(bV).property('name', 'r-b').next()
g.V(rV).addE('ht').to(lV).property('name', 'r-ht').next()
g.tx().commit()
System.out.println( ">>>>>> post tx commit" )
g.V().each( System.out::println )
}
9 replies