use of org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphPropertiesStep in project janusgraph by JanusGraph.
the class JanusGraphStepStrategyTest method applyMultiQueryTraversalSteps.
private void applyMultiQueryTraversalSteps(Traversal.Admin<?, ?> traversal) {
TraversalHelper.getStepsOfAssignableClassRecursively(VertexStep.class, traversal).forEach(vertexStep -> {
JanusGraphVertexStep janusGraphVertexStep = new JanusGraphVertexStep<>(vertexStep);
TraversalHelper.replaceStep(vertexStep, janusGraphVertexStep, vertexStep.getTraversal());
if (JanusGraphTraversalUtil.isEdgeReturnStep(janusGraphVertexStep)) {
HasStepFolder.foldInHasContainer(janusGraphVertexStep, vertexStep.getTraversal(), vertexStep.getTraversal());
}
});
TraversalHelper.getStepsOfAssignableClassRecursively(PropertiesStep.class, traversal).forEach(vertexStep -> {
JanusGraphPropertiesStep janusGraphPropertiesStep = new JanusGraphPropertiesStep<>(vertexStep);
TraversalHelper.replaceStep(vertexStep, janusGraphPropertiesStep, vertexStep.getTraversal());
});
TraversalHelper.getStepsOfAssignableClassRecursively(IsStep.class, traversal).forEach(isStep -> {
Object expectedStep = isStep.getPredicate().getValue();
if (expectedStep.equals(JanusGraphMultiQueryStep.class.getSimpleName())) {
TraversalHelper.replaceStep(isStep, new JanusGraphMultiQueryStep(isStep.getTraversal(), false), isStep.getTraversal());
}
});
}
use of org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphPropertiesStep in project janusgraph by JanusGraph.
the class JanusGraphLocalQueryOptimizerStrategy method applyJanusGraphPropertiesSteps.
private void applyJanusGraphPropertiesSteps(Admin<?, ?> traversal) {
TraversalHelper.getStepsOfAssignableClass(PropertiesStep.class, traversal).forEach(originalStep -> {
final JanusGraphPropertiesStep propertiesStep = new JanusGraphPropertiesStep(originalStep);
TraversalHelper.replaceStep(originalStep, propertiesStep, originalStep.getTraversal());
if (propertiesStep.getReturnType().forProperties()) {
HasStepFolder.foldInHasContainer(propertiesStep, originalStep.getTraversal(), originalStep.getTraversal());
// We cannot fold in orders or ranges since they are not local
}
});
}
use of org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphPropertiesStep in project janusgraph by JanusGraph.
the class JanusGraphLocalQueryOptimizerStrategy method inspectLocalTraversals.
private void inspectLocalTraversals(final Admin<?, ?> traversal) {
TraversalHelper.getStepsOfClass(LocalStep.class, traversal).forEach(localStep -> {
final Admin localTraversal = ((LocalStep<?, ?>) localStep).getLocalChildren().get(0);
final Step localStart = localTraversal.getStartStep();
if (localStart instanceof VertexStep) {
final JanusGraphVertexStep vertexStep = new JanusGraphVertexStep((VertexStep) localStart);
TraversalHelper.replaceStep(localStart, vertexStep, localTraversal);
if (JanusGraphTraversalUtil.isEdgeReturnStep(vertexStep)) {
HasStepFolder.foldInHasContainer(vertexStep, localTraversal, traversal);
HasStepFolder.foldInOrder(vertexStep, vertexStep.getNextStep(), localTraversal, traversal, false, null);
}
HasStepFolder.foldInRange(vertexStep, JanusGraphTraversalUtil.getNextNonIdentityStep(vertexStep), localTraversal, null);
unfoldLocalTraversal(traversal, localStep, localTraversal, vertexStep);
}
if (localStart instanceof PropertiesStep) {
final JanusGraphPropertiesStep propertiesStep = new JanusGraphPropertiesStep((PropertiesStep) localStart);
TraversalHelper.replaceStep(localStart, propertiesStep, localTraversal);
if (propertiesStep.getReturnType().forProperties()) {
HasStepFolder.foldInHasContainer(propertiesStep, localTraversal, traversal);
HasStepFolder.foldInOrder(propertiesStep, propertiesStep.getNextStep(), localTraversal, traversal, false, null);
}
HasStepFolder.foldInRange(propertiesStep, JanusGraphTraversalUtil.getNextNonIdentityStep(propertiesStep), localTraversal, null);
unfoldLocalTraversal(traversal, localStep, localTraversal, propertiesStep);
}
});
}
Aggregations