Search in sources :

Example 6 with PropertiesStep

use of org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep in project janusgraph by JanusGraph.

the class HasStepFolder method foldInHasFilter.

/**
 * Convert a TraversalFilterStep that is essentially "has(key)" into a normal HasStep
 * @param traversal local traversal
 * @param currentStep
 */
static Step foldInHasFilter(final Traversal.Admin<?, ?> traversal, final TraversalFilterStep<?> currentStep) {
    List<? extends Traversal.Admin<?, ?>> traversals = currentStep.getLocalChildren();
    assert (traversals.size() == 1);
    List<Step> steps = traversals.get(0).getSteps();
    assert (steps.size() == 1 && steps.get(0) instanceof PropertiesStep);
    String[] propertyKeys = ((PropertiesStep) steps.get(0)).getPropertyKeys();
    assert (propertyKeys.length == 1);
    HasStep hasStep = new HasStep(traversal, new HasContainer(propertyKeys[0], P.neq(null)));
    currentStep.getLabels().forEach(hasStep::addLabel);
    TraversalHelper.replaceStep(currentStep, hasStep, traversal);
    return hasStep;
}
Also used : PropertiesStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep) HasStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep) HasContainer(org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) ValueTraversal(org.apache.tinkerpop.gremlin.process.traversal.lambda.ValueTraversal) FlatMapStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep) EmptyStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep) HasStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep) GraphStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep) OrStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep) OrderGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderGlobalStep) NoOpBarrierStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep) PropertiesStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep) Step(org.apache.tinkerpop.gremlin.process.traversal.Step) IdentityStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep) RangeGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep) TraversalFilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep)

Aggregations

PropertiesStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep)6 Step (org.apache.tinkerpop.gremlin.process.traversal.Step)5 RangeGlobalStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep)4 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)3 LocalStep (org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalStep)3 VertexStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep)3 TraversalFilterStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep)2 GraphStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep)2 Graph (org.apache.tinkerpop.gremlin.structure.Graph)2 JanusGraphPropertiesStep (org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphPropertiesStep)2 StandardTitanGraph (com.thinkaurelius.titan.graphdb.database.StandardTitanGraph)1 StandardTitanTx (com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)1 Admin (org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin)1 ValueTraversal (org.apache.tinkerpop.gremlin.process.traversal.lambda.ValueTraversal)1 HasStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep)1 OrStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep)1 WherePredicateStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.WherePredicateStep)1 EdgeVertexStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep)1 FlatMapStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep)1 NoOpBarrierStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep)1