

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Format Serialisasi dalam Neptune Stream
<a name="streams-change-formats"></a>

Amazon Neptune menggunakan dua format yang berbeda untuk serialisasi data grafik-perubahan untuk stream log, tergantung apakah grafik dibuat menggunakan Gremlin atau SPARQL.

Kedua format berbagi format serialisasi rekaman umum, seperti yang dijelaskan dalam[Format Respon Neptune Streaming API](streams-using-api-reponse.md), yang berisi bidang berikut:
+ `commitTimestamp`— Waktu di mana komit untuk transaksi diminta, dalam milidetik dari zaman Unix.
+ `eventId`— Pengidentifikasi urutan catatan perubahan aliran.
+ `data`— Serial Gremlin, SPARQL, atau catatan perubahan. OpenCypher Format serialisasi dari setiap catatan dijelaskan secara lebih rinci di bagian selanjutnya.
+ `op`— Operasi yang menciptakan perubahan.

**Topics**
+ [PG\_JSON Ubah Format Serialisasi](#streams-change-formats-gremlin)
+ [Format Serialisasi Perubahan SPARQL NQUADS](#streams-change-formats-sparql)

## PG\_JSON Ubah Format Serialisasi
<a name="streams-change-formats-gremlin"></a>

**catatan**  
Output Gremlin stream output format (`GREMLIN_JSON`) oleh Gremlin stream endpoint () tidak digunakan lagi. `https://{{Neptune-DNS}}:8182/gremlin/stream` Ini digantikan oleh PG\_JSON, yang saat ini identik dengan. `GREMLIN_JSON`

Catatan perubahan Gremlin atau OpenCypher, yang terdapat di `data` bidang respons aliran log, memiliki bidang berikut:
+ `id` – STRING - Diperlukan.

  ID dari elemen Gremlin atau OpenCypher.
+ `type` – STRING - Diperlukan.

  Jenis elemen Gremlin atau OpenCypher ini. Harus berupa salah satu dari yang berikut:
  + `vl`— Label Vertex untuk Gremlin; label node untuk OpenCypher.
  + `vp`- Properti Vertex untuk Gremlin; properti node untuk OpenCypher.
  + `e`- Label tepi dan tepi untuk Gremlin; jenis hubungan dan hubungan untuk OpenCypher.
  + `ep`- Properti tepi untuk Gremlin; properti hubungan untuk OpenCypher.
+ `key` – STRING - Diperlukan.

  Nama properti. Untuk label elemen, ini adalah “label”.
+ `value`— objek `value`, diperlukan.

  Ini adalah objek JSON yang berisi bidang `value` untuk nilai itu sendiri, dan bidang `datatype` untuk tipe data JSON dari nilai tersebut.

  ```
    "value": {
      "value": "{{the new value}}",
      "dataType": "{{the JSON datatype of the new value}}"
    }
  ```
+ `from`- String, opsional.

  Jika ini adalah tepi (type="e”), ID yang sesuai *dari* simpul atau sumber simpul.
+ `to`- String, opsional.

  Jika ini adalah tepi (type="e”), ID yang sesuai dengan simpul atau *target* node.

**Contoh Gremlin**
+ Berikut ini adalah contoh label vertex Gremlin.

  ```
  {
    "id": "{{an ID string}}",
    "type": "vl",
    "key": "label",
    "value": {
      "value": "{{the new value of the vertex label}}",
      "dataType": "String"
    }
  }
  ```
+ Berikut ini adalah contoh properti vertex 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}}"
    }
  }
  ```
+ Berikut ini adalah contoh edge 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}}"
  }
  ```

**Contoh OpenCypher**
+ Berikut ini adalah contoh label node OpenCypher.

  ```
  {
    "id": "{{an ID string}}",
    "type": "vl",
    "key": "label",
    "value": {
      "value": "{{the new value of the node label}}",
      "dataType": "String"
    }
  }
  ```
+ Berikut ini adalah contoh dari properti node 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}}"
    }
  }
  ```
+ Berikut ini adalah contoh hubungan 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}}"
  }
  ```

## Format Serialisasi Perubahan SPARQL NQUADS
<a name="streams-change-formats-sparql"></a>

Log Neptune berubah ke quad SPARQL dalam grafik menggunakan bahasa `N-QUADS` Resource Description Framework (RDF) yang didefinisikan dalam spesifikasi [W3C RDF 1.1 N-Quad](https://www.w3.org/TR/n-quads/).

Bidang `data` dalam catatan perubahan hanya berisi bidang `stmt` yang memegang pernyataan N-QUADS mengekspresikan quad yang diubah, seperti dalam contoh berikut.

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