当前位置: 首页>>代码示例>>Java>>正文


Java TraversalHelper.onGraphComputer方法代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper.onGraphComputer方法的典型用法代码示例。如果您正苦于以下问题:Java TraversalHelper.onGraphComputer方法的具体用法?Java TraversalHelper.onGraphComputer怎么用?Java TraversalHelper.onGraphComputer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper的用法示例。


在下文中一共展示了TraversalHelper.onGraphComputer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (TraversalHelper.onGraphComputer(traversal))
        return;

    for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
        final TinkerGraphStep<?, ?> tinkerGraphStep = new TinkerGraphStep<>(originalGraphStep);
        TraversalHelper.replaceStep(originalGraphStep, tinkerGraphStep, traversal);
        Step<?, ?> currentStep = tinkerGraphStep.getNextStep();
        while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
            if (currentStep instanceof HasStep) {
                for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
                    if (!GraphStep.processHasContainerIds(tinkerGraphStep, hasContainer))
                        tinkerGraphStep.addHasContainer(hasContainer);
                }
                TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
                traversal.removeStep(currentStep);
            }
            currentStep = currentStep.getNextStep();
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:23,代码来源:TinkerGraphStepStrategy.java

示例2: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (!(traversal.getParent() instanceof EmptyStep) || TraversalHelper.onGraphComputer(traversal))
        return;
    final List<Step> steps = traversal.getSteps();
    if (steps.size() < 2 ||
            !(steps.get(0) instanceof GraphStep) ||
            0 != ((GraphStep) steps.get(0)).getIds().length ||
            !(steps.get(steps.size() - 1) instanceof CountGlobalStep))
        return;
    for (int i = 1; i < steps.size() - 1; i++) {
        final Step current = steps.get(i);
        if (!(current instanceof MapStep ||
                current instanceof IdentityStep ||
                current instanceof NoOpBarrierStep ||
                current instanceof CollectingBarrierStep) ||
                (current instanceof TraversalParent &&
                        TraversalHelper.anyStepRecursively(s -> (s instanceof SideEffectStep || s instanceof AggregateStep), (TraversalParent) current)))
            return;
    }
    final Class<? extends Element> elementClass = ((GraphStep<?, ?>) steps.get(0)).getReturnClass();
    TraversalHelper.removeAllSteps(traversal);
    traversal.addStep(new TinkerCountGlobalStep<>(traversal, elementClass));
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerGraphCountStrategy.java

示例3: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (TraversalHelper.onGraphComputer(traversal))
        return;

    TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(originalGraphStep -> {
        final TinkerGraphStep<?, ?> tinkerGraphStep = new TinkerGraphStep<>(originalGraphStep);
        TraversalHelper.replaceStep(originalGraphStep, (Step) tinkerGraphStep, traversal);
        Step<?, ?> currentStep = tinkerGraphStep.getNextStep();
        while (currentStep instanceof HasContainerHolder) {
            ((HasContainerHolder) currentStep).getHasContainers().forEach(hasContainer -> {
                if (!GraphStep.processHasContainerIds(tinkerGraphStep, hasContainer))
                    tinkerGraphStep.addHasContainer(hasContainer);
            });
            currentStep.getLabels().forEach(tinkerGraphStep::addLabel);
            traversal.removeStep(currentStep);
            currentStep = currentStep.getNextStep();
        }
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:TinkerGraphStepStrategy.java

示例4: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(Traversal.Admin<?, ?> traversal) {
    if(TraversalHelper.onGraphComputer(traversal)) return;

    Graph graph = traversal.getGraph().get();
    if(!(graph instanceof UniGraph)) {
        return;
    }

    UniGraph uniGraph = (UniGraph) graph;

    TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(graphStep -> {

        final UniGraphStartStep<?,?> uniGraphStartStep = new UniGraphStartStep<>(graphStep, uniGraph.getControllerManager());
        TraversalHelper.replaceStep(graphStep, (Step) uniGraphStartStep, traversal);
        PredicatesUtil.collectPredicates(uniGraphStartStep, traversal);
    });
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:19,代码来源:UniGraphStartStepStrategy.java

示例5: initializeIfNeeded

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
private void initializeIfNeeded() {
    if (null == this.metrics) {
        this.onGraphComputer = TraversalHelper.onGraphComputer(this.getTraversal());
        this.metrics = new MutableMetrics(this.getPreviousStep().getId(), this.getPreviousStep().toString());
        final Step<?, S> previousStep = this.getPreviousStep();
        if (previousStep instanceof Profiling)
            ((Profiling) previousStep).setMetrics(this.metrics);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:ProfileStep.java

示例6: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (TraversalHelper.onGraphComputer(traversal))
        return;

    for (int i = 0; i < traversal.getSteps().size(); i++) {
        if (traversal.getSteps().get(i) instanceof RepeatStep) {
            final RepeatStep<?> repeatStep = (RepeatStep) traversal.getSteps().get(i);
            if (null == repeatStep.getEmitTraversal() && repeatStep.getUntilTraversal() instanceof LoopTraversal && ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops() > 0) {
                final Traversal.Admin<?, ?> repeatTraversal = repeatStep.getGlobalChildren().get(0);
                final int repeatLength = repeatTraversal.getSteps().size() - 1;
                repeatTraversal.removeStep(repeatLength); // removes the RepeatEndStep
                int insertIndex = i;
                final int loops = (int) ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops();
                for (int j = 0; j < loops; j++) {
                    TraversalHelper.insertTraversal(insertIndex, repeatTraversal.clone(), traversal);
                    insertIndex = insertIndex + repeatLength;
                    if (j != (loops - 1) || !(traversal.getSteps().get(insertIndex).getNextStep() instanceof Barrier)) // only add a final NoOpBarrier is subsequent step is not a barrier
                        traversal.addStep(++insertIndex, new NoOpBarrierStep<>(traversal, 5000));
                }
                // label last step if repeat() was labeled
                if (!repeatStep.getLabels().isEmpty()) {
                    final Step<?, ?> lastStep = traversal.getSteps().get(insertIndex);
                    repeatStep.getLabels().forEach(lastStep::addLabel);
                }

                traversal.removeStep(i); // remove the RepeatStep
            }
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:32,代码来源:RepeatUnrollStrategy.java

示例7: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(Traversal.Admin<?, ?> traversal) {
    if (TraversalHelper.onGraphComputer(traversal)) return;

    Graph graph = traversal.getGraph().get();
    if (!(graph instanceof UniGraph)) {
        return;
    }

    UniGraph uniGraph = (UniGraph) graph;

    TraversalHelper.getStepsOfClass(RepeatStep.class, traversal).forEach(repeatStep -> {
        if (TraversalHelper.hasStepOfClass(UnionStep.class, (Traversal.Admin) repeatStep.getGlobalChildren().get(0))) {
            return;
        }
        UniGraphRepeatStep uniGraphRepeatStep = new UniGraphRepeatStep(repeatStep, traversal.asAdmin(), uniGraph);
        if (repeatStep.getUntilTraversal() != null && TraversalHelper.getFirstStepOfAssignableClass(ReducingBarrierStep.class, repeatStep.getUntilTraversal()).isPresent())
            return;
        Traversal.Admin<?, ?> repeatTraversal = uniGraphRepeatStep.getRepeatTraversal();
        TraversalHelper.replaceStep(repeatStep, uniGraphRepeatStep, traversal);
        TraversalHelper.getStepsOfClass(RepeatStep.RepeatEndStep.class, repeatTraversal).forEach(repeatEndStep -> {
            UniGraphRepeatStep.RepeatEndStep uniGraphRepeatEndStep = new UniGraphRepeatStep.RepeatEndStep(repeatTraversal, uniGraphRepeatStep);
            TraversalHelper.replaceStep(repeatEndStep, uniGraphRepeatEndStep, repeatTraversal);
        });
    });

}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:28,代码来源:UniGraphRepeatStepStrategy.java

示例8: initializeIfNeeded

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
private void initializeIfNeeded() {
    if (null == this.metrics) {
        this.onGraphComputer = TraversalHelper.onGraphComputer(this.getTraversal());
        this.metrics = new MutableMetrics(this.getPreviousStep().getId(), this.getPreviousStep().toString());
        final Step<?, S> previousStep = this.getPreviousStep();

        // give metrics to the step being profiled so that it can add additional data to the metrics like
        // annotations
        if (previousStep instanceof Profiling)
            ((Profiling) previousStep).setMetrics(this.metrics);
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:13,代码来源:ProfileStep.java

示例9: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (TraversalHelper.onGraphComputer(traversal))
        return;

    for (int i = 0; i < traversal.getSteps().size(); i++) {
        if (traversal.getSteps().get(i) instanceof RepeatStep) {
            final RepeatStep<?> repeatStep = (RepeatStep) traversal.getSteps().get(i);
            if (null == repeatStep.getEmitTraversal() && null != repeatStep.getRepeatTraversal() &&
                    repeatStep.getUntilTraversal() instanceof LoopTraversal && ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops() > 0 &&
                    !TraversalHelper.hasStepOfAssignableClassRecursively(Scope.global, DedupGlobalStep.class, repeatStep.getRepeatTraversal()) &&
                    !TraversalHelper.hasStepOfAssignableClassRecursively(INVALIDATING_STEPS, repeatStep.getRepeatTraversal())) {
                final Traversal.Admin<?, ?> repeatTraversal = repeatStep.getGlobalChildren().get(0);
                repeatTraversal.removeStep(repeatTraversal.getSteps().size() - 1); // removes the RepeatEndStep
                TraversalHelper.applySingleLevelStrategies(traversal, repeatTraversal, RepeatUnrollStrategy.class);
                final int repeatLength = repeatTraversal.getSteps().size();
                int insertIndex = i;
                final int loops = (int) ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops();
                for (int j = 0; j < loops; j++) {
                    TraversalHelper.insertTraversal(insertIndex, repeatTraversal.clone(), traversal);
                    insertIndex = insertIndex + repeatLength;
                    if (j != (loops - 1) || !(traversal.getSteps().get(insertIndex).getNextStep() instanceof Barrier)) // only add a final NoOpBarrier is subsequent step is not a barrier
                        traversal.addStep(++insertIndex, new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE));
                }
                // label last step if repeat() was labeled
                if (!repeatStep.getLabels().isEmpty())
                    TraversalHelper.copyLabels(repeatStep, traversal.getSteps().get(insertIndex), false);
                traversal.removeStep(i); // remove the RepeatStep
            }
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:33,代码来源:RepeatUnrollStrategy.java

示例10: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (TraversalHelper.onGraphComputer(traversal) ||
            traversal.getTraverserRequirements().contains(TraverserRequirement.PATH) ||
            (IS_TESTING && ((TraversalHelper.hasStepOfAssignableClass(ProfileStep.class, TraversalHelper.getRootTraversal(traversal)) ||
                    TraversalHelper.hasStepOfAssignableClass(ProfileSideEffectStep.class, TraversalHelper.getRootTraversal(traversal)))))) // necessary cause ProfileTest analyzes counts
        return;

    boolean foundFlatMap = false;
    boolean labeledPath = false;
    for (int i = 0; i < traversal.getSteps().size(); i++) {
        final Step<?, ?> step = traversal.getSteps().get(i);

        if (step instanceof PathProcessor) {
            final Set<String> keepLabels = ((PathProcessor) step).getKeepLabels();
            if (null != keepLabels && keepLabels.isEmpty()) // if no more path data, then start barrier'ing again
                labeledPath = false;
        }
        if (step instanceof FlatMapStep &&
                !(step instanceof VertexStep && ((VertexStep) step).returnsEdge()) ||
                (step instanceof GraphStep &&
                        (i > 0 || ((GraphStep) step).getIds().length >= BIG_START_SIZE ||
                                (((GraphStep) step).getIds().length == 0 && !(step.getNextStep() instanceof HasStep))))) {
            if (foundFlatMap && !labeledPath &&
                    !(step.getNextStep() instanceof Barrier) &&
                    !(step.getNextStep() instanceof NoneStep) &&
                    !(step.getNextStep() instanceof EmptyStep)) {
                final Step noOpBarrierStep = new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE);
                TraversalHelper.copyLabels(step, noOpBarrierStep, true);
                TraversalHelper.insertAfterStep(noOpBarrierStep, step, traversal);
            } else
                foundFlatMap = true;
        }
        if (!step.getLabels().isEmpty())
            labeledPath = true;

    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:39,代码来源:LazyBarrierStrategy.java

示例11: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (!TraversalHelper.onGraphComputer(traversal))
        return;

    if (traversal.getParent() instanceof TraversalVertexProgramStep) {
        if (TraversalHelper.getStepsOfAssignableClassRecursively(GraphStep.class, traversal).size() > 1)
            throw new VerificationException("Mid-traversal V()/E() is currently not supported on GraphComputer", traversal);
        if (TraversalHelper.hasStepOfAssignableClassRecursively(ProfileStep.class, traversal) && TraversalHelper.getStepsOfAssignableClass(VertexProgramStep.class, TraversalHelper.getRootTraversal(traversal)).size() > 1)
            throw new VerificationException("Profiling a multi-VertexProgramStep traversal is currently not supported on GraphComputer", traversal);
    }

    // this is a problem because sideEffect.merge() is transient on the OLAP reduction
    if (TraversalHelper.getRootTraversal(traversal).getTraverserRequirements().contains(TraverserRequirement.ONE_BULK))
        throw new VerificationException("One bulk is currently not supported on GraphComputer: " + traversal, traversal);

    // you can not traverse past the local star graph with localChildren (e.g. by()-modulators).
    if (!TraversalHelper.isGlobalChild(traversal) && !TraversalHelper.isLocalStarGraph(traversal))
        throw new VerificationException("Local traversals may not traverse past the local star-graph on GraphComputer: " + traversal, traversal);

    for (final Step<?, ?> step : traversal.getSteps()) {
        if (step instanceof PathProcessor && ((PathProcessor) step).getMaxRequirement() != PathProcessor.ElementRequirement.ID)
            throw new VerificationException("It is not possible to access more than a path element's id on GraphComputer: " + step + " requires " + ((PathProcessor) step).getMaxRequirement(), traversal);

        if (UNSUPPORTED_STEPS.stream().filter(c -> c.isAssignableFrom(step.getClass())).findFirst().isPresent())
            throw new VerificationException("The following step is currently not supported on GraphComputer: " + step, traversal);
    }

    Step<?, ?> nextParentStep = traversal.getParent().asStep();
    while (!(nextParentStep instanceof EmptyStep)) {
        if (nextParentStep instanceof PathProcessor && ((PathProcessor) nextParentStep).getMaxRequirement() != PathProcessor.ElementRequirement.ID)
            throw new VerificationException("The following path processor step requires more than the element id on GraphComputer: " + nextParentStep + " requires " + ((PathProcessor) nextParentStep).getMaxRequirement(), traversal);
        nextParentStep = nextParentStep.getNextStep();
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:36,代码来源:ComputerVerificationStrategy.java

示例12: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(Traversal.Admin<?, ?> traversal) {
    if (!TraversalHelper.onGraphComputer(traversal) || !TraversalHelper.isGlobalChild(traversal))
        return;

    for (final Step<?, ?> step : traversal.getSteps()) {
        if (step instanceof GraphComputing)
            ((GraphComputing) step).onGraphComputer();
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:11,代码来源:ComputerFinalizationStrategy.java

示例13: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {

    if (!TraversalHelper.onGraphComputer(traversal))
        return;

    final boolean globalChild = TraversalHelper.isGlobalChild(traversal);

    if (traversal.getParent() instanceof TraversalVertexProgramStep) {
        if (TraversalHelper.getStepsOfAssignableClassRecursively(GraphStep.class, traversal).size() > 1)
            throw new VerificationException("Mid-traversal V()/E() is currently not supported on GraphComputer", traversal);
        if (TraversalHelper.hasStepOfAssignableClassRecursively(ProfileStep.class, traversal) && TraversalHelper.getStepsOfAssignableClass(VertexProgramStep.class, TraversalHelper.getRootTraversal(traversal)).size() > 1)
            throw new VerificationException("Profiling a multi-VertexProgramStep traversal is currently not supported on GraphComputer", traversal);
    }

    for (final Step<?, ?> step : traversal.getSteps()) {

        // only global children are graph computing
        if (globalChild && step instanceof GraphComputing)
            ((GraphComputing) step).onGraphComputer();

        // you can not traverse past the local star graph with localChildren (e.g. by()-modulators).
        if (step instanceof TraversalParent) {
            final Optional<Traversal.Admin<Object, Object>> traversalOptional = ((TraversalParent) step).getLocalChildren().stream()
                    .filter(t -> !TraversalHelper.isLocalStarGraph(t.asAdmin()))
                    .findAny();
            if (traversalOptional.isPresent())
                throw new VerificationException("Local traversals may not traverse past the local star-graph on GraphComputer: " + traversalOptional.get(), traversal);
        }

        // collecting barriers and dedup global use can only operate on the element and its properties (no incidences)
        if (step instanceof CollectingBarrierStep && step instanceof TraversalParent) {
            if (((TraversalParent) step).getLocalChildren().stream().filter(t -> !TraversalHelper.isLocalProperties(t)).findAny().isPresent())
                throw new VerificationException("The following barrier step can not process the incident edges of a vertex on GraphComputer: " + step, traversal);
        }

        // this is a problem because sideEffect.merge() is transient on the OLAP reduction
        if (TraversalHelper.getRootTraversal(traversal).getTraverserRequirements().contains(TraverserRequirement.ONE_BULK))
            throw new VerificationException("One bulk is currently not supported on GraphComputer: " + step, traversal);

        if (step instanceof PathProcessor && ((PathProcessor) step).getMaxRequirement() != PathProcessor.ElementRequirement.ID)
            throw new VerificationException("It is not possible to access more than a path element's id on GraphComputer: " + step + " requires " + ((PathProcessor) step).getMaxRequirement(), traversal);

        if (UNSUPPORTED_STEPS.stream().filter(c -> c.isAssignableFrom(step.getClass())).findFirst().isPresent())
            throw new VerificationException("The following step is currently not supported on GraphComputer: " + step, traversal);

    }

    Step<?, ?> nextParentStep = traversal.getParent().asStep();
    while (!(nextParentStep instanceof EmptyStep)) {
        if (nextParentStep instanceof PathProcessor && ((PathProcessor) nextParentStep).getMaxRequirement() != PathProcessor.ElementRequirement.ID)
            throw new VerificationException("The following path processor step requires more than the element id on GraphComputer: " + nextParentStep + " requires " + ((PathProcessor) nextParentStep).getMaxRequirement(), traversal);
        nextParentStep = nextParentStep.getNextStep();
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:56,代码来源:ComputerVerificationStrategy.java


注:本文中的org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper.onGraphComputer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。