use of org.unipop.process.predicate.ReceivesPredicatesHolder in project unipop by unipop-graph.
the class UniGraphOrderStrategy method apply.
@Override
public void apply(Traversal.Admin<?, ?> traversal) {
TraversalHelper.getStepsOfAssignableClass(OrderGlobalStep.class, traversal).forEach(orderGlobalStep -> {
List<Pair<Traversal.Admin, Comparator>> comparators = orderGlobalStep.getComparators();
List<Pair<String, Order>> collect = comparators.stream().filter(pair -> pair.getValue0() instanceof ElementValueTraversal).filter(pair -> pair.getValue1() instanceof Order).map(pair -> Pair.with(((ElementValueTraversal) pair.getValue0()).getPropertyKey(), ((Order) pair.getValue1()))).collect(Collectors.toList());
Collection<Orderable> orderableStepOf = getOrderableStepOf(orderGlobalStep, traversal);
if (orderableStepOf != null && orderableStepOf.size() == 1) {
Orderable step = orderableStepOf.iterator().next();
step.setOrders(collect);
Step nextStep = orderGlobalStep.getNextStep();
if (nextStep instanceof RangeGlobalStep) {
if (step instanceof ReceivesPredicatesHolder) {
RangeGlobalStep rangeGlobalStep = (RangeGlobalStep) nextStep;
int limit = rangeGlobalStep.getHighRange() > Integer.MAX_VALUE ? -1 : (int) rangeGlobalStep.getHighRange();
((ReceivesPredicatesHolder) step).setLimit(limit);
}
}
}
});
}
Aggregations