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


Java TraversalHelper.replaceStep方法代码示例

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


在下文中一共展示了TraversalHelper.replaceStep方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
	for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
		final BitsyGraphStep<?, ?> bitsyGraphStep = new BitsyGraphStep<>(originalGraphStep);
		TraversalHelper.replaceStep(originalGraphStep, bitsyGraphStep, traversal);
		Step<?, ?> currentStep = bitsyGraphStep.getNextStep();
		while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
			if (currentStep instanceof HasStep) {
				for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
					if (!GraphStep.processHasContainerIds(bitsyGraphStep, hasContainer))
						bitsyGraphStep.addHasContainer(hasContainer);
				}
				TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
				traversal.removeStep(currentStep);
			}
			currentStep = currentStep.getNextStep();
		}
	}
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:20,代码来源:BitsyTraversalStrategy.java

示例3: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    for (final VertexStep originalVertexStep : TraversalHelper.getStepsOfClass(VertexStep.class, traversal)) {
        final HBaseVertexStep<?> hbaseVertexStep = new HBaseVertexStep<>(originalVertexStep);
        TraversalHelper.replaceStep(originalVertexStep, hbaseVertexStep, traversal);
        Step<?, ?> currentStep = hbaseVertexStep.getNextStep();
        while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
            if (currentStep instanceof HasStep) {
                for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
                    hbaseVertexStep.addHasContainer(hasContainer);
                }
                TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
                traversal.removeStep(currentStep);
            }
            currentStep = currentStep.getNextStep();
        }
    }
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:20,代码来源:HBaseVertexStepStrategy.java

示例4: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
        final HBaseGraphStep<?, ?> hbaseGraphStep = new HBaseGraphStep<>(originalGraphStep);
        TraversalHelper.replaceStep(originalGraphStep, hbaseGraphStep, traversal);
        Step<?, ?> currentStep = hbaseGraphStep.getNextStep();
        while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
            if (currentStep instanceof HasStep) {
                for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
                    if (!GraphStep.processHasContainerIds(hbaseGraphStep, hasContainer))
                        hbaseGraphStep.addHasContainer(hasContainer);
                }
                TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
                traversal.removeStep(currentStep);
            }
            currentStep = currentStep.getNextStep();
        }
    }
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:21,代码来源:HBaseGraphStepStrategy.java

示例5: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    final Step<?, ?> startStep = traversal.getStartStep();
    // only apply once
    if (startStep instanceof GraphStep && !(startStep instanceof OrientGraphStep)) {
        final GraphStep<?, ?> originalGraphStep = (GraphStep) startStep;
        final OrientGraphStep<?, ?> orientGraphStep = new OrientGraphStep<>(originalGraphStep);
        TraversalHelper.replaceStep(startStep, (Step) orientGraphStep, traversal);

        Step<?, ?> currentStep = orientGraphStep.getNextStep();
        while (currentStep instanceof HasContainerHolder) {
            ((HasContainerHolder) currentStep).getHasContainers().forEach(orientGraphStep::addHasContainer);
            currentStep.getLabels().forEach(orientGraphStep::addLabel);
            traversal.removeStep(currentStep);
            currentStep = currentStep.getNextStep();
        }
    }
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:19,代码来源:OrientGraphStepStrategy.java

示例6: apply

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    for (final GraphStep originalGraphStep : TraversalHelper.getStepsOfClass(GraphStep.class, traversal)) {
        final Neo4jGraphStep<?, ?> neo4jGraphStep = new Neo4jGraphStep<>(originalGraphStep);
        TraversalHelper.replaceStep(originalGraphStep, neo4jGraphStep, traversal);
        Step<?, ?> currentStep = neo4jGraphStep.getNextStep();
        while (currentStep instanceof HasStep || currentStep instanceof NoOpBarrierStep) {
            if (currentStep instanceof HasStep) {
                for (final HasContainer hasContainer : ((HasContainerHolder) currentStep).getHasContainers()) {
                    if (!GraphStep.processHasContainerIds(neo4jGraphStep, hasContainer))
                        neo4jGraphStep.addHasContainer(hasContainer);
                }
                TraversalHelper.copyLabels(currentStep, currentStep.getPreviousStep(), false);
                traversal.removeStep(currentStep);
            }
            currentStep = currentStep.getNextStep();
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:20,代码来源:Neo4jGraphStepStrategy.java

示例7: executeStrategy

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
/**
 * Replace the {@code graphStep} and {@code filterStep} with a new {@link JanusPreviousPropertyStep} in the given
 * {@code traversal}.
 */
private void executeStrategy(
        Traversal.Admin<?, ?> traversal, GraphStep<?, ?> graphStep, TraversalFilterStep<Vertex> filterStep,
        String propertyKey, String label) {

    JanusPreviousPropertyStep newStep = new JanusPreviousPropertyStep(traversal, propertyKey, label);
    traversal.removeStep(filterStep);
    TraversalHelper.replaceStep(graphStep, newStep, traversal);
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:13,代码来源:JanusPreviousPropertyStepStrategy.java

示例8: optimizeSteps

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
/**
 * Optimizes the given edge-emitting step and the vertex-emitting step by replacing them with a single
 * vertex-emitting step.
 *
 * @param traversal the traversal that holds the given steps
 * @param step1     the edge-emitting step to replace
 * @param step2     the vertex-emitting step to replace
 */
private static void optimizeSteps(final Traversal.Admin traversal, final VertexStep step1, final Step step2) {
    final Step newStep = new VertexStep(traversal, Vertex.class, step1.getDirection(), step1.getEdgeLabels());
    for (final String label : (Iterable<String>) step2.getLabels()) {
        newStep.addLabel(label);
    }
    TraversalHelper.replaceStep(step1, newStep, traversal);
    traversal.removeStep(step2);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:IncidentToAdjacentStrategy.java

示例9: shouldReplaceStep

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Test
public void shouldReplaceStep() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    final HasStep hasStep = new HasStep(traversal);
    final IdentityStep identityStep = new IdentityStep(traversal);
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, hasStep);
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    TraversalHelper.replaceStep(hasStep, identityStep, traversal);

    assertEquals(traversal.asAdmin().getSteps().get(1), identityStep);
    assertEquals(3, traversal.asAdmin().getSteps().size());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:TraversalHelperTest.java

示例10: apply

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

    final Step<?, ?> startStep = traversal.getStartStep();
    if (startStep instanceof GraphStep) {
        final GraphStep<?> originalGraphStep = (GraphStep) startStep;
        if (originalGraphStep.getIds() == null || originalGraphStep.getIds().length == 0) {
            //Try to optimize for index calls
            final TitanGraphStep<?> titanGraphStep = new TitanGraphStep<>(originalGraphStep);
            TraversalHelper.replaceStep(startStep, (Step) titanGraphStep, traversal);

            HasStepFolder.foldInHasContainer(titanGraphStep, traversal);
            HasStepFolder.foldInOrder(titanGraphStep, traversal, traversal, titanGraphStep.returnsVertex());
            HasStepFolder.foldInRange(titanGraphStep, traversal);
        } else {
            //Make sure that any provided "start" elements are instantiated in the current transaction
            Object[] ids = originalGraphStep.getIds();
            ElementUtils.verifyArgsMustBeEitherIdorElement(ids);
            if (ids[0] instanceof Element) {
                //GraphStep constructor ensures that the entire array is elements
                final Object[] elementIds = new Object[ids.length];
                for (int i = 0; i < ids.length; i++) {
                    elementIds[i] = ((Element) ids[i]).id();
                }
                originalGraphStep.setIteratorSupplier(() -> (Iterator) (originalGraphStep.returnsVertex() ?
                        originalGraphStep.getTraversal().getGraph().get().vertices(elementIds) :
                        originalGraphStep.getTraversal().getGraph().get().edges(elementIds)));
            }
        }
    }
}
 
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:34,代码来源:TitanGraphStepStrategy.java

示例11: processOrStep

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的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

示例12: shouldSetPreviousStepToEmptyStep

import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; //导入方法依赖的package包/类
@Test
public void shouldSetPreviousStepToEmptyStep() {
    final Traversal.Admin<?, ?> traversal = __.V().out().asAdmin();
    //transform the traversal to __.V().not(out())
    //the VertexStep's previousStep should be the EmptyStep
    Optional<VertexStep> vertexStepOpt = TraversalHelper.getFirstStepOfAssignableClass(VertexStep.class, traversal);
    assertTrue(vertexStepOpt.isPresent());
    Traversal.Admin<?,?> inner = __.start().asAdmin();
    inner.addStep(0, vertexStepOpt.get());
    TraversalHelper.replaceStep(vertexStepOpt.get(), new NotStep<>(__.identity().asAdmin(), inner), traversal);
    List<VertexStep> vertexSteps = TraversalHelper.getStepsOfAssignableClassRecursively(VertexStep.class, traversal);
    assertEquals(1, vertexSteps.size());
    VertexStep vertexStep = vertexSteps.get(0);
    assertTrue("Expected the previousStep to be an EmptyStep, found instead " + vertexStep.getPreviousStep().toString(),vertexStep.getPreviousStep() == EmptyStep.instance());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:16,代码来源:TraversalHelperTest.java


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