Execution Directives
Execution Directives are Ocular Query Components which execute the queries they suffix and return the results of the execution in a specific format. The most straightforward Execution Directive is toList
which, as the name suggests, executes the Ocular Query it suffixes and returns the results in a list:
toList
l
toList
has a shorthand named l
:
Execution Directives and the Ocular Interpreter
Execution Directives sit at the border between Ocular Queries and the Ocular Interpreter, that is at the border between querying Code Property Graphs, and using the results of those queries for further processing using the Scala programming language. For example, say you'd like to take the results of a query execution and write them to a text file:
You'll see your results written to a file, ready for post-analysis:
Writing the results of a query to a file can also be done in a more concise way using the |>
operator provided by the Ocular Interpreter:
p
p
executes the traversal and pretty-prints the results:
toJson
toJson
executes the traversal and returns the results in a JSON string:
toJsonPretty
toJsonPretty
executes the traversal and returns the results in a pretty-printed JSON string:
size
size
executes the traversal and returns the number of results: