Skip to content

Always provide both containment and parent id in serialization #55

Description

@enikao

In a tree, the relation between parent and child is bi-directional.
In our serialization format, we have such a relation for each Containment.

Option A: Store child id in parent

Example:

{
  "type": "Car",
  "id": "1111",
  "children": {
    "wheels": [
      "2222",
      "2223"
    ]
  }
},
{
  "type": "MetalWheel",
  "id": "2222"
},
{
  "type": "AluminiumWheel",
  "id": "2223"
},

Pro:

  • Efficient top-down navigation

Con:

  • Need to build up child-to-parent relation during parsing

Option B: Store parent id in child

Example:

{
  "type": "Car",
  "id": "1111"
},
{
  "type": "MetalWheel",
  "id": "2222",
  "parent": "1111"
},
{
  "type": "AluminiumWheel",
  "id": "2223",
  "parent": "1111"
},

Pro:

  • We know the parent even if it's not part of the currently serialized model chunk
  • We don't need another Repo API call "get me the parent of this node"

Con:

  • Need to build up parent-to-child relation during parsing

Option C: Store both

Example:

{
  "type": "Car",
  "id": "1111",
  "children": {
    "wheels": [
      "2222",
      "2223"
    ]
  }
},
{
  "type": "MetalWheel",
  "id": "2222",
  "parent": "1111"
},
{
  "type": "AluminiumWheel",
  "id": "2223",
  "parent": "1111"
},

Pro:

  • Combines all pros of option A and B
  • Both directions are explicitly stored

Con:

  • Duplicate information might waste space
  • Have to handle inconsistent information

-> Decision: Option C
Space issues can be addressed by compression in lower protocol level (#73).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions