carnival-data / carnival

JVM property graph data unification framework
https://carnival-data.github.io/carnival/
GNU General Public License v3.0
7 stars 2 forks source link

Add an execution context to GraphMethod execute() method #128

Open augustearth opened 2 months ago

augustearth commented 2 months ago

The method that graph methods currently have to implement is:

abstract void execute(Graph graph, GraphTraversalSource g) 

This means that the execute method has access to the graph, but no other context for the execution including the process vertex that was created. To make it easier for the execute method to attach graph elements to the process vertex, we need to supply a pointer to it. The process vertex is currently available to the graph method as a protected field, which works, but also makes the GraphMethod object not thread-safe. The processVertex is set at the start of the execution. If execution is called again while the first is still running, then processVertex will be overwritten with the one created for the second call.

Create an ExecutionContext that will be passed to execute. Not sure if we should add a parameter or put the Graph and GraphTraversalSource in the context...

abstract void execute(Graph graph, GraphTraversalSource g, ExecutionContext ctx) 

or

abstract void execute(ExecutionContext ctx)