Search in sources :

Example 1 with GraphSONMapper

use of org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper in project titan by thinkaurelius.

the class TitanIoTest method testGeoShapeSerializationReadWriteAsGraphSONEmbedded.

@Test
public void testGeoShapeSerializationReadWriteAsGraphSONEmbedded() throws Exception {
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);
    GraphSONMapper m = graph.io(IoCore.graphson()).mapper().embedTypes(true).create();
    GraphWriter writer = graph.io(IoCore.graphson()).writer().mapper(m).create();
    FileOutputStream fos = new FileOutputStream("/tmp/test.json");
    writer.writeGraph(fos, graph);
    clearGraph(config);
    open(config);
    GraphReader reader = graph.io(IoCore.graphson()).reader().mapper(m).create();
    FileInputStream fis = new FileInputStream("/tmp/test.json");
    reader.readGraph(fis, graph);
    TitanIndexTest.assertGraphOfTheGods(graph);
}
Also used : GraphReader(org.apache.tinkerpop.gremlin.structure.io.GraphReader) GraphSONMapper(org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper) FileOutputStream(java.io.FileOutputStream) GraphWriter(org.apache.tinkerpop.gremlin.structure.io.GraphWriter) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with GraphSONMapper

use of org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper in project incubator-atlas by apache.

the class Titan1Graph method exportToGson.

@Override
public void exportToGson(OutputStream os) throws IOException {
    GraphSONMapper mapper = getGraph().io(IoCore.graphson()).mapper().create();
    GraphSONWriter.Builder builder = GraphSONWriter.build();
    builder.mapper(mapper);
    GraphSONWriter writer = builder.create();
    writer.writeGraph(os, getGraph());
}
Also used : GraphSONMapper(org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper) GraphSONWriter(org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter)

Aggregations

GraphSONMapper (org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 GraphReader (org.apache.tinkerpop.gremlin.structure.io.GraphReader)1 GraphWriter (org.apache.tinkerpop.gremlin.structure.io.GraphWriter)1 GraphSONWriter (org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter)1 Test (org.junit.Test)1