use of org.apache.jena.sparql.core.Var in project jena by apache.
the class LeftJoinClassifier method nonLinearVars.
public static Set<Var> nonLinearVars(OpLeftJoin op) {
Op left = effectiveOp(op.getLeft());
Op right = effectiveOp(op.getRight());
Set<Var> leftVars = OpVars.visibleVars(left);
Set<Var> optRight = VarFinder.optDefined(right);
return SetUtils.intersection(leftVars, optRight);
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class ListBase method execEvaluated.
/** If the subject is a list (well, at least not an unbound variable), dispatch to execOneList
* else dispatch to one of object a var, a list or a node.
*/
@Override
public final QueryIterator execEvaluated(Binding binding, PropFuncArg argSubject, Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
Node listNode = argSubject.getArg();
if (!Var.isVar(listNode))
// Subject bound or constant
return execOneList(binding, listNode, predicate, argObject, execCxt);
// Subject unbound.
Var listVar = Var.alloc(listNode);
return listUnboundSubject(binding, listVar, predicate, argObject, execCxt);
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class CSVInput method vars.
private static List<Var> vars(CSVParser parser) {
final List<Var> vars = new ArrayList<>();
List<String> varNames = parser.parse1();
if (varNames == null)
throw new ARQException("SPARQL CSV Results malformed, input is empty");
for (String vn : varNames) {
vars.add(Var.alloc(vn));
}
return vars;
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class container method execEvaluatedCalc.
// Ask by finding all the rdf:_N + rdf:type
private QueryIterator execEvaluatedCalc(Binding binding, Node containerNode, Node predicate, Node member, ExecutionContext execCxt) {
Graph graph = execCxt.getActiveGraph();
if (!containerNode.isVariable()) {
// Container a ground term.
if (!GraphContainerUtils.isContainer(execCxt.getActiveGraph(), containerNode, typeNode))
return IterLib.noResults(execCxt);
return oneContainer(binding, containerNode, member, execCxt);
}
// Container a variable.
Collection<Node> c = null;
if (member.isVariable())
c = findContainers(graph, typeNode);
else
c = findContainingContainers(graph, typeNode, member);
QueryIterConcat cIter = new QueryIterConcat(execCxt);
Var cVar = Var.alloc(containerNode);
for (Node cn : c) {
//Binding the container node.
Binding b = BindingFactory.binding(binding, cVar, cn);
Node m = member;
// Special case of ?x rdfs:member ?x
if (Var.isVar(member) && member.equals(cVar)) {
m = cn;
}
cIter.add(oneContainer(b, cn, m, execCxt));
}
return cIter;
//throw new QueryFatalException(Utils.className(this)+": Arg 1 is too hard : "+containerNode) ;
}
use of org.apache.jena.sparql.core.Var in project jena by apache.
the class strSplit method execEvaluated.
@Override
public QueryIterator execEvaluated(final Binding binding, final Node subject, final Node predicate, final PropFuncArg object, final ExecutionContext execCxt) {
if (!Var.isVar(subject))
throw new ExprEvalException("Subject is not a variable (" + subject + ")");
if (object.getArgListSize() != 2)
throw new ExprEvalException("Object list must contain exactly two arguments, the string to split and a regular expression");
String s = object.getArg(0).getLiteralLexicalForm();
String regex = object.getArg(1).getLiteralLexicalForm();
final Var subjectVar = Var.alloc(subject);
// StrUtils will also trim whitespace
String[] tokens = StrUtils.split(s, regex);
Iterator<Binding> it = Iter.map(Arrays.asList(tokens).iterator(), item -> BindingFactory.binding(binding, subjectVar, NodeFactory.createLiteral(item)));
return new QueryIterPlainWrapper(it, execCxt);
}
Aggregations