Object type definitions and something like Structs for binary data #4094
DarkCat5501
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Example problem
Lets say you're making an application that is meant to store and retrieve Objects from database, that are part of a bigger record, and in the code they are just an array of Objects. Currently in the database you can choose between saving them as
array<object>
orarray<record>
, both of which have its own drawbacks. For example, records need explicit creation and deletion before insering into the array, which makes more code necessary to do the job, and objects have no fixed fields (yet), which can lead to major issues if for example there is a bug in the data serialization, leading to data corruption or you inseting nested objects into the database (which happend to me).Proposition
As stated in the example problem, most will choose the objects because they need no additional code to be maintained.
I propose the addition of object type definitions inside the database, like:
this would have the major benefit of having object fields type checking, default value definitions, assertions and even fized size objects that are better for database storage and compression.
It sounds similar to records, but, record to work the same way would need relation fields to correlate to the main record, as well as having to duplicate permissions and still have the problem of needing explicit creation and deletion. I guess it could be implemented to something similar to records or record definitions inside the engine, that would inherit the permissions and relate only to the main record, and that would solve the problem.
Usage
Lets imagine you have a simple objet like
Position { x: <int>, y: <int> }
, surreal has Points and MultiPoint types, but it needs more code for serialization and deserialization to be maintained and do not have assertions or return name fields, and if for some reason you need to add az
property, you'll have to create coversion code and it would break the old records. but with type definitions for example it would work:Anothe proposition
This one is only a follow up of the previous proposition and i think it could be a great addition to have data to bytes conversion which paired with the typed Objects it would act like struct definitions that can be directly retrieved without the needing of parsing, and it could be loaded directly into memory, appart from needing some alignment for sure, but could have many implications and usage in the gaming industry, as game servers could store game data directly inside the database
Beta Was this translation helpful? Give feedback.
All reactions