use of org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalSideEffects in project unipop by unipop-graph.
the class UniGraphCoalesceStep method process.
@Override
protected Iterator<Traverser.Admin<E>> process(List<Traverser.Admin<S>> traversers) {
List<Traverser.Admin<E>> coalesce = new ArrayList<>();
List<Traverser.Admin<S>> traversersList = Lists.newArrayList(traversers);
traversersList.forEach(t -> {
t.setSideEffects(new DefaultTraversalSideEffects() {
{
register(t.toString(), () -> t, BinaryOperator.maxBy((o1, o2) -> 1));
set(t.toString(), t);
}
});
});
coalesceTraversals.forEach(t -> {
traversersList.forEach(t::addStart);
while (t.hasNext()) {
Traverser<E> item = (Traverser<E>) t.next();
((B_O_S_SE_SL_Traverser) item).getSideEffects().forEach((key, value) -> {
if (value != null && value instanceof Traverser)
traversersList.remove(value);
});
coalesce.add((item.asAdmin()));
}
});
return coalesce.iterator();
}
use of org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalSideEffects in project unipop by unipop-graph.
the class UniGraphWhereTraversalStep method processNextStart.
@Override
protected Traverser.Admin<S> processNextStart() throws NoSuchElementException {
if (this.starts.hasNext()) {
this.starts.forEachRemaining(start -> {
start.setSideEffects(new DefaultTraversalSideEffects() {
{
register("_whereStep", () -> start, (sAdmin, sAdmin2) -> sAdmin);
}
});
whereTraversal.asAdmin().addStart(start);
originals.add(start);
if (whereTraversal.asAdmin().getStartStep() instanceof UniGraphWhereStartStep) {
((UniGraphWhereStartStep) whereTraversal.asAdmin().getStartStep()).addOriginal(start);
}
});
had = true;
}
if (had && !results.hasNext()) {
HashSet<Traverser.Admin<S>> resultsList = new HashSet<>();
while (whereTraversal.hasNext()) {
had = false;
B_O_S_SE_SL_Traverser next = (B_O_S_SE_SL_Traverser) whereTraversal.next();
Object whereStep = next.getSideEffects().get("_whereStep");
if (whereStep instanceof Traverser)
resultsList.add((Traverser.Admin<S>) whereStep);
else {
results = ((ArrayList<Traverser.Admin<S>>) whereStep).iterator();
}
}
if (resultsList.size() > 0)
results = resultsList.iterator();
}
return results.next();
}
Aggregations