Changes between Version 6 and Version 7 of DatabaseBasedAnalysis/rootifysql


Ignore:
Timestamp:
08/05/18 18:11:04 (6 years ago)
Author:
tbretz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseBasedAnalysis/rootifysql

    v6 v7  
    140140== Writing to a root-file ==
    141141
     142=== Basics ===
     143
     144Let's try our previous example
     145{{{
     146fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!'"
     147[...]
     148------------------------ Rootify SQL -------------------------
     149[...]
     150Opening file 'rootify.root' [compression=1]...
     151Writing data to tree 'Result'
     152Trying to setup 1 branches...
     153
     154 - Hello World! [VARCHAR NOT NULL] {V}
     155
     156Configured 0 branches.
     157Filling branches...
     1581 rows fetched.
     1591 rows filled into tree.
     1604 kB written to disk.
     161File closed.
     162Execution time: 0.0775619s (77.6 ms/row)
     163--------------------------------------------------------------
     164}}}
     165
     166The option {{{-f}}} (which is a shortcut for {{{--force}}}) actually overwrites an existing root file (''RECREATE''). The verbosity option {{{-v 2}}} prints some information on how the table columns are translated. As the output suggests, 1 branch could have been setup (one column was returned), but no branch was configured. Our "''Hello World!''" string is returned as a VARCHAR (or CHAR), but only values are supported. The leading {{{-}}} tells us that the column was skipped, the {{{V}}} is an internal abbreviation for the action (and {{{C}}} for {{{CHAR}}}). So second try:
     167
     168{{{
     169fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1"
     170[...]
     171------------------------ Rootify SQL -------------------------
     172[...]
     173Opening file 'rootify.root' [compression=1]...
     174Writing data to tree 'Result'
     175Trying to setup 2 branches...
     176
     177 - Hello World! [VARCHAR NOT NULL] {V}
     178 + 1 [BIGINT NOT NULL] {n}
     179
     180Configured 1 branches.
     181Filling branches...
     1821 rows fetched.
     1831 rows filled into tree.
     1845 kB written to disk.
     185File closed.
     186Execution time: 0.064065s (64.1 ms/row)
     187--------------------------------------------------------------
     188}}}
     189
     190Now one branch was setup successfully (indicated by the {{{+}}}) because it of a basic (numerical) type (indicated by the {{{n}}}).
     191
     192All columns of a numerical type ({{{n}}}) get converted to a branch of type double in the root-file. This keeps reading the root-file simple. All SQL columns of types {{{DATE}}}, {{{DATETIME}}} and {{{TIME}}} are converted to UNIX time and also written as a double-branch.
     193
     194To have another way to skip columns, all variables defined in a query are skipped:
     195{{{
     196fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1, @a:=5"
     197[...]
     198------------------------ Rootify SQL -------------------------
     199[...]
     200Trying to setup 3 branches...
     201
     202 - Hello World! [VARCHAR NOT NULL] {V}
     203 + 1 [BIGINT NOT NULL] {n}
     204 - @a:=5 [BIGINT NOT NULL] {@}
     205
     2061 branches skipped due to name starting with @.
     207Configured 1 branches.
     208[...]
     209--------------------------------------------------------------
     210}}}
     211
     212This can be circumvented by giving it a name
     213{{{
     214fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1, @a:=5 AS MyName"
     215[...]
     216------------------------ Rootify SQL -------------------------
     217[...]
     218Trying to setup 3 branches...
     219
     220 - Hello World! [VARCHAR NOT NULL] {V}
     221 + 1 [BIGINT NOT NULL] {n}
     222 + MyName [BIGINT NOT NULL] {n}
     223
     224Configured 2 branches.
     225[...]
     226--------------------------------------------------------------
     227}}}
     228
     229Usually the name of the root-branch coincides with the name of the column, but it can easily be overwritten in the query with the {{{AS}}} directive as illustrated above.
     230
     231Now assuming you want to create a very general query but then skip some column in the root-file (usually, it is more efficient to just don't query them, because they are transferred from the server nevertheless). In this case you can do:
     232{{{
     233fact@ihp-pc45:~/FACT++/build> rootifysql -f -v 2 --query="SELECT 'Hello World\!', 1, @a:=5 AS MyName" --ignore MyName
     234[...]
     235------------------------ Rootify SQL -------------------------
     236[...]
     237Trying to setup 3 branches...
     238
     239 - Hello World! [VARCHAR NOT NULL] {V}
     240 + 1 [BIGINT NOT NULL] {n}
     241 - MyName [BIGINT NOT NULL] {-}
     242
     2431 branches skipped due to ignore list.
     244Configured 1 branches.
     245[...]
     246--------------------------------------------------------------
     247}}}
     248
     249The {{{--ignore}}} option can be specified more than once and it takes regular expression. So {{{--ignore M.*}}} would skip all columns starting with '''My'''.
     250
     251
     252
     253
     254
     255
     256
     257
    142258
    143259