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


Java GraphTraversal.Admin方法代码示例

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


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

示例1: g_V

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
private static GraphTraversal.Admin<?, ?> g_V(final Object... hasKeyValues) {
    final GraphTraversal.Admin<?, ?> traversal = new DefaultGraphTraversal<>();
    final TinkerGraphStep<Vertex, Vertex> graphStep = new TinkerGraphStep<>(new GraphStep<>(traversal, Vertex.class, true));
    for (int i = 0; i < hasKeyValues.length; i = i + 2) {
        graphStep.addHasContainer(new HasContainer((String) hasKeyValues[i], (P) hasKeyValues[i + 1]));
    }
    return traversal.addStep(graphStep);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:9,代码来源:TinkerGraphStepStrategyTest.java

示例2: optimisedTraversal

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
private GraphTraversal<Vertex, Vertex> optimisedTraversal(GraphTraversalSource g) {
    GraphTraversal expected = g.V().outE().values("e prop").as("x");

    GraphTraversal.Admin<Vertex, Object> admin = expected.asAdmin();
    JanusPreviousPropertyStep<?> graphStep = new JanusPreviousPropertyStep<>(admin, "v prop", "x");
    admin.addStep(graphStep);

    admin.applyStrategies();

    return expected;
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:12,代码来源:JanusPreviousPropertyStepTest.java

示例3: find

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
public <S> Traversal<S, JSONObject> find(final String queryDocument) {
    final MongoDBTraversalSource clone = this.clone();
    clone.bytecode.addStep(GraphTraversal.Symbols.inject, "query", queryDocument);
    final GraphTraversal.Admin<S, S> traversal = new DefaultGraphTraversal<>(new GraphTraversalSource(clone.getGraph(), clone.getStrategies()));
    return (GraphTraversal) traversal.addStep(new InjectStep(traversal, "query", queryDocument));
}
 
开发者ID:okram,项目名称:mongodb-gremlin,代码行数:7,代码来源:MongoDBTraversalSource.java

示例4: insertOne

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
public <S> Traversal<S, JSONObject> insertOne(final String insertDocument) {
    final MongoDBTraversalSource clone = this.clone();
    clone.bytecode.addStep(GraphTraversal.Symbols.inject, "insert", insertDocument);
    final GraphTraversal.Admin<S, S> traversal = new DefaultGraphTraversal<>(new GraphTraversalSource(clone.getGraph(), clone.getStrategies()));
    return (GraphTraversal) traversal.addStep(new InjectStep(traversal, "insert", insertDocument));
}
 
开发者ID:okram,项目名称:mongodb-gremlin,代码行数:7,代码来源:MongoDBTraversalSource.java

示例5: shouldBeFaster

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Test
public void shouldBeFaster() throws Exception {

    final TraversalStrategies withStrategyUnderTest = new DefaultTraversalStrategies();
    withStrategyUnderTest.addStrategies(getStrategyUnderTestInstance());

    final TraversalStrategies withoutStrategyUnderTest = new DefaultTraversalStrategies();
    withoutStrategyUnderTest.removeStrategies(getStrategyUnderTest());

    final int clockRuns = getClockRuns();
    final Iterator<GraphTraversal> iterator = getTraversalIterator();
    int faster = 0, numTraversals = 0;
    while (iterator.hasNext()) {

        final GraphTraversal traversal = iterator.next();
        final GraphTraversal.Admin original = traversal.asAdmin();
        final GraphTraversal.Admin optimized = original.clone();

        original.setStrategies(withoutStrategyUnderTest);
        optimized.setStrategies(withStrategyUnderTest);

        final double originalTime, optimizedTime;

        if (RANDOM.nextBoolean()) {
            originalTime = TimeUtil.clock(clockRuns, () -> original.clone().iterate());
            optimizedTime = TimeUtil.clock(clockRuns, () -> optimized.clone().iterate());
        } else {
            optimizedTime = TimeUtil.clock(clockRuns, () -> optimized.clone().iterate());
            originalTime = TimeUtil.clock(clockRuns, () -> original.clone().iterate());
        }

        final List originalResult = original.toList();
        final List optimizedResult = optimized.toList();

        if (originalTime > optimizedTime) {
            LOGGER.debug("Original traversal ({} ms): {}", originalTime, original);
            LOGGER.debug("Optimized traversal ({} ms): {}", optimizedTime, optimized);
        } else {
            LOGGER.warn("Original traversal ({} ms): {}", originalTime, original);
            LOGGER.warn("Optimized traversal ({} ms): {}", optimizedTime, optimized);
        }

        if (getAssertionPercentile() >= 100) assertTrue(originalTime > optimizedTime);
        else {
            if (originalTime > optimizedTime)
                faster++;
            numTraversals++;
        }

        assertEquals(originalResult, optimizedResult);
    }

    if (getAssertionPercentile() < 100 && numTraversals > 0)
        assertTrue(((faster * 100.0) / numTraversals) >= getAssertionPercentile());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:56,代码来源:TraversalStrategyPerformanceTest.java

示例6: start

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
private static GraphTraversal.Admin<?, ?> start() {
    return new DefaultGraphTraversal<>().asAdmin();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:4,代码来源:VertexProgramStrategyTest.java

示例7: shouldFoldInHasContainers

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Test
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void shouldFoldInHasContainers() {
    GraphTraversal.Admin traversal = g.V().has("name", "marko").asAdmin();
    assertEquals(2, traversal.getSteps().size());
    assertEquals(HasStep.class, traversal.getEndStep().getClass());
    traversal.applyStrategies();
    assertEquals(1, traversal.getSteps().size());
    assertEquals(TinkerGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(TinkerGraphStep.class, traversal.getEndStep().getClass());
    assertEquals(1, ((TinkerGraphStep) traversal.getStartStep()).getHasContainers().size());
    assertEquals("name", ((TinkerGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getKey());
    assertEquals("marko", ((TinkerGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getValue());
    ////
    traversal = g.V().has("name", "marko").has("age", P.gt(20)).asAdmin();
    traversal.applyStrategies();
    assertEquals(1, traversal.getSteps().size());
    assertEquals(TinkerGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(2, ((TinkerGraphStep) traversal.getStartStep()).getHasContainers().size());
    ////
    traversal = g.V().has("name", "marko").out().has("name", "daniel").asAdmin();
    traversal.applyStrategies();
    assertEquals(3, traversal.getSteps().size());
    assertEquals(TinkerGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(1, ((TinkerGraphStep) traversal.getStartStep()).getHasContainers().size());
    assertEquals("name", ((TinkerGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getKey());
    assertEquals("marko", ((TinkerGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getValue());
    assertEquals(HasStep.class, traversal.getEndStep().getClass());
    ////
    traversal = g.V().has("name", "marko").out().V().has("name", "daniel").asAdmin();
    traversal.applyStrategies();
    assertEquals(3, traversal.getSteps().size());
    assertEquals(TinkerGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(1, ((TinkerGraphStep) traversal.getStartStep()).getHasContainers().size());
    assertEquals("name", ((TinkerGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getKey());
    assertEquals("marko", ((TinkerGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getValue());
    assertEquals(TinkerGraphStep.class, traversal.getSteps().get(2).getClass());
    assertEquals(1, ((TinkerGraphStep) traversal.getSteps().get(2)).getHasContainers().size());
    assertEquals("name", ((TinkerGraphStep<?, ?>) traversal.getSteps().get(2)).getHasContainers().get(0).getKey());
    assertEquals("daniel", ((TinkerGraphStep<?,?>) traversal.getSteps().get(2)).getHasContainers().get(0).getValue());
    assertEquals(TinkerGraphStep.class, traversal.getEndStep().getClass());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:43,代码来源:TinkerGraphStepStrategyTest.java

示例8: shouldHaveAllRegisteredGryoSerializerClasses

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Test
public void shouldHaveAllRegisteredGryoSerializerClasses() throws Exception {
    // this is a stress test that ensures that when data is spilling to disk, persisted to an RDD, etc. the correct classes are registered with GryoSerializer.
    final TinkerGraph randomGraph = TinkerGraph.open();
    int totalVertices = 200000;
    TestHelper.createRandomGraph(randomGraph, totalVertices, 100);
    final String inputLocation = TestHelper.makeTestDataDirectory(GryoSerializerIntegrateTest.class, UUID.randomUUID().toString()) + "/random-graph.kryo";
    randomGraph.io(IoCore.gryo()).writeGraph(inputLocation);
    randomGraph.clear();
    randomGraph.close();

    final String outputLocation = TestHelper.makeTestDataDirectory(GryoSerializerIntegrateTest.class, UUID.randomUUID().toString());
    Configuration configuration = getBaseConfiguration();
    configuration.clearProperty(Constants.SPARK_SERIALIZER); // ensure proper default to GryoSerializer
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, inputLocation);
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, GryoInputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, outputLocation);
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false);
    Graph graph = GraphFactory.open(configuration);
    final GraphTraversal.Admin<Vertex, Map<Vertex, Collection<Vertex>>> traversal = graph.traversal().withComputer(SparkGraphComputer.class).V().group("m").<Map<Vertex, Collection<Vertex>>>cap("m").asAdmin();
    assertTrue(traversal.hasNext());
    assertTrue(traversal.next() == traversal.getSideEffects().get("m"));
    assertFalse(traversal.hasNext());
    assertTrue(traversal.getSideEffects().exists("m"));
    assertTrue(traversal.getSideEffects().get("m") instanceof Map);
    assertEquals(totalVertices, traversal.getSideEffects().<Map>get("m").size());

    configuration = getBaseConfiguration();
    configuration.clearProperty(Constants.SPARK_SERIALIZER); // ensure proper default to GryoSerializer
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, inputLocation);
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, GryoInputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, PersistedOutputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "DISK_ONLY");
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, "persisted-rdd");
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, true);
    graph = GraphFactory.open(configuration);
    assertEquals(totalVertices, graph.compute(SparkGraphComputer.class).program(PageRankVertexProgram.build().iterations(2).create(graph)).submit().get().graph().traversal().V().count().next().longValue());

    configuration = getBaseConfiguration();
    configuration.clearProperty(Constants.SPARK_SERIALIZER); // ensure proper default to GryoSerializer
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, "persisted-rdd");
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, PersistedInputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, outputLocation);
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, true);
    graph = GraphFactory.open(configuration);
    assertEquals(totalVertices, graph.traversal().withComputer(SparkGraphComputer.class).V().count().next().longValue());

    configuration = getBaseConfiguration();
    configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, "persisted-rdd");
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, PersistedInputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, PersistedOutputRDD.class.getCanonicalName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, outputLocation);
    configuration.setProperty(Constants.GREMLIN_SPARK_GRAPH_STORAGE_LEVEL, "MEMORY_ONLY"); // this should be ignored as you can't change the persistence level once created
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "MEMORY_AND_DISK");
    configuration.setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, true);
    graph = GraphFactory.open(configuration);
    assertEquals(totalVertices, graph.traversal().withComputer(SparkGraphComputer.class).V().count().next().longValue());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:61,代码来源:GryoSerializerIntegrateTest.java

示例9: shouldFoldInHasContainers

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Test
public void shouldFoldInHasContainers() {
    GraphTraversal.Admin traversal = g.V().has("name", "marko").asAdmin();
    assertEquals(2, traversal.getSteps().size());
    assertEquals(HasStep.class, traversal.getEndStep().getClass());
    traversal.applyStrategies();
    assertEquals(1, traversal.getSteps().size());
    assertEquals(Neo4jGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(Neo4jGraphStep.class, traversal.getEndStep().getClass());
    assertEquals(1, ((Neo4jGraphStep) traversal.getStartStep()).getHasContainers().size());
    assertEquals("name", ((Neo4jGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getKey());
    assertEquals("marko", ((Neo4jGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getValue());
    ////
    traversal = g.V().has("name", "marko").has("age", P.gt(20)).asAdmin();
    traversal.applyStrategies();
    assertEquals(1, traversal.getSteps().size());
    assertEquals(Neo4jGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(2, ((Neo4jGraphStep) traversal.getStartStep()).getHasContainers().size());
    ////
    traversal = g.V().has("name", "marko").out().has("name", "daniel").asAdmin();
    traversal.applyStrategies();
    assertEquals(3, traversal.getSteps().size());
    assertEquals(Neo4jGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(1, ((Neo4jGraphStep) traversal.getStartStep()).getHasContainers().size());
    assertEquals("name", ((Neo4jGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getKey());
    assertEquals("marko", ((Neo4jGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getValue());
    assertEquals(HasStep.class, traversal.getEndStep().getClass());
    ////
    traversal = g.V().has("name", "marko").out().V().has("name", "daniel").asAdmin();
    traversal.applyStrategies();
    assertEquals(3, traversal.getSteps().size());
    assertEquals(Neo4jGraphStep.class, traversal.getStartStep().getClass());
    assertEquals(1, ((Neo4jGraphStep) traversal.getStartStep()).getHasContainers().size());
    assertEquals("name", ((Neo4jGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getKey());
    assertEquals("marko", ((Neo4jGraphStep<?, ?>) traversal.getStartStep()).getHasContainers().get(0).getValue());
    assertEquals(Neo4jGraphStep.class, traversal.getSteps().get(2).getClass());
    assertEquals(1, ((Neo4jGraphStep) traversal.getSteps().get(2)).getHasContainers().size());
    assertEquals("name", ((Neo4jGraphStep<?, ?>) traversal.getSteps().get(2)).getHasContainers().get(0).getKey());
    assertEquals("daniel", ((Neo4jGraphStep<?,?>) traversal.getSteps().get(2)).getHasContainers().get(0).getValue());
    assertEquals(Neo4jGraphStep.class, traversal.getEndStep().getClass());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:42,代码来源:Neo4jGraphStepStrategyTest.java

示例10: cypher

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
 * Execute the Cypher query with provided parameters and get the result set as a {@link GraphTraversal}.
 *
 * @param query      the Cypher query to execute
 * @param parameters the parameters of the Cypher query
 * @return a fluent Gremlin traversal
 */
public <S, E> GraphTraversal<S, E> cypher(final String query, final Map<String, Object> parameters) {
    this.tx().readWrite();
    final GraphTraversal.Admin<S, E> traversal = new DefaultGraphTraversal<>(this);
    traversal.addStep(new CypherStartStep(traversal, query, new Neo4jCypherIterator<>((Iterator) this.baseGraph.execute(query, parameters), this)));
    return traversal;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:14,代码来源:Neo4jGraph.java


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