use of com.vaticle.typedb.core.graph.vertex.ThingVertex in project grakn by graknlabs.
the class RelationIterator method createIterator.
private Forwardable<ThingVertex, Order.Asc> createIterator(int pos) {
StructureEdge<?, ?> edge = edges.get(pos);
ThingVertex player = answer.get(edge.to().id().asVariable().asRetrievable()).asThing();
return SortedIterators.Forwardable.merge(iterate(edge.asNative().asRolePlayer().types()).map(roleLabel -> {
TypeVertex roleVertex = graphMgr.schema().getType(roleLabel);
return player.ins().edge(ROLEPLAYER, roleVertex).fromAndOptimised().filter(relRole -> relationTypes.contains(relRole.key().type().properLabel()));
}), ASC).filter(relRole -> !scoped.contains(relRole.value())).mapSorted(relRole -> {
scoped.record(pos, relRole.value());
return relRole.key();
}, relation -> new KeyValue<>(relation, null), ASC);
}
use of com.vaticle.typedb.core.graph.vertex.ThingVertex in project grakn by graknlabs.
the class RelationIterator method proposeNext.
private void proposeNext() {
assert state == State.EMPTY;
Forwardable<ThingVertex, Order.Asc> relationIterator = getIterator(proposer);
// relationIterator requires clearing of scoped roles as it is stateful
scoped.clear();
while (relationIterator.hasNext()) {
ThingVertex newRelation = relationIterator.next();
if (!newRelation.equals(relation)) {
relation = newRelation;
state = State.PROPOSED;
return;
}
}
state = State.COMPLETED;
}
Aggregations