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


Java ConnectiveStep类代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep的典型用法代码示例。如果您正苦于以下问题:Java ConnectiveStep类的具体用法?Java ConnectiveStep怎么用?Java ConnectiveStep使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectiveStep类属于org.apache.tinkerpop.gremlin.process.traversal.step.filter包,在下文中一共展示了ConnectiveStep类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasMatched

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private boolean hasMatched(final ConnectiveStep.Connective connective, final Traverser.Admin<S> traverser) {
    int counter = 0;
    boolean matched = false;
    for (final Traversal.Admin<Object, Object> matchTraversal : this.matchTraversals) {
        if (traverser.getTags().contains(matchTraversal.getStartStep().getId())) {
            if (connective == ConnectiveStep.Connective.OR) {
                matched = true;
                break;
            }
            counter++;
        }
    }
    if (!matched)
        matched = this.matchTraversals.size() == counter;
    if (matched && this.dedupLabels != null) {
        final Path path = traverser.path();
        final List<Object> objects = new ArrayList<>(this.dedupLabels.size());
        for (final String label : this.dedupLabels) {
            objects.add(path.get(Pop.last, label));
        }
        this.dedups.add(objects);
    }
    return matched;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:MatchStep.java

示例2: apply

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    final List<Step> steps = traversal.getSteps();
    final int size = steps.size() - 1;
    Step prev = null;
    for (int i = 0; i <= size; i++) {
        final Step curr = steps.get(i);
        if (i == size && isOptimizable(curr)) {
            final TraversalParent parent = curr.getTraversal().getParent();
            if (parent instanceof NotStep || parent instanceof TraversalFilterStep || parent instanceof WhereTraversalStep || parent instanceof ConnectiveStep) {
                optimizeStep(traversal, curr);
            }
        } else if (isOptimizable(prev)) {
            if (curr instanceof CountGlobalStep) {
                optimizeStep(traversal, prev);
            }
        }
        if (!(curr instanceof RangeGlobalStep)) {
            prev = curr;
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:AdjacentToIncidentStrategy.java

示例3: testPreCompilationOfOr

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Test
public void testPreCompilationOfOr() {
    final List<Traversal.Admin<?, ?>> traversals = Arrays.asList(
            __.match(as("a").out().as("b"), or(as("c").path().as("d"), as("e").coin(0.5).as("f"))).asAdmin(),
            __.match(as("a").out().as("b"), as("c").path().as("d").or().as("e").coin(0.5).as("f")).asAdmin());
    assertEquals(1, new HashSet<>(traversals).size()); // the two patterns should pre-compile to the same traversal
    traversals.forEach(traversal -> {
        final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
        assertEquals(2, matchStep.getGlobalChildren().size());
        Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
        assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
        assertEquals(VertexStep.class, pattern.getStartStep().getNextStep().getClass());
        assertEquals("b", ((MatchStep.MatchEndStep) pattern.getEndStep()).getMatchKey().get());
        //
        pattern = matchStep.getGlobalChildren().get(1);
        assertEquals(MatchStep.class, pattern.getStartStep().getClass());
        assertEquals(ConnectiveStep.Connective.OR, ((MatchStep<?, ?>) pattern.getStartStep()).getConnective());
        assertEquals("c", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep()).getSelectKey().get());
        assertEquals(PathStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep().getNextStep().getClass());
        assertEquals("d", ((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getEndStep()).getMatchKey().get());
        assertEquals("e", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep()).getSelectKey().get());
        assertEquals(CoinStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep().getNextStep().getClass());
        assertEquals("f", ((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getEndStep()).getMatchKey().get());
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:MatchStepTest.java

示例4: testPreCompilationOfAnd

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Test
public void testPreCompilationOfAnd() {
    final List<Traversal.Admin<?, ?>> traversals = Arrays.asList(
            __.match(as("a").out().as("b"), and(as("c").path().as("d"), as("e").barrier())).asAdmin(),
            __.match(as("a").out().as("b"), as("c").path().as("d").and().as("e").barrier()).asAdmin());
    assertEquals(1, new HashSet<>(traversals).size());   // the two patterns should pre-compile to the same traversal
    traversals.forEach(traversal -> {
        final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
        assertEquals(2, matchStep.getGlobalChildren().size());
        Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
        assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
        assertEquals(VertexStep.class, pattern.getStartStep().getNextStep().getClass());
        assertEquals("b", ((MatchStep.MatchEndStep) pattern.getEndStep()).getMatchKey().get());
        //
        pattern = matchStep.getGlobalChildren().get(1);
        assertEquals(MatchStep.class, pattern.getStartStep().getClass());
        assertEquals(ConnectiveStep.Connective.AND, ((MatchStep<?, ?>) pattern.getStartStep()).getConnective());
        assertEquals("c", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep()).getSelectKey().get());
        assertEquals(PathStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getStartStep().getNextStep().getClass());
        assertEquals("d", ((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(0).getEndStep()).getMatchKey().get());
        assertEquals("e", ((MatchStep.MatchStartStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep()).getSelectKey().get());
        assertEquals(NoOpBarrierStep.class, ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getStartStep().getNextStep().getClass());
        assertFalse(((MatchStep.MatchEndStep) ((MatchStep<?, ?>) pattern.getStartStep()).getGlobalChildren().get(1).getEndStep()).getMatchKey().isPresent());
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:MatchStepTest.java

示例5: MatchStep

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
public MatchStep(final Traversal.Admin traversal, final ConnectiveStep.Connective connective, final Traversal... matchTraversals) {
    super(traversal);
    this.connective = connective;
    this.matchTraversals = (List) Stream.of(matchTraversals).map(Traversal::asAdmin).collect(Collectors.toList());
    this.matchTraversals.forEach(this::configureStartAndEndSteps); // recursively convert to MatchStep, MatchStartStep, or MatchEndStep
    this.matchTraversals.forEach(this::integrateChild);
    this.computedStartLabel = Helper.computeStartLabel(this.matchTraversals);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:MatchStep.java

示例6: pullOutVariableStartStepToParent

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private Set<String> pullOutVariableStartStepToParent(final Set<String> selectKeys, final Traversal.Admin<?, ?> traversal, boolean testRun) {
    final Step<?, ?> startStep = traversal.getStartStep();
    if (startStep instanceof WhereTraversalStep.WhereStartStep && !((WhereTraversalStep.WhereStartStep) startStep).getScopeKeys().isEmpty()) {
        selectKeys.addAll(((WhereTraversalStep.WhereStartStep<?>) startStep).getScopeKeys());
        if (!testRun) ((WhereTraversalStep.WhereStartStep) startStep).removeScopeKey();
    } else if (startStep instanceof ConnectiveStep || startStep instanceof NotStep) {
        ((TraversalParent) startStep).getLocalChildren().forEach(child -> this.pullOutVariableStartStepToParent(selectKeys, child, testRun));
    }
    return selectKeys;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:MatchStep.java

示例7: getVariableLocations

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static Set<Scoping.Variable> getVariableLocations(final Set<Scoping.Variable> variables, final Traversal.Admin<?, ?> traversal) {
    if (variables.size() == 2) return variables;    // has both START and END so no need to compute further
    final Step<?, ?> startStep = traversal.getStartStep();
    if (StartStep.isVariableStartStep(startStep))
        variables.add(Scoping.Variable.START);
    else if (startStep instanceof WherePredicateStep) {
        if (((WherePredicateStep) startStep).getStartKey().isPresent())
            variables.add(Scoping.Variable.START);
    } else if (startStep instanceof WhereTraversalStep.WhereStartStep) {
        if (!((WhereTraversalStep.WhereStartStep) startStep).getScopeKeys().isEmpty())
            variables.add(Scoping.Variable.START);
    } else if (startStep instanceof MatchStep.MatchStartStep) {
        if (((MatchStep.MatchStartStep) startStep).getSelectKey().isPresent())
            variables.add(Scoping.Variable.START);
    } else if (startStep instanceof MatchStep) {
        ((MatchStep<?, ?>) startStep).getGlobalChildren().forEach(child -> TraversalHelper.getVariableLocations(variables, child));
    } else if (startStep instanceof ConnectiveStep || startStep instanceof NotStep || startStep instanceof WhereTraversalStep)
        ((TraversalParent) startStep).getLocalChildren().forEach(child -> TraversalHelper.getVariableLocations(variables, child));
    ///
    final Step<?, ?> endStep = traversal.getEndStep();
    if (endStep instanceof WherePredicateStep) {
        if (((WherePredicateStep) endStep).getStartKey().isPresent())
            variables.add(Scoping.Variable.END);
    } else if (endStep instanceof WhereTraversalStep.WhereEndStep) {
        if (!((WhereTraversalStep.WhereEndStep) endStep).getScopeKeys().isEmpty())
            variables.add(Scoping.Variable.END);
    } else if (endStep instanceof MatchStep.MatchEndStep) {
        if (((MatchStep.MatchEndStep) endStep).getMatchKey().isPresent())
            variables.add(Scoping.Variable.END);
    } else if (!endStep.getLabels().isEmpty())
        variables.add(Scoping.Variable.END);
    ///
    return variables;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:35,代码来源:TraversalHelper.java

示例8: processConjunctionMarker

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static void processConjunctionMarker(final Class<? extends ConnectiveStep> markerClass, final Traversal.Admin<?, ?> traversal) {

        TraversalHelper.getStepsOfClass(markerClass, traversal).stream()
                .filter(conjunctionStep -> conjunctionStep.getLocalChildren().isEmpty())
                .findFirst().ifPresent(connectiveStep -> {

            Step<?, ?> currentStep = connectiveStep.getNextStep();
            final Traversal.Admin<?, ?> rightTraversal = __.start().asAdmin();
            if (!connectiveStep.getLabels().isEmpty()) {
                final StartStep<?> startStep = new StartStep<>(rightTraversal);
                final Set<String> conjunctionLabels = ((Step<?, ?>) connectiveStep).getLabels();
                conjunctionLabels.forEach(startStep::addLabel);
                conjunctionLabels.forEach(label -> connectiveStep.removeLabel(label));
                rightTraversal.addStep(startStep);
            }
            while (legalCurrentStep(currentStep)) {
                final Step<?, ?> nextStep = currentStep.getNextStep();
                rightTraversal.addStep(currentStep);
                traversal.removeStep(currentStep);
                currentStep = nextStep;
            }
            processConnectiveMarker(rightTraversal);

            currentStep = connectiveStep.getPreviousStep();
            final Traversal.Admin<?, ?> leftTraversal = __.start().asAdmin();
            while (legalCurrentStep(currentStep)) {
                final Step<?, ?> previousStep = currentStep.getPreviousStep();
                leftTraversal.addStep(0, currentStep);
                traversal.removeStep(currentStep);
                currentStep = previousStep;
            }
            processConnectiveMarker(leftTraversal);

            TraversalHelper.replaceStep(connectiveStep,
                    connectiveStep instanceof AndStep ?
                            new AndStep(traversal, leftTraversal, rightTraversal) :
                            new OrStep(traversal, leftTraversal, rightTraversal), traversal);
        });
    }
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:40,代码来源:ConnectiveStrategy.java

示例9: getVariableLocations

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static Set<Scoping.Variable> getVariableLocations(final Set<Scoping.Variable> variables, final Traversal.Admin<?, ?> traversal) {
    if (variables.size() == 2) return variables;    // has both START and END so no need to compute further
    final Step<?, ?> startStep = traversal.getStartStep();
    if (StartStep.isVariableStartStep(startStep))
        variables.add(Scoping.Variable.START);
    else if (startStep instanceof WherePredicateStep) {
        if (((WherePredicateStep) startStep).getStartKey().isPresent())
            variables.add(Scoping.Variable.START);
    } else if (startStep instanceof WhereTraversalStep.WhereStartStep) {
        if (!((WhereTraversalStep.WhereStartStep) startStep).getScopeKeys().isEmpty())
            variables.add(Scoping.Variable.START);
    } else if (startStep instanceof MatchStep.MatchStartStep) {
        if (((MatchStep.MatchStartStep) startStep).getSelectKey().isPresent())
            variables.add(Scoping.Variable.START);
    } else if (startStep instanceof MatchStep) {
        for (final Traversal.Admin<?, ?> global : ((MatchStep<?, ?>) startStep).getGlobalChildren()) {
            TraversalHelper.getVariableLocations(variables, global);
        }
    } else if (startStep instanceof ConnectiveStep || startStep instanceof NotStep || startStep instanceof WhereTraversalStep) {
        for (final Traversal.Admin<?, ?> local : ((TraversalParent) startStep).getLocalChildren()) {
            TraversalHelper.getVariableLocations(variables, local);
        }
    }
    ///
    final Step<?, ?> endStep = traversal.getEndStep();
    if (endStep instanceof WherePredicateStep) {
        if (((WherePredicateStep) endStep).getStartKey().isPresent())
            variables.add(Scoping.Variable.END);
    } else if (endStep instanceof WhereTraversalStep.WhereEndStep) {
        if (!((WhereTraversalStep.WhereEndStep) endStep).getScopeKeys().isEmpty())
            variables.add(Scoping.Variable.END);
    } else if (endStep instanceof MatchStep.MatchEndStep) {
        if (((MatchStep.MatchEndStep) endStep).getMatchKey().isPresent())
            variables.add(Scoping.Variable.END);
    } else if (!endStep.getLabels().isEmpty())
        variables.add(Scoping.Variable.END);
    ///
    return variables;
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:40,代码来源:TraversalHelper.java

示例10: processConjunctionMarker

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static void processConjunctionMarker(final Class<? extends ConnectiveStep> markerClass, final Traversal.Admin<?, ?> traversal) {

        TraversalHelper.getStepsOfClass(markerClass, traversal).stream()
                .filter(conjunctionStep -> conjunctionStep.getLocalChildren().isEmpty())
                .findFirst().ifPresent(connectiveStep -> {

            Step<?, ?> currentStep = connectiveStep.getNextStep();
            final Traversal.Admin<?, ?> rightTraversal = __.start().asAdmin();
            if (!connectiveStep.getLabels().isEmpty()) {
                final StartStep<?> startStep = new StartStep<>(rightTraversal);
                final Set<String> conjunctionLabels = ((Step<?, ?>) connectiveStep).getLabels();
                conjunctionLabels.forEach(startStep::addLabel);
                conjunctionLabels.forEach(label -> connectiveStep.removeLabel(label));
                rightTraversal.addStep(startStep);
            }
            while (legalCurrentStep(currentStep)) {
                final Step<?, ?> nextStep = currentStep.getNextStep();
                rightTraversal.addStep(currentStep);
                traversal.removeStep(currentStep);
                currentStep = nextStep;
            }
            processConnectiveMarker(rightTraversal);

            currentStep = connectiveStep.getPreviousStep();
            final Traversal.Admin<?, ?> leftTraversal = __.start().asAdmin();
            while (legalCurrentStep(currentStep)) {
                final Step<?, ?> previousStep = currentStep.getPreviousStep();
                leftTraversal.addStep(0, currentStep);
                traversal.removeStep(currentStep);
                currentStep = previousStep;
            }
            processConnectiveMarker(leftTraversal);

            if (connectiveStep instanceof AndStep)
                TraversalHelper.replaceStep((Step) connectiveStep, new AndStep(traversal, leftTraversal, rightTraversal), traversal);
            else
                TraversalHelper.replaceStep((Step) connectiveStep, new OrStep(traversal, leftTraversal, rightTraversal), traversal);
        });
    }
 
开发者ID:apache,项目名称:tinkerpop,代码行数:40,代码来源:ConnectiveStrategy.java

示例11: isLocalElement

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
private static boolean isLocalElement(final Step<?, ?> step) {
    return step instanceof PropertiesStep || step instanceof PropertyMapStep ||
            step instanceof IdStep || step instanceof LabelStep || step instanceof SackStep ||
            step instanceof PropertyKeyStep || step instanceof PropertyValueStep ||
            step instanceof TailGlobalStep || step instanceof RangeGlobalStep || step instanceof HasStep ||
            step instanceof ConnectiveStep;
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:8,代码来源:MasterExecutor.java

示例12: from

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
public static TYPE from(ConnectiveStep<?> connectiveStep) {
    if (connectiveStep instanceof AndStep) {
        return AND;
    } else if (connectiveStep instanceof OrStep) {
        return OR;
    } else {
        return NONE;
    }
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:10,代码来源:AndOrHasContainer.java

示例13: getConnective

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
public ConnectiveStep.Connective getConnective() {
    return this.connective;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:4,代码来源:MatchStep.java

示例14: apply

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (TraversalHelper.hasStepOfAssignableClass(ConnectiveStep.class, traversal)) {
        processConnectiveMarker(traversal);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:7,代码来源:ConnectiveStrategy.java

示例15: match

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep; //导入依赖的package包/类
/**
 * Map the {@link Traverser} to a {@link Map} of bindings as specified by the provided match traversals.
 *
 * @param matchTraversals the traversal that maintain variables which must hold for the life of the traverser
 * @param <E2>            the type of the obejcts bound in the variables
 * @return the traversal with an appended {@link MatchStep}.
 */
public default <E2> GraphTraversal<S, Map<String, E2>> match(final Traversal<?, ?>... matchTraversals) {
    return this.asAdmin().addStep(new MatchStep<>(this.asAdmin(), ConnectiveStep.Connective.AND, matchTraversals));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:GraphTraversal.java


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