Skip to content

Commit

Permalink
Mapper result lists can be now be immediately (safely) iterated while…
Browse files Browse the repository at this point in the history
… data is being fetched in the background.
  • Loading branch information
Aklakan committed Jul 16, 2017
1 parent 405a4e1 commit 06d7cf3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;

import org.aksw.jena_sparql_api.core.QueryExecutionDecorator;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.ResultSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,16 @@ protected Entry<Node, ResultSetPart> computeNext() {
}

Entry<Node, ResultSetPart> r = lookAhead == null && rsp.getBindings().isEmpty()
? endOfData()
? null //endOfData()
: new SimpleEntry<>(currentNode, rsp);

if(r == null) {
endOfData();
// Make sure to close the query execution or we will
// cause starvation in jena's connection pool
qe.close();
}

return r;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ public Stream<X> getResultStream(Range<Long> requestRange) { //, Integer offset)
ListPaginator<Entry<Node, Node>> paginator = ls.createPaginator(new Concept(new ElementSubQuery(query), resultVar));


Stream<Node> items = paginator.apply(requestRange).map(Entry::getKey);
Stream<Entry<Node, Node>> rawItems = paginator.apply(requestRange);

Stream<Node> items = rawItems.map(Entry::getKey);
//List<Node> items = ServiceUtils.fetchList(qef, query, resultVar);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.aksw.jena_sparql_api.mapper.annotation.Iri;
import org.aksw.jena_sparql_api.mapper.annotation.RdfType;

@RdfType("http://spinrdf.org/sp#Query")
@RdfType("http://lsq.aksw.org/vocab#Query")
public class LsqQuery {
@Iri
protected String iri;
Expand Down

0 comments on commit 06d7cf3

Please sign in to comment.