Search in sources :

Example 1 with ReplacedStepTree

use of org.umlg.sqlg.sql.parse.ReplacedStepTree in project sqlg by pietermartin.

the class SqlgVertexStep method addReplacedStep.

@Override
public ReplacedStepTree.TreeNode addReplacedStep(ReplacedStep replacedStep) {
    replacedStep.setDepth(this.replacedSteps.size());
    this.replacedSteps.add(replacedStep);
    if (this.replacedStepTree == null) {
        // the first root node
        this.replacedStepTree = new ReplacedStepTree(replacedStep);
    } else {
        this.replacedStepTree.addReplacedStep(replacedStep);
    }
    return this.replacedStepTree.getCurrentTreeNodeNode();
}
Also used : ReplacedStepTree(org.umlg.sqlg.sql.parse.ReplacedStepTree)

Example 2 with ReplacedStepTree

use of org.umlg.sqlg.sql.parse.ReplacedStepTree in project sqlg by pietermartin.

the class SqlgGraphStep method addReplacedStep.

@Override
public ReplacedStepTree.TreeNode addReplacedStep(ReplacedStep<?, ?> replacedStep) {
    // depth is + 1 because there is always a root node who's depth is 0
    replacedStep.setDepth(this.replacedSteps.size());
    this.replacedSteps.add(replacedStep);
    // New way of interpreting steps
    if (this.replacedStepTree == null) {
        // the first root node
        this.replacedStepTree = new ReplacedStepTree(replacedStep);
    } else {
        this.replacedStepTree.addReplacedStep(replacedStep);
    }
    return this.replacedStepTree.getCurrentTreeNodeNode();
}
Also used : ReplacedStepTree(org.umlg.sqlg.sql.parse.ReplacedStepTree)

Example 3 with ReplacedStepTree

use of org.umlg.sqlg.sql.parse.ReplacedStepTree in project sqlg by pietermartin.

the class VertexStrategy method combineSteps.

void combineSteps() {
    List<Step<?, ?>> steps = new ArrayList(this.traversal.asAdmin().getSteps());
    ListIterator<Step<?, ?>> stepIterator = steps.listIterator();
    MutableInt pathCount = new MutableInt(0);
    while (stepIterator.hasNext()) {
        Step<?, ?> step = stepIterator.next();
        if (this.reset) {
            this.reset = false;
            this.sqlgStep = null;
        }
        if (isReplaceableStep(step.getClass())) {
            stepIterator.previous();
            boolean keepGoing = handleStep(stepIterator, pathCount);
            if (!keepGoing) {
                break;
            }
        } else {
            // restart
            this.sqlgStep = null;
        }
    }
    if (this.currentTreeNodeNode != null) {
        ReplacedStepTree replacedStepTree = this.currentTreeNodeNode.getReplacedStepTree();
        replacedStepTree.maybeAddLabelToLeafNodes();
    }
}
Also used : ReplacedStepTree(org.umlg.sqlg.sql.parse.ReplacedStepTree) MutableInt(org.apache.commons.lang3.mutable.MutableInt) ArrayList(java.util.ArrayList) EdgeVertexStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep) SqlgVertexStep(org.umlg.sqlg.step.SqlgVertexStep) Step(org.apache.tinkerpop.gremlin.process.traversal.Step) SqlgStep(org.umlg.sqlg.step.SqlgStep) ChooseStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseStep) ReplacedStep(org.umlg.sqlg.sql.parse.ReplacedStep) OptionalStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalStep) VertexStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep)

Aggregations

ReplacedStepTree (org.umlg.sqlg.sql.parse.ReplacedStepTree)3 ArrayList (java.util.ArrayList)1 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1 Step (org.apache.tinkerpop.gremlin.process.traversal.Step)1 ChooseStep (org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseStep)1 OptionalStep (org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalStep)1 EdgeVertexStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep)1 VertexStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep)1 ReplacedStep (org.umlg.sqlg.sql.parse.ReplacedStep)1 SqlgStep (org.umlg.sqlg.step.SqlgStep)1 SqlgVertexStep (org.umlg.sqlg.step.SqlgVertexStep)1