agquery is a command-line query tool. It dispatches queries to the AllegroGraph server and receives the results. The results are the same as sending queries using, say, AGWebView (see WebView).



The arguments are:

the AllegroGraph triple store name
zero or more files or directories containing SPARQL queries; If a directory is specified, all of the files in it will be processed. Use - for standard input.


There are many options. For convenience, we break them into several categories:

Connection options

-p PORT, --port PORT
Server port (default 10035).
-c CATALOG, --catalog CATALOG
CATALOG name on server; use "" or leave unspecified for the root catalog (the default is the root catalog). Note: the root catalog has no name. Specifying "root" will not be interpreted as the root catalog.
-u USERNAME, --username USERNAME
username for the triple-store; use with --password (default username).
--password PASSWORD
password for the triple-store; use with --username (default password).
--server SERVER
server where the triple-store lives (if unspecified, this argument is ignored). This allows you to query a remote triple-store.

Triple-store options

-m MODE, --mode MODE
the reasoning mode. The choices are:
rdfs           RDFS++  
restriction    restriction 
-o LEVEL, --optimize LEVEL
Optimize database indices (default 0) as soon as the store is opened. Possible values are 0, 1, and 2. See optimize-indices][].
--specification SPECIFICATION
triple-store specification for a remote-triple-store (if unspecified, this argument is ignored). See Session specifications in AGWebView.
--with-indices INDICES

Specify the indices of the triple-store. The parameter should be a list of index names separated by spaces. When multiple names separated by spaces are specified, the spaces must be escaped or the whole specification can be quoted, like "spogi posgi ospgi".

If not specified, newly created triple-stores will use the standard set of indices and existing triple-stores will retain their current indices. If specified, the current indices are dropped and the newly specified ones are used.

Query options

--engine ENGINE
Name of the query engine to use (default default). Choices are:
sparql-1.1, sbqe, set-based    Use the set based engine  
sparql-1.0 or algebra          Use the SPARQL algebra engine  
default                        Use the default engine  
Run entire batch (default 1).
--option NAME=VALUE
Specify options, which will be used when running the queries, just like normal SPARQL prefixes. See SPARQL query options.
Run each query this many times per iteration (default 1).
--results-format FORMAT
output format used by the query engine (default table). Choices are:
arrays          arrays  
strings         strings  
lists           lists  
sparql-xml      sparql-xml  
count           count  
count-cursor    determine the count using a cursor  
table           table 
--title TITLE
Value to use for the report title.

Reporting options

--baseline FILENAME
Log file to use as a reporting baseline.
--measure MEASURE
What to measure (e.g., time, space). Choices include:
Choice     What it measures  
------     ----------------  
time       time  
user       user time  
system     system time  
space      cons cells  
minor      minor page faults  
major      major page faults 
--report-format FORMAT
Output format for generated reports (default text). Choices are
Choice  Format  
------  ------  
text    text  
csv     comma-separated value  

Other options

--answer-file ANSWER-FILE
provide answers for the queries you are running, in order to verify results.
Save results to log.
--profile STYLE
Profile queries. Styles include:
time     profile time  
space    profile space  
count    count calls (and profile time) 
--profile-file FILENAME
Send profile report to this file (use standard output if unspecified).
Reduce output (default no).
Specify an initial random seed.
--setup FILENAME
Run code before starting queries.
--spogi YES-OR-NO
Turn the SPOGI cache on or off (default yes).
Squeeze / release memory before each query.
--summary-only YES-OR-NO
Report only the summary.
--teardown FILENAME
Run code before exiting agquery.
-v, --verbose
Include more output.
Calls warmup-triple-store before querying if specified.


A typical call using the lubm50 database and associated queries.

agquery --catalog stores lubm-50 /queries/lubm-50/*.rq 

Another example would be the following which uses a book database. Note we get the query from standard input.

agquery --results-format count sp2b-1e4 - <<EOF  
PREFIX rdf:     <>  
PREFIX rdfs:    <>  
PREFIX swrc:    <>  
PREFIX foaf:    <>  
PREFIX bench:   <http://localhost/vocabulary/bench/>  
PREFIX dc:      <>  
PREFIX dcterms: <>  
SELECT ?inproc ?author ?booktitle ?title  
       ?proc ?ee ?page ?url ?yr ?abstract  
  ?inproc rdf:type bench:Inproceedings .  
  ?inproc dc:creator ?author .  
  ?inproc bench:booktitle ?booktitle .  
  ?inproc dc:title ?title .  
  ?inproc dcterms:partOf ?proc .  
  ?inproc rdfs:seeAlso ?ee .  
  ?inproc swrc:pages ?page .  
  ?inproc foaf:homepage ?url .  
  ?inproc dcterms:issued ?yr  
    ?inproc bench:abstract ?abstract  
ORDER BY ?yr  

It returns:

   147   0.364