Hi,

Currently for TinkerPop 3.1.0-incubating Sqlg follows the following pattern.

In SqlgGraph
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/structure/SqlgGraph.java>
in a static code block invokes

static {
   TraversalStrategies.GlobalCache.registerStrategies(Graph.class,
TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(new
SqlgVertexStepStrategy()));
   TraversalStrategies.GlobalCache.registerStrategies(Graph.class,
TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(new
SqlgGraphStepStrategy()));
  
TraversalStrategies.GlobalCache.getStrategies(Graph.class).setTraverserGeneratorFactory(new
SqlgTraverserGeneratorFactory());                                               
                                                            

}

i.e. This gives Sqlg a place to set a custom TraverserGeneratorFactory
SqlgTraverserGeneratorFactory
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlgTraverserGeneratorFactory.java>

SqlgTraverserGeneratorFactory
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlgTraverserGeneratorFactory.java>
will depending on the TraverserRequirement(s) either use TinkerPop's
DefaultTraverserGeneratorFactory (I copied the code :-\) or
SqlgGraphStepWithPathTraverserGenerator
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlgGraphStepWithPathTraverserGenerator.java>.
SqlgGraphStepWithPathTraverserGenerator
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlgGraphStepWithPathTraverserGenerator.java>
instantiates SqlGraphStepWithPathTraverser
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlGraphStepWithPathTraverser.java>
Sqlg's custom Traverser.

Sqlg has only one Traverser, SqlGraphStepWithPathTraverser
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlGraphStepWithPathTraverser.java>.
It extends B_LP_O_P_S_SE_SL_Traverser which in many ways is where I am
getting lucky. So far I have gotten away with only using one Traverser.
Its probably unoptimized and needs refactoring.

SqlGraphStepWithPathTraverser
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlGraphStepWithPathTraverser.java>
has one method customSplit(...) which is needed to construct the
Traverser's path. For the most part it uses specific information passed
on from Sqlg's custom steps to construct the Traverser's path.

SqlGraphStepWithPathTraverser
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/process/SqlGraphStepWithPathTraverser.java>'s
state is modified from Sqlg's custom Steps. Primarily
SqlgGraphStepCompiled
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/strategy/SqlgGraphStepCompiled.java>
and SqlgVertexStepCompiled
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/strategy/SqlgVertexStepCompiled.java>

These 2 steps are instantiated by SqlgGraphStepStrategy
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/strategy/SqlgGraphStepStrategy.java>
and SqlgVertexStepStrategy
<https://github.com/pietermartin/sqlg/blob/schema/sqlg-core/src/main/java/org/umlg/sqlg/strategy/SqlgVertexStepStrategy.java>.
They are responsible to recompile TinkerPop's steps into Sqlg steps.

The tp31 TraversalStrategies
<https://github.com/apache/incubator-tinkerpop/blob/tp31/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java>.setTraverserGeneratorFactory
has been removed in master, removing the entry point for Sqlg to set a
custom TraverserGeneratorFactory and via that a custom Traverser.

Hope its useful.

Thanks
Pieter

Reply via email to