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


Java GraphWriter.writeGraph方法代码示例

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


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

示例1: shouldLoseTypesWithGraphSONNoTypesForVertexIds

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
/**
 * Asserts the approximateGraphsChecks function fails when expected. Vertex ids.
 */
@Test
public void shouldLoseTypesWithGraphSONNoTypesForVertexIds() throws IOException {
    final GraphWriter writer = getWriter(noTypesMapperV2d0);
    final GraphReader reader = getReader(noTypesMapperV2d0);
    final TinkerGraph sampleGraph1 = TinkerGraph.open();
    TinkerFactory.generateModern(sampleGraph1);
    sampleGraph1.addVertex(T.id, 100L, "name", "kevin");
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeGraph(out, sampleGraph1);
        final String json = out.toString();
        final TinkerGraph read = TinkerGraph.open();
        reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
        // Should fail on deserialized vertex Id.
        assertFalse(approximateGraphsCheck(sampleGraph1, read));
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:20,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例2: shouldLoseTypesWithGraphSONNoTypesForVertexProps

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
/**
 * Asserts the approximateGraphsChecks function fails when expected. Vertex props.
 */
@Test
public void shouldLoseTypesWithGraphSONNoTypesForVertexProps() throws IOException {
    final GraphWriter writer = getWriter(noTypesMapperV2d0);
    final GraphReader reader = getReader(noTypesMapperV2d0);
    final TinkerGraph sampleGraph1 = TinkerGraph.open();
    TinkerFactory.generateModern(sampleGraph1);

    sampleGraph1.addVertex(T.id, 100, "name", "kevin", "uuid", UUID.randomUUID());
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeGraph(out, sampleGraph1);
        final String json = out.toString();
        final TinkerGraph read = TinkerGraph.open();
        reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
        // Should fail on deserialized vertex prop.
        assertFalse(approximateGraphsCheck(sampleGraph1, read));
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:21,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例3: shouldLoseTypesWithGraphSONNoTypesForEdgeIds

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
/**
 * Asserts the approximateGraphsChecks function fails when expected. Edge ids.
 */
@Test
public void shouldLoseTypesWithGraphSONNoTypesForEdgeIds() throws IOException {
    final GraphWriter writer = getWriter(noTypesMapperV2d0);
    final GraphReader reader = getReader(noTypesMapperV2d0);
    final TinkerGraph sampleGraph1 = TinkerGraph.open();
    TinkerFactory.generateModern(sampleGraph1);
    final  Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin");
    v1.addEdge("hello", sampleGraph1.traversal().V().has("name", "marko").next(), T.id, 101L);
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeGraph(out, sampleGraph1);
        final String json = out.toString();
        final TinkerGraph read = TinkerGraph.open();
        reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
        // Should fail on deserialized edge Id.
        assertFalse(approximateGraphsCheck(sampleGraph1, read));
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:21,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例4: shouldLoseTypesWithGraphSONNoTypesForEdgeProps

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
/**
 * Asserts the approximateGraphsChecks function fails when expected. Edge props.
 */
@Test
public void shouldLoseTypesWithGraphSONNoTypesForEdgeProps() throws IOException {
    final GraphWriter writer = getWriter(noTypesMapperV2d0);
    final GraphReader reader = getReader(noTypesMapperV2d0);
    final Graph sampleGraph1 = TinkerFactory.createModern();

    final Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin");
    v1.addEdge("hello", sampleGraph1.traversal().V().has("name", "marko").next(), T.id, 101,
            "uuid", UUID.randomUUID());
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeGraph(out, sampleGraph1);
        final String json = out.toString();
        final TinkerGraph read = TinkerGraph.open();
        reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
        // Should fail on deserialized edge prop.
        assertFalse(approximateGraphsCheck(sampleGraph1, read));
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:22,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例5: shouldReadWriteModern

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
@Ignore
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldReadWriteModern() throws Exception {
    try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
        ((HBaseGraph) graph).createIndex(ElementType.EDGE, "knows", "weight");
        final GraphWriter writer = graph.io(ioBuilderToTest).writer().create();
        writer.writeGraph(os, graph);

        final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.MODERN);
        graphProvider.clear(configuration);
        final Graph g1 = graphProvider.openTestGraph(configuration);
        ((HBaseGraph) g1).createIndex(ElementType.EDGE, "knows", "weight");
        final GraphReader reader = graph.io(ioBuilderToTest).reader().create();
        //((HBaseGraph) graph).dump();
        //((HBaseGraph) g1).dump();
        try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
            reader.readGraph(bais, g1);
        }

        // modern uses double natively so always assert as such
        IoTest.assertModernGraph(g1, true, lossyForId);

        graphProvider.clear(g1, configuration);
    }
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:27,代码来源:CustomTest.java

示例6: shouldDeserializeGraphSONIntoTinkerGraphWithPartialTypes

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
/**
 * Checks that the graph has been fully ser/deser with types.
 */
@Test
public void shouldDeserializeGraphSONIntoTinkerGraphWithPartialTypes() throws IOException {
    final GraphWriter writer = getWriter(defaultMapperV2d0);
    final GraphReader reader = getReader(defaultMapperV2d0);
    final  TinkerGraph baseModern = TinkerFactory.createModern();

    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeGraph(out, baseModern);
        final String json = out.toString();
        final TinkerGraph read = TinkerGraph.open();
        reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
        IoTest.assertModernGraph(read, true, false);
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:18,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例7: shouldDeserializeGraphSONIntoTinkerGraphWithoutTypes

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
/**
 * Checks that the graph has been fully ser/deser without types.
 */
@Test
public void shouldDeserializeGraphSONIntoTinkerGraphWithoutTypes() throws IOException {
    final GraphWriter writer = getWriter(noTypesMapperV2d0);
    final GraphReader reader = getReader(noTypesMapperV2d0);
    final TinkerGraph baseModern = TinkerFactory.createModern();

    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeGraph(out, baseModern);
        final String json = out.toString();
        final TinkerGraph read = TinkerGraph.open();
        reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
        IoTest.assertModernGraph(read, true, false);
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:18,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例8: shouldKeepTypesWhenDeserializingSerializedTinkerGraph

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
/**
 * Those kinds of types are declared differently in the GraphSON type deserializer, check that all are handled
 * properly.
 */
@Test
public void shouldKeepTypesWhenDeserializingSerializedTinkerGraph() throws IOException {
    final TinkerGraph tg = TinkerGraph.open();

    final Vertex v = tg.addVertex("vertexTest");
    final UUID uuidProp = UUID.randomUUID();
    final Duration durationProp = Duration.ofHours(3);
    final Long longProp = 2L;
    final ByteBuffer byteBufferProp = ByteBuffer.wrap("testbb".getBytes());
    final InetAddress inetAddressProp = InetAddress.getByName("10.10.10.10");

    // One Java util type natively supported by Jackson
    v.property("uuid", uuidProp);
    // One custom time type added by the GraphSON module
    v.property("duration", durationProp);
    // One Java native type not handled by JSON natively
    v.property("long", longProp);
    // One Java util type added by GraphSON
    v.property("bytebuffer", byteBufferProp);
    v.property("inetaddress", inetAddressProp);


    final GraphWriter writer = getWriter(defaultMapperV2d0);
    final GraphReader reader = getReader(defaultMapperV2d0);
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeGraph(out, tg);
        final String json = out.toString();
        final TinkerGraph read = TinkerGraph.open();
        reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
        final Vertex vRead = read.traversal().V().hasLabel("vertexTest").next();
        assertEquals(vRead.property("uuid").value(), uuidProp);
        assertEquals(vRead.property("duration").value(), durationProp);
        assertEquals(vRead.property("long").value(), longProp);
        assertEquals(vRead.property("bytebuffer").value(), byteBufferProp);
        assertEquals(vRead.property("inetaddress").value(), inetAddressProp);
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:42,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例9: writeGryo

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.GRATEFUL)
@BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 0, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
public void writeGryo() throws Exception {
    final GraphWriter writer = graph.io(GryoIo.build()).writer().create();
    final OutputStream os = new ByteArrayOutputStream();
    writer.writeGraph(os, graph);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:GraphWritePerformanceTest.java

示例10: writeGraphML

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.GRATEFUL)
@BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 0, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
public void writeGraphML() throws Exception {
    final GraphWriter writer = graph.io(GraphMLIo.build()).writer().create();
    final OutputStream os = new ByteArrayOutputStream();
    writer.writeGraph(os, graph);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:GraphWritePerformanceTest.java

示例11: writeGraphSON

import org.apache.tinkerpop.gremlin.structure.io.GraphWriter; //导入方法依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.GRATEFUL)
@BenchmarkOptions(benchmarkRounds = 10, warmupRounds = 0, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
public void writeGraphSON() throws Exception {
    final GraphWriter writer = graph.io(GraphSONIo.build()).writer().create();
    final OutputStream os = new ByteArrayOutputStream();
    writer.writeGraph(os, graph);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:GraphWritePerformanceTest.java


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