-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-5030: fix FedXDataset support for queries with FROM clauses #5031
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,7 @@ | |
import org.eclipse.rdf4j.query.algebra.helpers.TupleExprs; | ||
import org.eclipse.rdf4j.query.algebra.helpers.collectors.VarNameCollector; | ||
import org.eclipse.rdf4j.query.impl.EmptyBindingSet; | ||
import org.eclipse.rdf4j.query.impl.FallbackDataset; | ||
import org.eclipse.rdf4j.repository.RepositoryException; | ||
import org.eclipse.rdf4j.repository.sparql.federation.CollectionIteration; | ||
import org.eclipse.rdf4j.repository.sparql.federation.RepositoryFederatedService; | ||
|
@@ -179,19 +180,8 @@ public TupleExpr optimize(TupleExpr expr, EvaluationStatistics evaluationStatist | |
|
||
FederationEvaluationStatistics stats = (FederationEvaluationStatistics) evaluationStatistics; | ||
QueryInfo queryInfo = stats.getQueryInfo(); | ||
Dataset dataset = stats.getDataset(); | ||
|
||
FederationContext federationContext = queryInfo.getFederationContext(); | ||
List<Endpoint> members; | ||
if (dataset instanceof FedXDataset) { | ||
// run the query against a selected set of endpoints | ||
FedXDataset ds = (FedXDataset) dataset; | ||
members = federationContext.getEndpointManager().getEndpoints(ds.getEndpoints()); | ||
} else { | ||
// evaluate against entire federation | ||
FedX fed = federationContext.getFederation(); | ||
members = fed.getMembers(); | ||
} | ||
List<Endpoint> members = getMembersFromContext(stats); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: the logic is now moved into a helper method. Potentially allowing derived extensions to do additional pruning of members in the query context |
||
|
||
// Clone the tuple expression to allow for more aggressive optimizations | ||
TupleExpr clone = expr.clone(); | ||
|
@@ -270,6 +260,34 @@ public TupleExpr optimize(TupleExpr expr, EvaluationStatistics evaluationStatist | |
return query; | ||
} | ||
|
||
/** | ||
* Returns the federation members that are active in the current federation. By default it is all federation | ||
* members. If the passed {@link Dataset} is a {@link FedXDataset}, the defined {@link FedXDataset#getEndpoints()} | ||
* are used. | ||
* | ||
* @param evaluationStatisticss to keep the current query context | ||
* @return | ||
*/ | ||
protected List<Endpoint> getMembersFromContext(FederationEvaluationStatistics evaluationStatisticss) { | ||
Dataset queryDataset = evaluationStatisticss.getDataset(); | ||
|
||
// if the query uses a FROM clause, the external dataset | ||
// is wrapped as primary dataset in FallbackDataset | ||
if (queryDataset instanceof FallbackDataset) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is actually the only change in logic: we unwrap the primary dataset from the FallbackDataset |
||
queryDataset = ((FallbackDataset) queryDataset).getPrimary(); | ||
} | ||
|
||
if (queryDataset instanceof FedXDataset) { | ||
// run the query against a selected set of endpoints | ||
FedXDataset ds = (FedXDataset) queryDataset; | ||
return federationContext.getEndpointManager().getEndpoints(ds.getEndpoints()); | ||
} else { | ||
// evaluate against entire federation | ||
FedX fed = federationContext.getFederation(); | ||
return fed.getMembers(); | ||
} | ||
} | ||
|
||
/** | ||
* Perform source selection for all statements of the query. As a result of this method all statement nodes are | ||
* annotated with their relevant sources. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think it is OK to make the primary dataset accessible for use in FedX?