Neptune 串流中的序列化格式 - Amazon Neptune

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Neptune 串流中的序列化格式

Amazon Neptune 使用兩種不同的格式來序列化圖形變更資料以記錄串流,這取決於圖形是使用 Gremlin 還是建立。SPARQL

這兩種格式共用通用的記錄序列化格式 (如 Neptune 流API響應格式 中所述),其中包含下列欄位:

  • commitTimestamp – 已請求遞交交易的時間,以毫秒為單位,從 Unix epoch 開始。

  • eventId – 串流變更記錄的序列識別符。

  • data— 序列化的小鬼, 或 OpenCypher 更改記SPARQL錄. 以下幾節會詳細描述每筆記錄的序列化格式。

  • op – 已建立變更的操作。

PG_ JSON 變更序列化格式

注意

引擎 1.1.0.0 版開始,Gramlin 串流端點 (https://Neptune-DNS:8182/gremlin/stream) 輸出的 Gremlin 串流輸出格式 (GREMLIN_JSON) 正被棄用。它由 PG_ 取代JSON,目前與. GREMLIN_JSON

包含在記錄資料流回應data欄位中的 Grinlin 或 openCypher 變更記錄具有下列欄位:

  • id – 字串 (必要)。

    小精靈或 openCypher 元素的 ID。

  • type – 字串 (必要)。

    這個小鬼或 openCypher 元素的類型。必須是下列其中之一:

    • vl— 小鬼的頂點標籤;節點標籤。openCypher

    • vp— Girmlin 的頂點屬性;節點屬性。openCypher

    • e— Grimlin 的邊緣和邊緣標籤;關係和關係類型。openCypher

    • ep— 小精靈的邊緣屬性;關係屬性用於. openCypher

  • key – 字串 (必要)。

    屬性名稱 對於元素標籤,這是「標籤」。

  • valuevalue 物件 (必要)。

    這是一個JSON對象,其中包含值本身的datatype字段以及該值的JSON數據類型的字段。value

    "value": { "value": "the new value", "dataType": "the JSON datatype of the new value" }
  • from – 字串 (選用)。

    如果這是邊緣 (type="e"),則為對應「來源」頂點或來源節點的 ID。

  • to – 字串 (選用)。

    如果這是邊緣 (type="e"),則為對應「目標」頂點或目標節點的 ID。

Gremlin 範例
  • 以下是 Gremlin 頂點標籤的範例。

    { "id": "an ID string", "type": "vl", "key": "label", "value": { "value": "the new value of the vertex label", "dataType": "String" } }
  • 以下是 Gremlin 頂點屬性的範例。

    { "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" } }
  • 以下是 Gremlin 邊緣的範例。

    { "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" }
openCypher 例子
  • 以下是 openCypher 節點標籤的範例。

    { "id": "an ID string", "type": "vl", "key": "label", "value": { "value": "the new value of the node label", "dataType": "String" } }
  • 以下是 openCypher 節點屬性的範例。

    { "id": "an ID string", "type": "vp", "key": "the property name", "value": { "value": "the new value of the node property", "dataType": "the datatype of the node property" } }
  • 以下是 openCypher 關係的範例。

    { "id": "an ID string", "type": "e", "key": "label", "value": { "value": "the new value of the relationship", "dataType": "String" }, "from": "the ID of the corresponding source node", "to": "the ID of the corresponding target node" }

SPARQLNQUADS變更序列化格式

Neptune 使用 W3C RDF 1.1 N-SPARQL 四邊形規範中定義的資源描述架構 (RDF) N-QUADS 語言,將變更記錄到圖形中的四邊形。

變更記錄中的data欄位只包含一個包含 N-QUADS 陳述式的stmt欄位,表示變更的四邊形,如下列範例所示。

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