Package com.tinkerpop.gremlin.process

Examples of com.tinkerpop.gremlin.process.Step


        if (startStep.startAssignableTo(Vertex.class, Edge.class)) {
            final Element element = ((StartStep<?>) startStep).getStart();
            final String label = startStep.getLabel();
            TraversalHelper.removeStep(startStep, traversal);
            if (TraversalHelper.isLabeled(label)) {
                final Step identityStep = new IdentityStep(traversal);
                identityStep.setLabel(label);
                TraversalHelper.insertStep(identityStep, 0, traversal);
            }
            TraversalHelper.insertStep(new HasStep(traversal, new HasContainer(T.id, Compare.eq, element.id())), 0, traversal);
            TraversalHelper.insertStep(new TinkerGraphStep<>(traversal, element.getClass()), 0, traversal);
        }
View Full Code Here


    public void apply(final Traversal<?, ?> traversal, final TraversalEngine engine) {
        if(engine.equals(TraversalEngine.STANDARD))
            return;

        if (TraversalHelper.hasStepOfAssignableClass(Comparing.class, traversal)) {
            final Step endStep = TraversalHelper.getEnd(traversal);
            TraversalHelper.getStepsOfAssignableClass(Comparing.class, traversal)
                    .stream()
                    .filter(step -> step != endStep)
                    .forEach(step -> TraversalHelper.removeStep(step, traversal));
        }
View Full Code Here

        this.firstKey = null;
        this.secondKey = null;
        this.biPredicate = null;
        this.constraint = constraint;

        final Step startStep = TraversalHelper.getStart(constraint);
        final Step endStep = TraversalHelper.getEnd(constraint);

        this.setPredicate(traverser -> {
            final Map<String, E> map = traverser.get();
            if (!map.containsKey(startStep.getLabel()))
                throw new IllegalArgumentException("The provided key is not in the current map: " + startStep.getLabel());
            final Object startObject = map.get(startStep.getLabel());
            final Object endObject;
            if (TraversalHelper.isLabeled(endStep)) {
                if (!map.containsKey(endStep.getLabel()))
                    throw new IllegalArgumentException("The provided key is not in the current map: " + endStep.getLabel());
                endObject = map.get(endStep.getLabel());
            } else
                endObject = null;

            startStep.addStart(TraversalStrategies.GlobalCache.getStrategies(constraint.getClass()).getTraverserGenerator(constraint, TraversalEngine.STANDARD).generate(startObject, startStep));
            if (null == endObject) {
View Full Code Here

    }

    private static void reLinkSteps(final Traversal<?, ?> traversal) {
        final List<Step> steps = traversal.getSteps();
        for (int i = 0; i < steps.size(); i++) {
            final Step previousStep = i > 0 ? steps.get(i - 1) : null;
            final Step currentStep = steps.get(i);
            final Step nextStep = i < steps.size() - 1 ? steps.get(i + 1) : null;
            currentStep.setPreviousStep(null != previousStep ? previousStep : EmptyStep.instance());
            currentStep.setNextStep(null != nextStep ? nextStep : EmptyStep.instance());
        }
    }
View Full Code Here

        return builder.toString();
    }

    public static String makeTraversalString(final Traversal<?, ?> traversal) {
        final List<Step> temp = new ArrayList<>();
        Step currentStep = TraversalHelper.getStart(traversal);
        while (!(currentStep instanceof EmptyStep)) {
            temp.add(currentStep);
            currentStep = currentStep.getNextStep();
        }
        return temp.toString();
    }
View Full Code Here

                .isPresent();
    }

    public static List<Step> isolateSteps(final Step<?, ?> from, final Step<?, ?> to) {
        final List<Step> steps = new ArrayList<>();
        Step step = from.getNextStep();
        while (step != to && !(step instanceof EmptyStep)) {
            steps.add(step);
            step = step.getNextStep();
        }
        if (step instanceof EmptyStep)
            steps.clear();
        return steps;
    }
View Full Code Here

    }

    @Override
    public void loadState(final Configuration configuration) {
        final Step step = TraversalHelper.getEnd(TraversalVertexProgram.getTraversalSupplier(configuration).get());
        this.comparator = Optional.ofNullable(step instanceof Comparing ? GraphComputerHelper.chainComparators(((Comparing) step).getComparators()) : null);
        this.reducer = Optional.ofNullable(step instanceof Reducing ? ((Reducing) step).getReducer() : null);
    }
View Full Code Here

        int counter = 0;
        for (final UntilStep untilStep : TraversalHelper.getStepsOfClass(UntilStep.class, traversal)) {
            final IdentityStep leftEndStep = new IdentityStep(traversal);
            leftEndStep.setLabel(UNTIL_PREFIX + counter++);
            TraversalHelper.insertBeforeStep(leftEndStep, untilStep, traversal);
            final Step rightEndStep = TraversalHelper.getStep(untilStep.getBreakLabel(), traversal);
            final String rightEndLabel = rightEndStep.getLabel();

            final JumpStep leftEndJumpStep = untilStep.createLeftJumpStep(traversal, rightEndLabel);
            leftEndJumpStep.setLabel(untilStep.getLabel());
            leftEndJumpStep.doWhile = false;
            TraversalHelper.removeStep(untilStep, traversal);
            TraversalHelper.insertAfterStep(leftEndJumpStep, leftEndStep, traversal);

            final JumpStep rightEndJumpStep = untilStep.createRightJumpStep(traversal, leftEndStep.getLabel());
            //new JumpStep(traversal, leftEndStep.getLabel());
            rightEndJumpStep.setLabel(rightEndLabel);
            rightEndStep.setLabel(Graph.System.system(UUID.randomUUID().toString()));
            TraversalHelper.insertAfterStep(rightEndJumpStep, rightEndStep, traversal);
        }
    }
View Full Code Here

    }

    @Override
    public void apply(final Traversal<?, ?> traversal, final TraversalEngine engine) {
        TraversalHelper.getStepsOfClass(LocalRangeStep.class, traversal).forEach(localRangeStep -> {
            Step previousStep = localRangeStep.getPreviousStep();
            while (!previousStep.equals(EmptyStep.instance()) && !(previousStep instanceof PropertiesStep) && !(previousStep instanceof VertexStep)) {
                previousStep = previousStep.getPreviousStep();
                // TODO: check for not filtering/sideEffect steps and throw an exception?
            }
            if (previousStep instanceof VertexStep) {
                VertexStep vertexStep = (VertexStep) previousStep;
                if (vertexStep.getReturnClass().equals(Edge.class)) {
View Full Code Here

        this.memory = result.memory();
        this.attachElements = attachElements;
        this.memory.keys().forEach(key -> traversal.sideEffects().set(key, this.memory.get(key)));
        this.computerTraversal = traversalVertexProgram.getTraversal();

        final Step endStep = TraversalHelper.getEnd(this.computerTraversal);
        this.traversers = endStep instanceof SideEffectCapStep ?
                new SingleIterator<>(new SimpleTraverser<>((S) this.memory.get(((SideEffectCapStep) endStep).getSideEffectKey()), this.traversal.sideEffects())) :
                (Iterator<Traverser.Admin<S>>) this.memory.get(TraverserMapReduce.TRAVERSERS);

    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.process.Step

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.