Compile SPARQL Commands Using the CGE compile Command

Purpose, syntax, examples, modes and output of the CGE CLI's compile command.

The compile command is used to compile SPARQL commands into the logical and/or physical plans that the database server will use for command execution. This can be useful for understanding how the system is interpreting and optimizing a query or update. Specify multiple files to compile a large number of files at the same time.

Compilation Modes

The -c/--compiler-mode option is used to specify the desired compilation output type. Supported values include:
Table 1. Compilation Modes
Compilation ModeOutput Mode
algebraThe optimized SPARQL algebra for the query/update as text in SPARQL Set Expression (SSE) format. This can be thought of as the logical plan for the query.
raw-algebraThe unoptimized SPARQL algebra for the query/update as text in SSE format. This is the unoptimized logical plan for the query.
rpnThe physical plan for the query/update in binary form. Primarily intended for Cray developer use only.
rpn-stringThe physical plan for the query/update in text. Primarily intended for Cray developer use only.
allProduces all of the above.
This option may be specified multiple times to request multiple output formats. It wil supersede any individual format requests if the all option is also specified. The -a or --all options can also be specified as a shortcut for specifying the -c all option.

Compilation Output

By default, the compilation output is sent to standard output and can be redirected to a file if desired. It is recommended to use the -f or --files option if multiple files need to be processed, or if more than one output type needs to be generated. This will output a file for each input and compilation mode combination in the directory that the cge-cli command is being executed. The output file names are automatically generated, based upon the input file name by replacing the extension with the appropriate extension for the output type:
Table 2. Compilation Output
Output TypeOutput File Extension
algebra.algebra
raw-algebra.rawalgebra
rpn.rpn
rpn-string.rpnstring
For more information, see the cge-cli-compile(1) man page.

Examples

The following example will compile the SPARQL command found in the example.rq file into algebraic form and display it to standard output.
$ cge-cli compile -c algebra example.rq
Suppose that there is a file named getTenRows.rq that contains the following SPARQL query:
sparql query: select * {?s ?p ?o} limit 10
Now execute the compile command on getTenRows.qr
$ cge-cli compile -c all getTenRows.rq --files
0 [main] INFO com.cray.cge.parser.sparql.algebra.OpAsRpnMessage  - Started Algebra to RPN message conversion
2 [main] INFO com.cray.cge.parser.sparql.algebra.OpAsRpnMessage  - Finished Algebra to RPN message conversion (3 operations)
The above command would create the following files:
  • getTenRows.rawalgebra
  • getTenRows.rawalgebra
  • getTenRows.rpn
  • getTenRows.rpnstring