use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class TransformMergeBGPs method merge.
private static BasicPattern merge(BasicPattern p1, BasicPattern p2) {
if (p1 == null || p2 == null)
return null;
BasicPattern p = new BasicPattern();
p.addAll(p1);
p.addAll(p2);
return p;
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class TransformReorder method transform.
/**
* Transforms Quad Patterns with the reordering
*/
@Override
public Op transform(OpQuadPattern opQuadPattern) {
BasicPattern pattern = opQuadPattern.getBasicPattern();
if (pattern.size() < 2)
return opQuadPattern;
BasicPattern pattern2 = reorder.reorder(pattern);
return new OpQuadPattern(opQuadPattern.getGraphNode(), pattern2);
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class TransformFilterPlacementConservative method transformFilterQuadPattern.
private static Op transformFilterQuadPattern(ExprList exprs, Set<Var> patternVarsScope, Node graphNode, BasicPattern pattern) {
// Any filters that depend on no variables.
Op op = insertAnyFilter(exprs, patternVarsScope, null);
if (Var.isVar(graphNode)) {
// Add in the graph node of the quad block.
// It's picked up after the first triple is processed.
VarUtils.addVar(patternVarsScope, Var.alloc(graphNode));
}
for (Triple triple : pattern) {
OpQuadPattern opQuad = getQuads(op);
if (opQuad == null) {
opQuad = new OpQuadPattern(graphNode, new BasicPattern());
op = OpSequence.create(op, opQuad);
}
opQuad.getBasicPattern().add(triple);
// Update variables in scope.
VarUtils.addVarsFromTriple(patternVarsScope, triple);
// Attempt to place any filters
op = insertAnyFilter(exprs, patternVarsScope, op);
}
return op;
}
use of org.apache.jena.sparql.core.BasicPattern in project jena by apache.
the class TransformFilterPlacement method placeQuadPattern.
private static Placement placeQuadPattern(ExprList exprsIn, Node graphNode, BasicPattern pattern) {
ExprList exprs = ExprList.copy(exprsIn);
Set<Var> patternVarsScope = new HashSet<>();
// Any filters that depend on no variables.
Op op = insertAnyFilter$(exprs, patternVarsScope, null);
if (Var.isVar(graphNode)) {
// Add in the graph node of the quad block.
VarUtils.addVar(patternVarsScope, Var.alloc(graphNode));
}
for (Triple triple : pattern) {
OpQuadPattern opQuad = getQuads(op);
if (opQuad == null) {
opQuad = new OpQuadPattern(graphNode, new BasicPattern());
op = OpSequence.create(op, opQuad);
}
opQuad.getBasicPattern().add(triple);
// Update variables in scope.
VarUtils.addVarsFromTriple(patternVarsScope, triple);
op = insertAnyFilter$(exprs, patternVarsScope, op);
}
return result(op, exprs);
}
Aggregations