本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Neptune Streams 中的序列化格式
Amazon Neptune 使用两种不同的格式来将图形更改数据序列化到日志流,具体取决于该图形是使用 GEMlin 还是 SPARQL 创建的。
两种格式共享一种通用的记录序列化格式,如中所述Neptune Streams API 响应格式其中包含以下字段:
commitTimestamp
— 请求提交事务的时间(使用 Unix 纪元时间表示,单位为毫秒)。eventId
— 流更改记录的序列标识符。data
— 序列化的 Gremlin、SPARQL 或 OpenPher 更改记录。下一节更详细地介绍了每个记录的序列化格式。op
— 创建更改的操作。
PG_JSON 更改序列化格式
截至引擎版本 1.1.0.0,Gremlin 流输出格式 (GREMLIN_JSON
) Gremlin 流端点的输出 (https://
) 被弃用。它被 PG_JSON 所取代,它目前与Neptune-DNS
:8182/gremlin/streamGREMLIN_JSON
.
Gremlin 或 openPher 更改记录,包含在data
日志流响应的字段具有以下字段:
-
id
— 字符串(必需)。GEMlin 或 OpenPher 元素的 ID。
-
type
— 字符串(必需)。该 GEMlin 或 OpenPher 元素的类型。必须是以下类型之一:
vl
— Gremlin 的顶点标签;OpenPher 的节点标签。vp
— Gremlin 的顶点属性;OpenPher 的节点属性。e
— Gremlin 的边缘和边缘标签;OpenPher 的关系和关系类型。ep
— Gremlin 的边缘属性;OpenPher 的关系属性。
-
key
— 字符串(必需)。属性名称。对于元素标签,此为“label”。
-
value
–value
对象(必需)。这是一个 JSON 对象,其中包含
value
字段(存储值本身)和datatype
字段(存储该值的 JSON 数据类型)。"value": { "value": "
the new value
", "dataType": "the JSON datatype of the new value
" } -
from
— 字符串(可选)。如果这是一个边缘 (type= "e”),其为相应的 ID。从顶点或源节点。
-
to
— 字符串(可选)。如果这是一个边缘 (type= "e”),其为相应的 ID。到顶点或目标节点。
GEMlin 示例
-
以下是 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
" }
OpenPher 示例
-
以下是 OpenPher 节点标签的示例。
{ "id": "
an ID string
", "type": "vl", "key": "label", "value": { "value": "the new value of the node label
", "dataType": "String" } } -
以下是 OpenPher 节点属性的示例。
{ "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
" } } -
以下是 OpenPher 关系的示例。
{ "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
" }
SPARQL NQUADS 更改序列化格式
Neptune 使用资源描述框架 (RDF) 记录图形中 SPARQL 四边形的更改。N-QUADS
中定义的语言W3C RDF 1.1 N-四边形
更改记录中的 data
字段仅包含一个 stmt
字段,该字段包含表示更改后的四元组的 N-QUADS 语句,如以下示例所示。
"stmt" : "<https://test.com/s> <https://test.com/p> <https://test.com/o> .\n"