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


Java TraversalHelper.getStepsOfAssignableClass方法代码示例

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


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

示例1: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (!traversal.getStrategies().toList().contains(ComputerVerificationStrategy.instance())) {
        if (!TraversalHelper.getStepsOfAssignableClass(VertexComputing.class, traversal).isEmpty())
            throw new VerificationException("VertexComputing steps must be executed with a GraphComputer: " + TraversalHelper.getStepsOfAssignableClass(VertexComputing.class, traversal), traversal);
    }

    traversal.getSteps().forEach(step -> {
        if (step instanceof ReducingBarrierStep && step.getTraversal().getParent() instanceof RepeatStep && step.getTraversal().getParent().getGlobalChildren().get(0).getSteps().contains(step))
            throw new VerificationException("The parent of a reducing barrier can not be repeat()-step: " + step, traversal);
    });

    // The ProfileSideEffectStep must be the last step or the 2nd last step when accompanied by the cap step.
    if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class, traversal) &&
            !(traversal.asAdmin().getEndStep() instanceof ProfileSideEffectStep) &&
            !(traversal.asAdmin().getEndStep() instanceof SideEffectCapStep && traversal.asAdmin().getEndStep().getPreviousStep() instanceof ProfileSideEffectStep)) {
        throw new VerificationException("When specified, the profile()-Step must be the last step or followed only by the cap()-step.", traversal);
    }

    if (TraversalHelper.getStepsOfClass(ProfileSideEffectStep.class, traversal).size() > 1) {
        throw new VerificationException("The profile()-Step cannot be specified multiple times.", traversal);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:24,代码来源:StandardVerificationStrategy.java

示例2: apply

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

    // Retrieve all graph (`V()`) steps - this is the step the strategy should replace
    List<GraphStep> graphSteps = TraversalHelper.getStepsOfAssignableClass(GraphStep.class, traversal);

    for (GraphStep graphStep : graphSteps) {
        // For each graph step, confirm it follows this pattern:
        // `V().filter(__.properties(a).where(P.eq(b)))`

        if (!(graphStep.getNextStep() instanceof TraversalFilterStep)) continue;
        TraversalFilterStep<Vertex> filterStep = (TraversalFilterStep<Vertex>) graphStep.getNextStep();

        // Retrieve the filter steps e.g. `__.properties(a).where(P.eq(b))`
        List<Step> steps = stepsFromFilterStep(filterStep);

        if (steps.size() < 2) continue;
        Step propertiesStep = steps.get(0); // This is `properties(a)`
        Step whereStep = steps.get(1);      // This is `filter(__.where(P.eq(b)))`

        // Get the property key `a`
        if (!(propertiesStep instanceof PropertiesStep)) continue;
        Optional<String> propertyKey = propertyFromPropertiesStep((PropertiesStep<Vertex>) propertiesStep);
        if (!propertyKey.isPresent()) continue;

        // Get the step label `b`
        if (!(whereStep instanceof WherePredicateStep)) continue;
        Optional<String> label = labelFromWhereEqPredicate((WherePredicateStep<Vertex>) whereStep);
        if (!label.isPresent()) continue;

        executeStrategy(traversal, graphStep, filterStep, propertyKey.get(), label.get());
    }
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:34,代码来源:JanusPreviousPropertyStepStrategy.java

示例3: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (!traversal.getStrategies().toList().contains(ComputerFinalizationStrategy.instance()) &&
            !traversal.getStrategies().toList().contains(ComputerVerificationStrategy.instance())) {
        if (!TraversalHelper.getStepsOfAssignableClass(VertexComputing.class, traversal).isEmpty())
            throw new VerificationException("VertexComputing steps must be executed with a GraphComputer: " + TraversalHelper.getStepsOfAssignableClass(VertexComputing.class, traversal), traversal);
    }

    for (final Step<?, ?> step : traversal.getSteps()) {
        for (String label : new HashSet<>(step.getLabels())) {
            if (Graph.Hidden.isHidden(label))
                step.removeLabel(label);
        }
        if (step instanceof ReducingBarrierStep && step.getTraversal().getParent() instanceof RepeatStep && step.getTraversal().getParent().getGlobalChildren().get(0).getSteps().contains(step))
            throw new VerificationException("The parent of a reducing barrier can not be repeat()-step: " + step, traversal);
    }

    // The ProfileSideEffectStep must be the last step, 2nd last step when accompanied by the cap step,
    // or 3rd to last when the traversal ends with a RequirementsStep.
    final Step<?, ?> endStep = traversal.asAdmin().getEndStep();
    if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class, traversal) &&
            !(endStep instanceof ProfileSideEffectStep ||
                    (endStep instanceof SideEffectCapStep && endStep.getPreviousStep() instanceof ProfileSideEffectStep) ||
                    (endStep instanceof RequirementsStep && (
                            endStep.getPreviousStep() instanceof SideEffectCapStep ||
                                    endStep.getPreviousStep() instanceof ProfileSideEffectStep)))) {
        throw new VerificationException("When specified, the profile()-Step must be the last step or followed only by the cap()-step and/or requirements step.", traversal);
    }

    if (TraversalHelper.getStepsOfClass(ProfileSideEffectStep.class, traversal).size() > 1) {
        throw new VerificationException("The profile()-Step cannot be specified multiple times.", traversal);
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:34,代码来源:StandardVerificationStrategy.java

示例4: apply

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

    if (vertexCriterion != null) {
        final List<Step> vertexStepsToInsertFilterAfter = new ArrayList<>();
        vertexStepsToInsertFilterAfter.addAll(TraversalHelper.getStepsOfAssignableClass(EdgeOtherVertexStep.class, traversal));
        vertexStepsToInsertFilterAfter.addAll(TraversalHelper.getStepsOfAssignableClass(EdgeVertexStep.class, traversal));
        vertexStepsToInsertFilterAfter.addAll(TraversalHelper.getStepsOfAssignableClass(AddVertexStep.class, traversal));
        vertexStepsToInsertFilterAfter.addAll(TraversalHelper.getStepsOfAssignableClass(AddVertexStartStep.class, traversal));
        vertexStepsToInsertFilterAfter.addAll(graphSteps.stream().filter(GraphStep::returnsVertex).collect(Collectors.toList()));

        applyCriterion(vertexStepsToInsertFilterAfter, traversal, vertexCriterion.asAdmin());
    }

    if (edgeCriterion != null) {
        final List<Step> edgeStepsToInsertFilterAfter = new ArrayList<>();
        edgeStepsToInsertFilterAfter.addAll(TraversalHelper.getStepsOfAssignableClass(AddEdgeStep.class, traversal));
        edgeStepsToInsertFilterAfter.addAll(graphSteps.stream().filter(GraphStep::returnsEdge).collect(Collectors.toList()));
        edgeStepsToInsertFilterAfter.addAll(vertexSteps.stream().filter(VertexStep::returnsEdge).collect(Collectors.toList()));

        applyCriterion(edgeStepsToInsertFilterAfter, traversal, edgeCriterion.asAdmin());
    }

    // explode g.V().out() to g.V().outE().inV() only if there is an edge predicate otherwise
    vertexSteps.stream().filter(VertexStep::returnsVertex).forEach(s -> {
        if (null == edgeCriterion)
            TraversalHelper.insertAfterStep(new TraversalFilterStep<>(traversal, vertexCriterion.asAdmin().clone()), s, traversal);
        else {
            final VertexStep someEStep = new VertexStep(traversal, Edge.class, s.getDirection(), s.getEdgeLabels());
            final Step someVStep = (s.getDirection() == Direction.BOTH) ?
                    new EdgeOtherVertexStep(traversal) : new EdgeVertexStep(traversal, s.getDirection().opposite());

            // if s was labelled then propagate those labels to the new step that will return the vertex
            transferLabels(s, someVStep);

            TraversalHelper.replaceStep(s, someEStep, traversal);
            TraversalHelper.insertAfterStep(someVStep, someEStep, traversal);
            TraversalHelper.insertAfterStep(new TraversalFilterStep<>(traversal, edgeCriterion.asAdmin().clone()), someEStep, traversal);

            if (vertexCriterion != null)
                TraversalHelper.insertAfterStep(new TraversalFilterStep<>(traversal, vertexCriterion.asAdmin().clone()), someVStep, traversal);
        }
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:47,代码来源:SubgraphStrategy.java


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