Class FederatedSparqlQueryClient
A class for connecting to multiple remote SPARQL endpoints and federating queries over them with the results merged locally.
Inherited Members
Namespace: VDS.RDF.Query
Assembly: dotNetRdf.dll
Syntax
public class FederatedSparqlQueryClient : ISparqlQueryClient, IConfigurationSerializable
Remarks
Queries are federated by executing multiple requests simultaneously and asynchronously against the endpoints in question with the data then merged locally. The merging process does not attempt to remove duplicate data it just naively merges the data.
Constructors
| Edit this page View SourceFederatedSparqlQueryClient(IEnumerable<SparqlQueryClient>)
Create a new federated client that connects to a number of remote SPARQL endpoints.
Declaration
public FederatedSparqlQueryClient(IEnumerable<SparqlQueryClient> endpointClients)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<SparqlQueryClient> | endpointClients | The remote endpoint clients to be federated. |
FederatedSparqlQueryClient(HttpClient, params Uri[])
Create a new federated client connecting to a number of remote SPARQL endpoints.
Declaration
public FederatedSparqlQueryClient(HttpClient httpClient, params Uri[] endpointUris)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | httpClient | The HTTP client to use for all connections. |
Uri[] | endpointUris | The URIs to connect to. |
FederatedSparqlQueryClient(params SparqlQueryClient[])
Create a new federated client that connects to a number of remote SPARQL endpoints.
Declaration
public FederatedSparqlQueryClient(params SparqlQueryClient[] endpointClients)
Parameters
Type | Name | Description |
---|---|---|
SparqlQueryClient[] | endpointClients | The remote endpoint clients to be federated. |
Properties
| Edit this page View SourceIgnoreFailedRequests
Get or set whether a failed request on one endpoint should cause the entire request to fail.
Declaration
public bool IgnoreFailedRequests { get; set; }
Property Value
Type | Description |
---|---|
bool |
MaxSimultaneousRequests
Get or set the maximum number of endpoints that this client will issue queries to at any one time.
Declaration
public int MaxSimultaneousRequests { get; set; }
Property Value
Type | Description |
---|---|
int |
Timeout
Get or set the period of time to wait for a response from any given endpoint.
Declaration
public int Timeout { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceAddEndpoint(SparqlQueryClient)
Add a remote endpoint using the specified client instance.
Declaration
public void AddEndpoint(SparqlQueryClient endpointClient)
Parameters
Type | Name | Description |
---|---|---|
SparqlQueryClient | endpointClient | The client to use to connect to the remote endpoint. |
Remarks
This method allows callers to use a specific HttpClient for certain remote endpoints by first constructing a SparqlQueryClient instance and then passing it to this method.
QueryWithResultGraphAsync(string)
Execute a SPARQL query where the expected result is a graph - i.e. a CONSTRUCT or DESCRIBE query.
Declaration
public Task<IGraph> QueryWithResultGraphAsync(string sparqlQuery)
Parameters
Type | Name | Description |
---|---|---|
string | sparqlQuery | The SPARQL query string. |
Returns
Type | Description |
---|---|
Task<IGraph> | An RDF graph containing the combined results received from all remote endpoints. |
QueryWithResultGraphAsync(string, CancellationToken)
Execute a SPARQL query that is intended to return an RDF Graph.
Declaration
public Task<IGraph> QueryWithResultGraphAsync(string sparqlQuery, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
string | sparqlQuery | The query to be executed. |
CancellationToken | cancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
Task<IGraph> | An RDF Graph. |
Remarks
This method should be used when processing SPARQL CONSTRUCT or DESCRIBE queries.
QueryWithResultGraphAsync(string, IRdfHandler)
Execute a SPARQL query where the expected result is a graph - i.e. a CONSTRUCT or DESCRIBE query.
Declaration
public Task QueryWithResultGraphAsync(string sparqlQuery, IRdfHandler handler)
Parameters
Type | Name | Description |
---|---|---|
string | sparqlQuery | The SPARQL query string. |
IRdfHandler | handler | The handler to use when parsing the graph data returned by the server. |
Returns
Type | Description |
---|---|
Task | An RDF graph containing the combined results received from all remote endpoints. |
QueryWithResultGraphAsync(string, IRdfHandler, CancellationToken)
Execute a SPARQL query where the expected result is a graph - i.e. a CONSTRUCT or DESCRIBE query.
Declaration
public Task QueryWithResultGraphAsync(string sparqlQuery, IRdfHandler handler, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
string | sparqlQuery | The SPARQL query string. |
IRdfHandler | handler | The handler to use when parsing the graph data returned by the server. |
CancellationToken | cancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
Task | An RDF graph containing the combined results received from all remote endpoints. |
QueryWithResultSetAsync(string, CancellationToken)
Run a federated query asynchronously.
Declaration
public Task<SparqlResultSet> QueryWithResultSetAsync(string sparqlQuery, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | sparqlQuery | The query to be executed. |
CancellationToken | cancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
Task<SparqlResultSet> | The Task object representing the asynchronous operation. |
Remarks
The query results are returned as a result of the task.
QueryWithResultSetAsync(string, ISparqlResultsHandler, CancellationToken)
Run a federated query asynchronously.
Declaration
public Task QueryWithResultSetAsync(string sparqlQuery, ISparqlResultsHandler handler, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | sparqlQuery | |
ISparqlResultsHandler | handler | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | The Task object representing the asynchronous operation. |
Remarks
The query results are reported through the specified ISparqlResultsHandler.
RemoveEndpoint(Uri)
Remove a remote endpoint.
Declaration
public void RemoveEndpoint(Uri endpointUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | endpointUri | The URI of the endpoint to be removed. |
RemoveEndpoint(SparqlQueryClient)
Remove a remote endpoint.
Declaration
public void RemoveEndpoint(SparqlQueryClient endpointClient)
Parameters
Type | Name | Description |
---|---|---|
SparqlQueryClient | endpointClient | The endpoint client to be removed from the federation. |
SerializeConfiguration(ConfigurationSerializationContext)
Serializes the Endpoint's Configuration.
Declaration
public void SerializeConfiguration(ConfigurationSerializationContext context)
Parameters
Type | Name | Description |
---|---|---|
ConfigurationSerializationContext | context | Configuration Serialization Context. |