Hi,

I am trying to optimize queries with 'as' in it.

Currently I can optimize consecutive VertexStep and EdgeVertexStep
(without labels) by combining them into one step.

Now I am trying to achieve the same but with 'as' in the traversal.

e.g.

Vertex a1 = g.addVertex(T.label, "A", "name", "a1");
Vertex b1 = g.addVertex(T.label, "B", "name", "b1");
Vertex b2 = g.addVertex(T.label, "B", "name", "b2");
Edge e1 = a1.addEdge("outB", b1);
Edge e2 = a1.addEdge("outB", b2);
 
g.tx().commit();
 
GraphTraversal<Vertex, Map<String, Element>> traversal = g.traversal()
        .V(a1)
        .outE("outB")
        .as("e")
        .inV()
        .as("B")
        .select("e", "B");

I combine all consecutive VertexStep, EdgeVertexStep into one step,
execute one query and with the result I can construct the labeled edge
("e") and vertices ("B").

So far in the combined step I have all the information, but alas what now?

public class SqlgVertexStepCompiled<S extends SqlgElement, E extends
SqlgElement> extends FlatMapStep<S, E> {

...

@Override
protected Traverser<E> processNextStart() {
    while (true) {
        if (this.iterator.hasNext()) {
            Pair<E, Map<String, Object>> next = this.iterator.next();
            E e = next.getLeft();
            Map<String, Object> labeledObjects = next.getRight();
            for (String label : labeledObjects.keySet()) {
                //What to do
                this.head.path().extend(labeledObjects.get(label), label);
            }
            return this.head.split(e, this);
        } else {
            this.head = this.starts.next();
            this.iterator = this.flatMapCustom(this.head);
        }
    }
}

...

Any pointers?

btw, what does all those strange traverser names mean,
B_O_P_S_SE_SL_Traverser...

Thanks
Pieter

Reply via email to