Loading and writing data using GraphSON

The Tinkerpop GraphSON Reader can be used to load and write data.

  1. Start the Gremlin console.

  2. Start a graph instance and create the schema.

  3. Use the DSE Graph Loader to load the GraphSON file.

  4. Writing data out of the graph into a GraphSON file while capturing the original data types of the inserted data can be accomplished with a short script:

    gremlin> f = new FileOutputStream("/tmp/recipe_lossless.json");
    mapper = graph.io(graphson()).mapper().embedTypes(true).create();
    graph.io(graphson()).writer().mapper(mapper).create().writeVertex(f,g.V().next(),BOTH)
    ==>null

    A sample of the output shows the class information and data types:

    {
      "@class":"java.util.HashMap",
      "id":{
        "@class":"java.util.HashMap",
        "~label":"meal",
        "member_id":["java.lang.Long",25],
        "community_id":1989847424
      },
      "label":"meal",

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com