Search in sources :

Example 1 with SPARQLQueryBindingSet

use of org.eclipse.rdf4j.repository.sparql.query.SPARQLQueryBindingSet in project rdf4j by eclipse.

the class ServiceJoinConversionIteration method convert.

@Override
protected BindingSet convert(BindingSet bIn) throws QueryEvaluationException {
    // overestimate the capacity
    SPARQLQueryBindingSet res = new SPARQLQueryBindingSet(bIn.size() + bindings.size());
    int bIndex = -1;
    Iterator<Binding> bIter = bIn.iterator();
    while (bIter.hasNext()) {
        Binding b = bIter.next();
        String name = b.getName();
        if (name.equals("__rowIdx")) {
            bIndex = Integer.parseInt(b.getValue().stringValue());
            continue;
        }
        res.addBinding(b.getName(), b.getValue());
    }
    // is dealt with in another place)
    if (bIndex == -1)
        throw new QueryEvaluationException("Invalid join. Probably this is due to non-standard behavior of the SPARQL endpoint. " + "Please report to the developers.");
    res.addAll(bindings.get(bIndex));
    return res;
}
Also used : Binding(org.eclipse.rdf4j.query.Binding) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) SPARQLQueryBindingSet(org.eclipse.rdf4j.repository.sparql.query.SPARQLQueryBindingSet)

Example 2 with SPARQLQueryBindingSet

use of org.eclipse.rdf4j.repository.sparql.query.SPARQLQueryBindingSet in project rdf4j by eclipse.

the class SPARQLCrossProductIteration method getNextElement.

@Override
protected BindingSet getNextElement() throws QueryEvaluationException {
    if (currentInputBinding == null) {
        inputBindingsIterator = inputBindings.iterator();
        if (resultIteration.hasNext())
            currentInputBinding = resultIteration.next();
        else
            // no more results
            return null;
    }
    if (inputBindingsIterator.hasNext()) {
        BindingSet next = inputBindingsIterator.next();
        SPARQLQueryBindingSet res = new SPARQLQueryBindingSet(next.size() + currentInputBinding.size());
        res.addAll(next);
        res.addAll(currentInputBinding);
        if (!inputBindingsIterator.hasNext())
            currentInputBinding = null;
        return res;
    }
    return null;
}
Also used : BindingSet(org.eclipse.rdf4j.query.BindingSet) SPARQLQueryBindingSet(org.eclipse.rdf4j.repository.sparql.query.SPARQLQueryBindingSet) SPARQLQueryBindingSet(org.eclipse.rdf4j.repository.sparql.query.SPARQLQueryBindingSet)

Aggregations

SPARQLQueryBindingSet (org.eclipse.rdf4j.repository.sparql.query.SPARQLQueryBindingSet)2 Binding (org.eclipse.rdf4j.query.Binding)1 BindingSet (org.eclipse.rdf4j.query.BindingSet)1 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)1