43 lines
1.2 KiB
Markdown
43 lines
1.2 KiB
Markdown
# How to serialize ?
|
||
|
||
## General rule
|
||
- 1 byte : type of object code
|
||
- int : version of the encoder
|
||
- data : can be the json representation of the object
|
||
|
||
### Current supported types
|
||
- E : events
|
||
- O : object (with history management)
|
||
- P : pickle
|
||
- S : state
|
||
- C : concept
|
||
- D : concept definitions
|
||
|
||
## How concepts are serialized ?
|
||
- get the id of the concept
|
||
- get the hash of the concept −> it will be its unique key
|
||
structure of the serialisation:
|
||
```json
|
||
{
|
||
"id" : "id",
|
||
"parent": <hash code of the previous version of the concept> or "",
|
||
"name": <name of the concept>,
|
||
"where": "",
|
||
"pre": "",
|
||
"post": "",
|
||
"body": "",
|
||
"desc": "",
|
||
...
|
||
}
|
||
```
|
||
|
||
## Idea to manage ObjectSerializer
|
||
Problem:
|
||
During serialization, there is no issue. The match() method is the unique way to get the correct serialier.
|
||
During the deserialisation, all Object serializer have type = '0' and version = 1.
|
||
So how to choose the correct one ?
|
||
A possible solution will be to add the type of the object to deserialize to the saved stream
|
||
--> SHA256 for every object. Too much data saved.
|
||
The id is to let to inc the version automatically in the Serialiser (during the registration) and to keep the mapping within sdp.state
|
||
|