Modification of the way in which Shapes are persistified. New DB schema.
This MR implements a new SQLite DB schema to let us store numeric values as REAL instead of TEXT.
Functions:
Functions were all persitified as strings. That made the persistification process simpler because a function composed of a variable number of operators was stored as a single string in the Functions table.
However, that involves different layers of conversion between numbers and strings.
So, now Functions are stored in two tables, follwoing the changes introduced by @boudreau in the TransfunctionPerstifier
:
- a table stores the numeric data only,
- a table stores the string representation of the operators, with placeholders for the numeric data, plus two integers pointing at the beginning and end rows in the first table
Also, a new CTest has been added to test the I/O operations of Functions and SerialTransformers.
Shapes:
Shapes were all persitified as strings. That made the persistification process simpler and the DB schema lighter.
Also, that allows the persistification of shapes with a variable number of parameters (such as "GeoPcon") transparent: a variable number of parameters were encoded in a semi-colon-separated list of strings. Then, it was interpreted in the GeoModelRead according to the type of shape.
But that prevented us to store numbers in their native formats.
So, now Shapes are stored in separate tables, all with their native types.
Also, shapes with a variable number of parameters are stored into two tables (in a similar way as we do for Transfuctions): a table stores the fixed parameters, one instance of the shape per row; while another table stores the variable parameters, where each row stores one particular parameter for a given shape, and all the variable parameters for that shape are stored in consequtive rows in the table. Therefore, in the end, a given shape is then stored together with two integers, dataStart and dataEnd, pointing at the rows in the data table.
Volume:
A new volume
column in the DB stores the value of the computed volume for each shape. The value is initialized with a dummy -1
at the beginning, to show that the volume has not been computed yet. It will be computed and filled later by an external tool.
DB After:
DB Before:
Example of Functions
Example of Functions in the new DB:
Expression, plus pointers to row in the data table:
Entries in the data table:
For comparison, this is how they were stored in the old DB schema:
Examples of Shapes
Example of two GeoBox shapes in the new DB:
Example of a GeoTube shape in the new DB:
For comparison, this is how they were stored in the old DB schema:
Example of complex shapes: Pcon
These are shapes with a variable number of construction parameters, such as the Pcon
shape. It has two fixed parameters, plus a variable number of Z-planes, each of them with a Z position, a Rmin and a Rmax.
A Pcon
shape is now stored in the new DB with the help of two linked tables:
- a
data
table storing the variable parameters, that is, the parameters to build the Z-planes in case of the Pcon shape - a table storing the fixed parameters, plus two integers that point at the beginning and ending rows in the data table storing the variable parameters
This is the table that stores the fixed parameters of a Pcon shape:
And this table stores the Zplanes, that is, the parameters that can appear in variable numbers. The first table holds pointers to rows in this data
table:
A Note: this MR is marked as a Draft
because the Read part for Shapes has to be completed.