use of org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphStep in project janusgraph by JanusGraph.
the class JanusGraphStepStrategyTest method g_V.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static GraphTraversal.Admin<?, ?> g_V(final Object... hasKeyValues) {
final GraphTraversal.Admin<?, ?> traversal = new DefaultGraphTraversal<>();
final JanusGraphStep<Vertex, Vertex> graphStep = new JanusGraphStep<>(new GraphStep<>(traversal, Vertex.class, true));
for (int i = 0; i < hasKeyValues.length; i++) {
if (hasKeyValues[i].equals(T.id)) {
graphStep.addIds(Collections.singletonList(hasKeyValues[i + 1]));
i++;
} else if (hasKeyValues[i] instanceof HasStepFolder.OrderEntry) {
final HasStepFolder.OrderEntry orderEntry = (HasStepFolder.OrderEntry) hasKeyValues[i];
graphStep.orderBy(orderEntry.key, orderEntry.order);
} else if (hasKeyValues[i] instanceof DefaultGraphTraversal && ((DefaultGraphTraversal) hasKeyValues[i]).getStartStep() instanceof OrStep) {
OrStep<?> orStep = (OrStep<?>) ((DefaultGraphTraversal) hasKeyValues[i]).getStartStep();
for (final Traversal.Admin<?, ?> child : orStep.getLocalChildren()) {
final JanusGraphStep<Vertex, Vertex> localGraphStep = ((JanusGraphStep<Vertex, Vertex>) ((DefaultGraphTraversal) child).getStartStep());
graphStep.addLocalHasContainersConvertingAndPContainers(orStep, localGraphStep.getHasContainers());
localGraphStep.getOrders().forEach(orderEntry -> graphStep.localOrderBy(orStep, localGraphStep.getHasContainers(), orderEntry.key, orderEntry.order));
graphStep.setLocalLimit(orStep, localGraphStep.getHasContainers(), localGraphStep.getLowLimit(), localGraphStep.getHighLimit());
}
} else if (hasKeyValues[i] instanceof DefaultGraphTraversal && ((DefaultGraphTraversal) hasKeyValues[i]).getStartStep() instanceof RangeGlobalStep) {
final RangeGlobalStep range = (RangeGlobalStep) ((DefaultGraphTraversal) hasKeyValues[i]).getStartStep();
graphStep.setLimit((int) range.getLowRange(), (int) range.getHighRange());
} else if (i < hasKeyValues.length - 1 && hasKeyValues[i + 1] instanceof ConnectiveP) {
final ConnectiveJanusPredicate connectivePredicate = JanusGraphPredicateUtils.instanceConnectiveJanusPredicate((ConnectiveP) hasKeyValues[i + 1]);
graphStep.addHasContainer(new HasContainer((String) hasKeyValues[i], new P<>(connectivePredicate, JanusGraphPredicateUtils.convert(((ConnectiveP<?>) hasKeyValues[i + 1]), connectivePredicate))));
i++;
} else {
graphStep.addHasContainer(new HasContainer((String) hasKeyValues[i], (P) hasKeyValues[i + 1]));
i++;
}
}
return traversal.addStep(graphStep);
}
use of org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphStep in project janusgraph by JanusGraph.
the class JanusGraphStepStrategyTest method shouldTriggerHasContainerSplit.
@Test
public void shouldTriggerHasContainerSplit() {
final GraphTraversal.Admin<?, ?> traversal = new DefaultGraphTraversal<>();
final JanusGraphStep<Vertex, Vertex> graphStep = new JanusGraphStep<>(new GraphStep<>(traversal, Vertex.class, true));
graphStep.addHasContainer(new HasContainer("age", P.between("1", "123")));
assertEquals(2, graphStep.getHasContainers().size());
}
Aggregations