com.franz.agraph.repository
Class AGStreamTupleQuery
java.lang.Object
org.openrdf.query.impl.AbstractOperation
org.openrdf.query.impl.AbstractQuery
com.franz.agraph.repository.AGQuery
com.franz.agraph.repository.AGTupleQuery
com.franz.agraph.repository.AGStreamTupleQuery
- All Implemented Interfaces:
- Operation, Query, TupleQuery
public class AGStreamTupleQuery
- extends AGTupleQuery
- implements TupleQuery
Wraps an AGTupleQuery to provide streaming results.
The default, TupleQueryResultParser and TupleQueryResultBuilder use
SAX to parse and an ArrayList to collect results,
so AGTupleQuery.evaluate()
does not return until the
entire stream is parsed.
AGStreamTupleQuery uses XMLStreamReader
, so the result is
pulled from the http response stream as methods such as
TupleQueryResult
.hasNext()
are called.
Usage:
AGTupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT ...");
query = new AGStreamTupleQuery(query);
TupleQueryResult results = query.evaluate();
...
- Since:
- v4.3
- See Also:
AGRepositoryConnection.prepareTupleQuery(org.openrdf.query.QueryLanguage, String)
Methods inherited from class com.franz.agraph.repository.AGQuery |
analyze, getBindingsArray, getEngine, getEntailmentRegime, getLanguage, getLimit, getName, getOffset, getPlanner, getQueryString, isCheckVariables, isPrepared, setCheckVariables, setEngine, setEntailmentRegime, setIncludeInferred, setLimit, setOffset, setPlanner, setPrepared, setSaveName, toString |
AGStreamTupleQuery
public AGStreamTupleQuery(AGTupleQuery query)
- Wraps a query with this object that will stream the response.
- Parameters:
query
- to wrap
evaluate
public TupleQueryResult evaluate()
throws QueryEvaluationException
- Returns a result object that will read from the http response as
results are requested, by
TupleQueryResult
.hasNext()
.
(Note that TupleQueryResult
.next()
does not actually do the work if hasNext() is called first.)
- Specified by:
evaluate
in interface TupleQuery
- Overrides:
evaluate
in class AGTupleQuery
- Throws:
QueryEvaluationException
evaluate
public void evaluate(TupleQueryResultHandler handler)
throws QueryEvaluationException,
TupleQueryResultHandlerException
- Specified by:
evaluate
in interface TupleQuery
- Overrides:
evaluate
in class AGTupleQuery
- Throws:
QueryEvaluationException
TupleQueryResultHandlerException