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


Java OrStep类代码示例

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


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

示例1: apply

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    boolean changed = true; // recursively walk child traversals trying to inline them into the current traversal line.
    while (changed) {
        changed = false;
        final Iterator<FilterStep> filterStepIterator = TraversalHelper.getStepsOfAssignableClass(FilterStep.class, traversal).iterator();
        while (!changed && filterStepIterator.hasNext()) {
            final FilterStep<?> step = filterStepIterator.next();
            changed = step instanceof HasStep && InlineFilterStrategy.processHasStep((HasStep) step, traversal) ||
                    step instanceof TraversalFilterStep && InlineFilterStrategy.processTraversalFilterStep((TraversalFilterStep) step, traversal) ||
                    step instanceof OrStep && InlineFilterStrategy.processOrStep((OrStep) step, traversal) ||
                    step instanceof AndStep && InlineFilterStrategy.processAndStep((AndStep) step, traversal);
        }
        if (!changed && traversal.getParent() instanceof EmptyStep) {
            final Iterator<MatchStep> matchStepIterator = TraversalHelper.getStepsOfClass(MatchStep.class, traversal).iterator();
            while (!changed && matchStepIterator.hasNext()) {
                if (InlineFilterStrategy.processMatchStep(matchStepIterator.next(), traversal))
                    changed = true;
            }
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:23,代码来源:InlineFilterStrategy.java

示例2: processConjunctionMarker

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的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

示例3: processOrStep

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的package包/类
private static final boolean processOrStep(final OrStep<?> step, final Traversal.Admin<?, ?> traversal) {
    boolean process = true;
    String key = null;
    P predicate = null;
    final List<String> labels = new ArrayList<>();
    for (final Traversal.Admin<?, ?> childTraversal : step.getLocalChildren()) {
        InlineFilterStrategy.instance().apply(childTraversal); // todo: this may be a bad idea, but I can't seem to find a test case to break it
        for (final Step<?, ?> childStep : childTraversal.getSteps()) {
            if (childStep instanceof HasStep) {
                for (final HasContainer hasContainer : ((HasStep<?>) childStep).getHasContainers()) {
                    if (null == key)
                        key = hasContainer.getKey();
                    else if (!hasContainer.getKey().equals(key)) {
                        process = false;
                        break;
                    }
                    predicate = null == predicate ?
                            hasContainer.getPredicate() :
                            predicate.or(hasContainer.getPredicate());
                }
                labels.addAll(childStep.getLabels());
            } else {
                process = false;
                break;
            }
        }
        if (!process)
            break;
    }
    if (process) {
        final HasStep hasStep = new HasStep<>(traversal, new HasContainer(key, predicate));
        TraversalHelper.replaceStep(step, hasStep, traversal);
        TraversalHelper.copyLabels(step, hasStep, false);
        for (final String label : labels) {
            hasStep.addLabel(label);
        }
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:41,代码来源:InlineFilterStrategy.java

示例4: getStepRank

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的package包/类
/**
 * Ranks the given step. Steps with lower ranks can be moved in front of steps with higher ranks. 0 means that
 * the step has no rank and thus is not exchangeable with its neighbors.
 *
 * @param step the step to get a ranking for
 * @return The rank of the given step.
 */
private static int getStepRank(final Step step) {
    final int rank;
    if (!(step instanceof FilterStep || step instanceof OrderGlobalStep))
        return 0;
    else if (step instanceof IsStep || step instanceof ClassFilterStep)
        rank = 1;
    else if (step instanceof HasStep)
        rank = 2;
    else if (step instanceof WherePredicateStep && ((WherePredicateStep) step).getLocalChildren().isEmpty())
        rank = 3;
    else if (step instanceof TraversalFilterStep || step instanceof NotStep)
        rank = 4;
    else if (step instanceof WhereTraversalStep)
        rank = 5;
    else if (step instanceof OrStep)
        rank = 6;
    else if (step instanceof AndStep)
        rank = 7;
    else if (step instanceof WherePredicateStep) // has by()-modulation
        rank = 8;
    else if (step instanceof DedupGlobalStep)
        rank = 9;
    else if (step instanceof OrderGlobalStep)
        rank = 10;
    else
        return 0;
    ////////////
    if (step instanceof TraversalParent)
        return getMaxStepRank((TraversalParent) step, rank);
    else
        return rank;
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:40,代码来源:FilterRankingStrategy.java

示例5: processConjunctionMarker

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的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

示例6: from

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的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

示例7: apply

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    //Only optimize SqlgGraph. StarGraph also passes through here.
    //noinspection OptionalGetWithoutIsPresent
    if (!(traversal.getGraph().get() instanceof SqlgGraph)) {
        return;
    }
    List<OrStep> orSteps = TraversalHelper.getStepsOfAssignableClass(OrStep.class, traversal);
    for (OrStep<S> orStep : orSteps) {

        Collection<Traversal.Admin<S, ?>> orTraversals = orStep.getLocalChildren();

        //reducing barrier steps like count does not work with Sqlg's barrier optimizations
        List<ReducingBarrierStep> reducingBarrierSteps = TraversalHelper.getStepsOfAssignableClassRecursively(ReducingBarrierStep.class, traversal);
        if (!reducingBarrierSteps.isEmpty()) {
            return;
        }

        SqlgOrStepBarrier<S> sqlgOrStepBarrier = new SqlgOrStepBarrier(
                traversal,
                orTraversals
        );
        for (String label : orStep.getLabels()) {
            sqlgOrStepBarrier.addLabel(label);
        }
        TraversalHelper.replaceStep(
                orStep,
                sqlgOrStepBarrier,
                orStep.getTraversal()
        );
    }
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:33,代码来源:SqlgOrStepStepStrategy.java

示例8: or

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的package包/类
public default GraphTraversal<S, E> or(final Traversal<?, ?>... orTraversals) {
    return this.asAdmin().addStep(new OrStep(this.asAdmin(), orTraversals));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:4,代码来源:GraphTraversal.java

示例9: processConnectiveMarker

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的package包/类
private static void processConnectiveMarker(final Traversal.Admin<?, ?> traversal) {
    processConjunctionMarker(OrStep.class, traversal);
    processConjunctionMarker(AndStep.class, traversal);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:ConnectiveStrategy.java

示例10: or

import org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep; //导入依赖的package包/类
/**
 * Ensures that at least one of the provided traversals yield a result.
 *
 * @param orTraversals filter traversals where at least one must be satisfied
 * @return the traversal with an appended {@link OrStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#or-step" target="_blank">Reference Documentation - Or Step</a>
 * @since 3.0.0-incubating
 */
public default GraphTraversal<S, E> or(final Traversal<?, ?>... orTraversals) {
    this.asAdmin().getBytecode().addStep(Symbols.or, orTraversals);
    return this.asAdmin().addStep(new OrStep(this.asAdmin(), orTraversals));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:13,代码来源:GraphTraversal.java


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