QtCS2018 Serialisation: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Created page with " * Serialisation * Binary JSON * mmapable() - zero alloc * deprecate, provide compat API to read * how to support reading from it? BJSON → J...")
 
No edit summary
 
Line 1: Line 1:
== Serialisation ==


=== Binary JSON ===


* Serialisation
* Was created for qtjsondb
    * Binary JSON
* fast reading
        * mmapable() - zero alloc
* mmap()able
        * deprecate, provide compat API to read
* Deprecate soon (Qt 5.12?)
            * how to support reading from it? BJSON → JSON → Qt 6 API?
** Remove from QJsonDocument in Qt 6
    * JSON > 128 MB
** Provide compat API to read
        * Needs to be fixed, before Qt 6
*** BSJON → JSON → parse again
    * CBOR
    * Should we have a public API that works for both JSON and CBOR?
        * A DOM Tree API
        * Could solve the editing-in-place issue (below)
        * QJSValue too?
        * QVariantMap
        * How to make sure people can't insert combinations not allowed in the output?
            * Do they do that? Maybe they won't write such code
            * We could use templates, specialising for CBOR, JSON, etc.
            * We could have a wrapper class that has inlines and provides only the possible combinations
    * QDataStream
    * QTextStream
    * Protobuf
    * QXmlStream{Reader,Writer}
* API for editing in place
    * If you update an entry in a node, you have to update the chain leading to it


     QCborValue foo;
=== QJsonDocument ===
     foo["s"] = "value"; // does not compile
 
     foo.toMap()["s"] = "value";   // updates the temporary!
* Limited to 128 MB of RAM footprint (due to Binary JSON)
* Needs to be fixed before Qt 6
* Can use the same backend as QCborValue
* Complaint: updating in-place is not easy
** If you update an entry in a node, you have to update the chain leading to it
** QCborValue has the same problem, as it was designed to have the same API
 
     QJsonValue foo = ...;
     foo["s"] = "value";             // does not compile
     foo.toObject()["s"] = "value"; // updates the temporary!
   
    // must write instead:
    QJsonObject fooObject = foo.toObject();
    fooObject["s"] = "value";
    setFoo(fooObject);
 
=== Common DOM API? ===
 
* Should we have a common API for manipulating trees of JSON-like values?
* QCborValue is a superset of QJsonValue
** But it would be confusing to users to use CBOR classes to manipulate JSON
** Generic name?
* What other uses would this API have?
** Replace QJSValue (QtQml)?
** Replace QVariantMap?
** Entry point for a Protobuf API?
* How to make sure people can't insert combinations not allowed in the output?
** For example, associative containers using integers as keys in JSON
** Do they do that? Maybe they won't write such code
*** They know what their content is used for
** We could use templates, specialising for CBOR, JSON, etc.
** We could have a wrapper class that has inlines and provides only the possible combinations
 
* QCborValue integrated last Friday into QtCore 5.12
** Need to know in the next few weeks if we keep it for 5.12
** Can yank it out and move to a new module for Tech Preview
 
=== Serialising Qt state ===
 
* Needed by Qt Remote Objects
* Slightly different from CBOR and JSON purposes
** Not about a standardised representation of a data model
** More about transmitting state from two independent processes of the same application
* Currently using QDataStream
** Has a lot of problems, can't really detect errors and not extensible enough
* Need more exploration, no conclusion
 
=== Protobuf ===
 
* Need volunteers to write a Proof of Concept
** plugin to protoc?

Latest revision as of 11:15, 11 June 2018

Serialisation

Binary JSON

  • Was created for qtjsondb
  • fast reading
  • mmap()able
  • Deprecate soon (Qt 5.12?)
    • Remove from QJsonDocument in Qt 6
    • Provide compat API to read
      • BSJON → JSON → parse again

QJsonDocument

  • Limited to 128 MB of RAM footprint (due to Binary JSON)
  • Needs to be fixed before Qt 6
  • Can use the same backend as QCborValue
  • Complaint: updating in-place is not easy
    • If you update an entry in a node, you have to update the chain leading to it
    • QCborValue has the same problem, as it was designed to have the same API
   QJsonValue foo = ...;
   foo["s"] = "value";             // does not compile
   foo.toObject()["s"] = "value";  // updates the temporary!
   
   // must write instead:
   QJsonObject fooObject = foo.toObject();
   fooObject["s"] = "value";
   setFoo(fooObject);

Common DOM API?

  • Should we have a common API for manipulating trees of JSON-like values?
  • QCborValue is a superset of QJsonValue
    • But it would be confusing to users to use CBOR classes to manipulate JSON
    • Generic name?
  • What other uses would this API have?
    • Replace QJSValue (QtQml)?
    • Replace QVariantMap?
    • Entry point for a Protobuf API?
  • How to make sure people can't insert combinations not allowed in the output?
    • For example, associative containers using integers as keys in JSON
    • Do they do that? Maybe they won't write such code
      • They know what their content is used for
    • We could use templates, specialising for CBOR, JSON, etc.
    • We could have a wrapper class that has inlines and provides only the possible combinations
  • QCborValue integrated last Friday into QtCore 5.12
    • Need to know in the next few weeks if we keep it for 5.12
    • Can yank it out and move to a new module for Tech Preview

Serialising Qt state

  • Needed by Qt Remote Objects
  • Slightly different from CBOR and JSON purposes
    • Not about a standardised representation of a data model
    • More about transmitting state from two independent processes of the same application
  • Currently using QDataStream
    • Has a lot of problems, can't really detect errors and not extensible enough
  • Need more exploration, no conclusion

Protobuf

  • Need volunteers to write a Proof of Concept
    • plugin to protoc?