The current implementation of com.bigdata.rdf.sail.webapp.client.RemoteRepository.hasStatements() relies on the REST API ESTCARD method, which in turn is based on the fast-range count mechanism in the backend database. This fast range count is exact when the namespace uses unisolated updated. However, it can be an overestimate when the namespace uses fully isolated read/write connections (buffered transactions).
In order to fix this we need to lift the hasStatements() method onto the REST API so the backend database can make the decision to use a fast range count or getStatements() LIMIT 1. Also, the code currently ignores the includeInferred boolean. In order to filter out materialized inferences, we would have to use getStatements() LIMIT 1 with an access path filter. The AbstractTripleStore hasStatements() implementation already does all of this. By lifting hasStatements() into the REST API we can simply leverage the existing code.
In fact, the REST API today only supports unisolated updates so this is not currently an urgent issue.
The new method will be
The response is an XML document as follows.
- where result is either "true" or "false"; and
- where elapsed is the elapsed time in milliseconds for the request.
The semantics are to report true iff at least one statement exists at the end point at satisfies the given triple/quad pattern.
The includeInferred option will default to true. When true, inferred statements are considered. When false, only explicit statements are specified.
Note that the server can optimize this request in a number of fashions.
TODO Test suite. We might already have coverage indirectly, but we should have our own direct tests of the new REST API method.