Interacting with a HeFQUIN Service
After starting a HeFQUIN service (which you can do either using Docker, using a servlet container embedded in HeFQUIN, or using your own, separate servlet container), you can first
test it by opening http://localhost:8080/ in a Web browser
(assuming that you have started the service at port 8080). If this works (i.e., you see a page that
describes the service), you can start interacting with the service via HTTP. In particular,
- you can issue queries and
- you can issue a request for query processing details.
While the following sections describe these options in detail, we also provide an OpenAPI documentation of the API of the HeFQUIN service. This documentation is also available at the root endpoint of the service:
http://localhost:8080/ (assuming that you have started the service at port 8080).
Issuing Queries
At the address http://localhost:8080/query the HeFQUIN service provides a SPARQL endpoint via which clients can issue SPARQL queries to be executed over the federation for which the service has been set up. To this end, the client may send a GET request or a POST request.
In the case of a GET request, the query needs to be provided in URL-encoded form via the URL parameter query (the URL parameters default-graph-uri and named-graph-uri, as introduced for SPARQL endpoints, are not supported by the HeFQUIN service).
In a POST request, the (unencoded) query may be provided directly in the request body, in which
case the request header must contain a Content-Type field with
application/sparql-query as value. Alternatively, the request body of the POST request may
contain the query parameter with the URL-encoded query as value, in which case the value of
the Content-Type field in the request header must be
application/x-www-form-urlencoded (also for POST requests, the URL parameters
default-graph-uri and named-graph-uri are not supported by HeFQUIN).
For instance, by using the command-line tool curl, you may execute the
following command to issue the query in a file called ExampleQuery.rq.
curl -X POST http://localhost:8080/sparql \
--data-binary @ExampleQuery.rq \
-H 'Content-Type: application/sparql-query'
In any case (using GET requests or POST requests), the client may specify the format in which it
wants to receive the query result in the response. To this end, the client may include an
Accept field in the request header, using any of the following media types (with the first
being used as the default).
-
application/sparql-results+json(used as the default) application/sparql-results+xmltext/csvtext/tab-separated-values
Responses returned by the HeFQUIN service may use any of the following HTTP status codes.
200 OK- Returned if the query has been executed successfully. In this case, the response body contains the query result, represented using the specified media type.400 Bad Request- Returned if no query was provided in the request or the query was empty or invalid.406 Not Acceptable- Returned if the givenAcceptvalue is not supported.415 Unsupported Media Type- Returned if the givenContent-Typevalue is not supported.500 Internal Server Error- Returned if an error occurs during query execution.501 Not Implemented- Returned if the given query uses a feature that is not supported by HeFQUIN.
Inspecting Query Processing Details
The HeFQUIN service also provides a diagnostic endpoint at http://localhost:8080/query-inspect, which can be used to inspect internal processing details of a given query, including the logical and physical query plans, execution times, and other statistics. This functionality is intended for debugging, performance tuning, and query analysis.
The endpoint /query-inspect supports both GET and POST requests using the same content
types and parameters as the /sparql endpoint.
For instance, by using the command-line tool curl, you may execute the following command to issue the query in a file called ExampleQuery.rq and retrieve information about the resulting query execution process.
curl -X POST http://localhost:8080/query-inspect \
--data-binary @ExampleQuery.rq \
-H 'Content-Type: application/sparql-query'
The service will return a response in JSON format, with application/json as the content type.
Responses returned by the service may use any of the following HTTP status codes.
200 OK- Returned if the query has been executed successfully. In this case, the response body contains the query processing details as a JSON object (see below).400 Bad Request- Returned if no query was provided in the request or the query was empty or invalid.406 Not Acceptable- Returned if the givenAcceptvalue is not supported.415 Unsupported Media Type- Returned if the givenContent-Typevalue is not supported.500 Internal Server Error- Returned if an error occurs during query execution.501 Not Implemented- Returned if the given query uses a feature that is not supported by HeFQUIN.
If the request is valid, the response will include:
- the source assignment that was passed to the logical optimizer,
- the logical plan that was passed to the physical optimizer,
- the physical plan that was selected for execution,
- timing metrics (overall, planning, compilation, execution),
- detailed statistics of the query planner and of the execution process, and
- any exceptions collected during the execution process.
Below follows an example of the structure of the output that can be expected.
{
"queryMetrics": {
"overallQueryProcessingTime": 222,
"planningTime": 3,
"compilationTime": 1,
"executionTime": 200,
"queryPlanningStats": { ... },
"executionStats": { ... },
"physicalPlan": "(physical plan representation)",
"logicalPlan": "(logical plan representation)",
"sourceAssignment": "(source assignment)",
"exceptions": [ ]
}
}