Serialization Formats in Neptune Streams - Amazon Neptune

Serialization Formats in Neptune Streams

Amazon Neptune uses two different formats for serializing graph-changes data to log streams, depending on whether the graph was created using Gremlin or SPARQL.

GREMLIN_JSON Change Serialization Format

A Gremlin change record, contained in the data field of a log stream response, has the following fields:

  • id – String, required.

    The ID of the Gremlin element.

  • type – String, required.

    The type of this Gremlin element. Must be one of the following:

    • vl – Vertex label.

    • vp – Vertex properties.

    • e – Edge, and also edge label.

    • ep – Edge properties.

  • key – String, required.

    The property name. For element labels, this is "label".

  • value – value object, required.

    This is a JSON object that contains a value field for the value itself, and a datatype field for the JSON data type of that value.

    "value": { "value": "the new value", "dataType": "the JSON datatype of the new value" }
  • from – String, optional.

    If this is an edge (type="e"), the ID of the corresponding from vertex.

  • to – String, optional.

    If this is an edge (type="e"), the ID of the corresponding to vertex.

Examples

  • The following is an example of a Gremlin vertex label.

    { "id": "an ID string", "type": "vl", "key": "label", "value": { "value": "the new value of the vertex label", "dataType": "String" } }
  • The following is an example of a Gremlin vertex property.

    { "id": "an ID string", "type": "vp", "key": "the property name", "value": { "value": "the new value of the vertex property", "dataType": "the datatype of the vertex property" } }
  • The following is an example of a Gremlin edge.

    { "id": "an ID string", "type": "e", "key": "label", "value": { "value": "the new value of the edge", "dataType": "String" }, "from": "the ID of the corresponding "from" vertex", "to": "the ID of the corresponding "to" vertex" }

SPARQL NQUADS Change Serialization Format

Neptune logs changes to SPARQL quads in the graph using the Resource Description Framework (RDF) N-QUADS language defined in the W3C RDF 1.1 N-Quads specification.

The data field in the change record simply contains a stmt field that holds an N-QUADS statement expressing the changed quad, as in the following example.

"stmt" : "<https://test.com/s> <https://test.com/p> <https://test.com/o> .\n"