Parser implementation

* Adaptation of the grammar to make more regular w.r.t reference space
   names placement.

 * Implemented Type check

 * Implemented prediction of the result set cardinality. This assumes:
    + A space is not infinite, this is required to compute complementary
      sets as we can compute the whole space volume.
    + Density is mostly uniform, this allows us to assume the number of
      results is related with a constant factor to the volume in space
      of the selection.
    + The prediction is approximated by using the most pessimistic
      resulting cardinality for each operator, in order to keep the
      operation simple, and fast, at the expense of the precision.

 * Implemented execution, which calls into a DB abstraction layer. That
   layer is currently mostly empty. Execution is also implemented in a
   naive way, and should most likely be optimised.
This commit is contained in:
2019-06-19 14:30:08 +02:00
parent 0eaa7839cf
commit 6ed76e485e
16 changed files with 2237 additions and 1153 deletions

View File

@@ -134,33 +134,38 @@ hyperrectangle
: 'hyperrectangle' '{'
position ',' position
( ',' position ',' position )*
( ',' STRING )?
'}'
;
/* A hypersphere is defined by its center and a radius, independantly
* of the number of dimensions of the space. */
hypersphere
: 'hypersphere' '{' position ( ',' positive_number ) '}'
: 'hypersphere' '{'
position
',' positive_number
( ',' STRING )?
'}'
;
point
: 'point' '{' position '}'
: 'point' '{' position ( ',' STRING )? '}'
;
/* Define a shape as the non-zero values in a NIfTI object, defined by
* nifti{
* spaceId: string,
* lower_corner: position, // Optional, default to the origin
* rotation: [ position+ ], // Optional, no rotation by default
* bytes: uri(STRING) // uri to the NIfTI object
* bytes: uri(STRING), // uri to the NIfTI object
* spaceId: string
* }
*/
nifti
: 'nifti' '{'
STRING ','
(position ',' )?
( '[' position ( ',' position )* ']' ',' )?
byte_provider
byte_provider ','
STRING
'}'
;

View File

@@ -18,11 +18,11 @@ projection_operators
*
* If it is provided, it MUST resolve to a NUMBER. */
nifti_operator
: 'nifti' '(' ( selector ',' )? bag_expression ')'
: 'nifti' '(' ( STRING ',' )? ( selector ',' )? bag_expression ')'
;
json_operator
: 'json' '(' jslt ',' bag_expression ')'
: 'json' '(' jslt ',' bag_expression ( ',' STRING )? ')'
;
jslt