Neptune Streams Examples - Amazon Neptune

Neptune Streams Examples

The following examples show how to access change-log stream data in Amazon Neptune.

AT_SEQUENCE_NUMBER Change Log

The following example shows a Gremlin AT_SEQUENCE_NUMBER change log.

curl -s "http://Neptune-DNS:8182/gremlin/stream?limit=1&commitNum=1&opNum=1&iteratorType=AT_SEQUENCE_NUMBER" |jq { "lastEventId": { "commitNum": 1, "opNum": 1 }, "lastTrxTimestamp": 1560011610678, "format": "GREMLIN_JSON", "records": [ { "eventId": { "commitNum": 1, "opNum": 1 }, "data": { "id": "d2b59bf8-0d0f-218b-f68b-2aa7b0b1904a", "type": "vl", "key": "label", "value": { "value": "vertex", "dataType": "String" } }, "op": "ADD" } ], "totalRecords": 1 }

This one shows a SPARQL example of an AT_SEQUENCE_NUMBER change log.

curl -s "http://localhost:8182/sparql/stream?limit=1&commitNum=1&opNum=1&iteratorType=AT_SEQUENCE_NUMBER" |jq { "lastEventId": { "commitNum": 1, "opNum": 1 }, "lastTrxTimestamp": 1571252030566, "format": "NQUADS", "records": [ { "eventId": { "commitNum": 1, "opNum": 1 }, "data": { "stmt": "<https://test.com/s> <https://test.com/p> <https://test.com/o> .\n" }, "op": "ADD" } ], "totalRecords": 1 }

AFTER_SEQUENCE_NUMBER Change Log

The following example shows a Gremlin AFTER_SEQUENCE_NUMBER change log.

curl -s "http://Neptune-DNS:8182/gremlin/stream?limit=1&commitNum=1&opNum=1&iteratorType=AFTER_SEQUENCE_NUMBER" |jq { "lastEventId": { "commitNum": 2, "opNum": 1 }, "lastTrxTimestamp": 1560011633768, "format": "GREMLIN_JSON", "records": [ { "eventId": { "commitNum": 2, "opNum": 1 }, "data": { "id": "d2b59bf8-0d0f-218b-f68b-2aa7b0b1904a", "type": "vl", "key": "label", "value": { "value": "vertex", "dataType": "String" } }, "op": "REMOVE" } ], "totalRecords": 1 }

TRIM_HORIZON Change Log

The following example shows a Gremlin TRIM_HORIZON change log.

curl -s "http://Neptune-DNS:8182/gremlin/stream?limit=1&iteratorType=TRIM_HORIZON" |jq { "lastEventId": { "commitNum": 1, "opNum": 1 }, "lastTrxTimestamp": 1560011610678, "format": "GREMLIN_JSON", "records": [ { "eventId": { "commitNum": 1, "opNum": 1 }, "data": { "id": "d2b59bf8-0d0f-218b-f68b-2aa7b0b1904a", "type": "vl", "key": "label", "value": { "value": "vertex", "dataType": "String" } }, "op": "ADD" } ], "totalRecords": 1 }

Compression Change Log

The following example shows a Gremlin compression change log.

curl -sH \ "Accept-Encoding: gzip" \ "http://Neptune-DNS:8182/gremlin/stream?limit=1&commitNum=1" \ -H "Accept-Encoding: gzip" \ -v |gunzip -|jq > GET /gremlin/stream?limit=1 HTTP/1.1 > Host: localhost:8182 > User-Agent: curl/7.64.0 > Accept: / > Accept-Encoding: gzip *> Accept-Encoding: gzip* > < HTTP/1.1 200 OK < Content-Type: application/json; charset=UTF-8 < Connection: keep-alive *< content-encoding: gzip* < content-length: 191 < { [191 bytes data] Connection #0 to host localhost left intact { "lastEventId": "1:1", "lastTrxTimestamp": 1558942160603, "format": "GREMLIN_JSON", "records": [ { "eventId": "1:1", "data": { "id": "v1", "type": "vl", "key": "label", "value": { "value": "person", "dataType": "String" } }, "op": "ADD" } ], "totalRecords": 1 }