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


Java Traversal类代码示例

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


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

示例1: apply

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的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.Traversal; //导入依赖的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: benchmarkStandardTraversals

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@Ignore
public void benchmarkStandardTraversals() throws Exception {
    Graph graph = TinkerGraph.open();
    GraphTraversalSource g = graph.traversal();
    graph.io(GraphMLIo.build()).readGraph("data/grateful-dead.xml");
    final List<Supplier<Traversal>> traversals = Arrays.asList(
            () -> g.V().outE().inV().outE().inV().outE().inV(),
            () -> g.V().out().out().out(),
            () -> g.V().out().out().out().path(),
            () -> g.V().repeat(out()).times(2),
            () -> g.V().repeat(out()).times(3),
            () -> g.V().local(out().out().values("name").fold()),
            () -> g.V().out().local(out().out().values("name").fold()),
            () -> g.V().out().map(v -> g.V(v.get()).out().out().values("name").toList())
    );
    traversals.forEach(traversal -> {
        logger.info("\nTESTING: {}", traversal.get());
        for (int i = 0; i < 7; i++) {
            final long t = System.currentTimeMillis();
            traversal.get().iterate();
            System.out.print("   " + (System.currentTimeMillis() - t));
        }
    });
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:26,代码来源:TinkerGraphPlayTest.java

示例4: apply

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

示例5: g_V_addVXanimalX_propertyXage_0X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
public void g_V_addVXanimalX_propertyXage_0X() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_addVXanimalX_propertyXage_0X();
    printTraversalForm(traversal);
    int count = 0;
    while (traversal.hasNext()) {
        final Vertex vertex = traversal.next();
        assertEquals("animal", vertex.label());
        assertEquals(0, vertex.<Integer>value("age").intValue());
        count++;
    }
    assertEquals(6, count);
    assertEquals(12, IteratorUtils.count(g.V()));

}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:AddVertexTest.java

示例6: g_V_matchXa_out_bX_selectXb_idX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_matchXa_out_bX_selectXb_idX() throws Exception {
    final Traversal<Vertex, Object> traversal = get_g_V_matchXa_out_bX_selectXb_idX();
    printTraversalForm(traversal);
    int counter = 0;
    final Object vadasId = convertToVertexId("vadas");
    final Object joshId = convertToVertexId("josh");
    final Object lopId = convertToVertexId("lop");
    final Object rippleId = convertToVertexId("ripple");
    Map<Object, Long> idCounts = new HashMap<>();
    while (traversal.hasNext()) {
        counter++;
        MapHelper.incr(idCounts, traversal.next(), 1l);
    }
    assertFalse(traversal.hasNext());
    assertEquals(idCounts.get(vadasId), Long.valueOf(1l));
    assertEquals(idCounts.get(lopId), Long.valueOf(3l));
    assertEquals(idCounts.get(joshId), Long.valueOf(1l));
    assertEquals(idCounts.get(rippleId), Long.valueOf(1l));
    assertEquals(6, counter);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:MatchTest.java

示例7: g_V_hasLabelXsongX_order_byXperfomances_decrX_byXnameX_rangeX110_120X_name

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(GRATEFUL)
public void g_V_hasLabelXsongX_order_byXperfomances_decrX_byXnameX_rangeX110_120X_name() {
    final Traversal<Vertex, String> traversal = get_g_V_hasLabelXsongX_order_byXperfomances_decrX_byXnameX_rangeX110_120X_name();
    printTraversalForm(traversal);
    final List<String> results = traversal.toList();
    assertEquals(10, results.size());
    assertEquals("WANG DANG DOODLE", results.get(0));
    assertEquals("THE ELEVEN", results.get(1));
    assertEquals("WAY TO GO HOME", results.get(2));
    assertEquals("FOOLISH HEART", results.get(3));
    assertEquals("GIMME SOME LOVING", results.get(4));
    assertEquals("DUPREES DIAMOND BLUES", results.get(5));
    assertEquals("CORRINA", results.get(6));
    assertEquals("PICASSO MOON", results.get(7));
    assertEquals("KNOCKING ON HEAVENS DOOR", results.get(8));
    assertEquals("MEMPHIS BLUES", results.get(9));
    assertFalse(traversal.hasNext());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:OrderTest.java

示例8: g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path() {
    final Traversal<Vertex, Path> traversal = get_g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path(convertToVertexId("marko"));
    printTraversalForm(traversal);
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        final Path path = traversal.next();
        if (path.get("a").equals("daniel")) {
            assertEquals(2, path.size());
            assertEquals(6, (int) path.get(1));
        } else {
            assertEquals(4, path.size());
            assertEquals(path.<String>get("a").length(), (int) path.get(3));
        }
    }
    assertEquals(4, counter);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:InjectTest.java

示例9: g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenm_since_2010X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
public void g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenm_since_2010X() {
    final Traversal<Vertex, Vertex> traversal = get_g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenm_since_2010X();
    printTraversalForm(traversal);
    final Vertex stephen = traversal.next();
    assertFalse(traversal.hasNext());
    assertEquals("person", stephen.label());
    assertEquals("stephenm", stephen.value("name"));
    assertEquals(2010, Integer.parseInt(stephen.property("name").value("since").toString()));
    assertEquals(1, IteratorUtils.count(stephen.property("name").properties()));
    assertEquals(1, IteratorUtils.count(stephen.properties()));
    assertEquals(7, IteratorUtils.count(g.V()));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:AddVertexTest.java

示例10: compareQueryTraversalSegment

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
private static void compareQueryTraversalSegment(Traversal<?, ?> gremlinTraversal, Traversal<?, ?> mongoTraversal) {
    gremlinTraversal.iterate();
    mongoTraversal.iterate();
    for (int i = 0; i < mongoTraversal.asAdmin().getSteps().size() - 1; i++) {
        assertEquals(mongoTraversal.asAdmin().getSteps().get(i), gremlinTraversal.asAdmin().getSteps().get(i));
    }
}
 
开发者ID:okram,项目名称:mongodb-gremlin,代码行数:8,代码来源:MongoDBTest.java

示例11: receiveMessages

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Override
    public Iterator<M> receiveMessages() {
        final MultiIterator<M> multiIterator = new MultiIterator<>();
        for (final MessageScope messageScope : this.messageBoard.receiveMessages.keySet()) {
//        for (final MessageScope messageScope : this.messageBoard.previousMessageScopes) {
            if (messageScope instanceof MessageScope.Local) {
                final MessageScope.Local<M> localMessageScope = (MessageScope.Local<M>) messageScope;
                final Traversal.Admin<Vertex, Edge> incidentTraversal = TinkerMessenger.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), this.vertex);
                final Direction direction = TinkerMessenger.getDirection(incidentTraversal);
                final Edge[] edge = new Edge[1]; // simulates storage side-effects available in Gremlin, but not Java8 streams
                multiIterator.addIterator(StreamSupport.stream(Spliterators.spliteratorUnknownSize(VertexProgramHelper.reverse(incidentTraversal.asAdmin()), Spliterator.IMMUTABLE | Spliterator.SIZED), false)
                        .map(e -> this.messageBoard.receiveMessages.get(messageScope).get((edge[0] = e).vertices(direction).next()))
                        .filter(q -> null != q)
                        .flatMap(Queue::stream)
                        .map(message -> localMessageScope.getEdgeFunction().apply(message, edge[0]))
                        .iterator());

            } else {
                multiIterator.addIterator(Stream.of(this.vertex)
                        .map(this.messageBoard.receiveMessages.get(messageScope)::get)
                        .filter(q -> null != q)
                        .flatMap(Queue::stream)
                        .iterator());
            }
        }
        return multiIterator;
    }
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:28,代码来源:TinkerMessenger.java

示例12: g_V_hasXnoX_count

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_hasXnoX_count() {
    final Traversal<Vertex, Long> traversal = get_g_V_hasXnoX_count();
    printTraversalForm(traversal);
    assertEquals(new Long(0), traversal.next());
    assertFalse(traversal.hasNext());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:CountTest.java

示例13: g_V_localXoutE_limitX1X_inVX_limitX3X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_localXoutE_limitX1X_inVX_limitX3X() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_localXoutE_limitX1X_inVX_limitX3X();
    printTraversalForm(traversal);
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        traversal.next();
    }
    assertEquals(3, counter);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:RangeTest.java

示例14: g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX() {
    final Traversal<Vertex, Collection> traversal = get_g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX(convertToVertexId("marko"));
    printTraversalForm(traversal);
    final Collection names = traversal.next();
    assertEquals(4, names.size());
    assertTrue(names.contains("marko"));
    assertTrue(names.contains("josh"));
    assertTrue(names.contains("vadas"));
    assertTrue(names.contains("lop"));
    assertFalse(traversal.hasNext());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:14,代码来源:StoreTest.java

示例15: g_V_aggregateXxX_byXnameX_capXxX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_aggregateXxX_byXnameX_capXxX() {
    final Traversal<Vertex, List<String>> traversal = get_g_V_aggregateXxX_byXnameX_capXxX();
    printTraversalForm(traversal);
    final Collection<String> names = traversal.next();
    assertFalse(traversal.hasNext());
    checkListOfNames(names);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:AggregateTest.java


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