本文整理了Java中org.apache.jena.query.ResultSet.hasNext
方法的一些代码示例,展示了ResultSet.hasNext
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultSet.hasNext
方法的具体详情如下:
包路径:org.apache.jena.query.ResultSet
类名称:ResultSet
方法名:hasNext
[英]Is there another result?
[中]还有其他结果吗?
代码示例来源:origin: com.github.galigator.openllet/openllet-jena
public SlicedResultSet(final ResultSet results, final long offset, final long limit)
{
_results = results;
_row = 0;
_limit = limit;
for (int i = 0; i < offset && results.hasNext(); i++)
results.next();
}
代码示例来源:origin: vivo-project/Vitro
/**
* Assumes single bound variable in solution.
*/
protected List<String> executeQueryToList(QueryExecution qex){
List<String> rv = new LinkedList<String>();
ResultSet results = qex.execSelect();
while (results.hasNext()) {
rv.add(querySolutionToString( results.nextSolution() ));
}
return rv;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Node executeSingle(QueryExecutionFactory qef, Query query, Var var) {
Node result = null;
QueryExecution qe = qef.createQueryExecution(query);
ResultSet rs = qe.execSelect();
if(rs.hasNext()) {
Binding binding = rs.nextBinding();
result = binding.get(var);
}
if(rs.hasNext()) {
logger.warn("A single result was retrieved, but more results exist - is this intended?");
}
return result;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
private Set<OWLIndividual> computePosExamples(OWLClass cls) {
List<OWLIndividual> posExamples = new ArrayList<>();
String query = String.format("SELECT ?s WHERE {?s a <%s>}", cls.toStringID());
try(QueryExecution qe = qef.createQueryExecution(query)) {
ResultSet rs = qe.execSelect();
while(rs.hasNext()) {
QuerySolution qs = rs.next();
posExamples.add(new OWLNamedIndividualImpl(IRI.create(qs.getResource("s").getURI())));
}
}
Collections.shuffle(posExamples, rnd);
return new TreeSet<>(posExamples.subList(0, Math.min(posExamples.size(), maxNrOfPosExamples)));
}
代码示例来源:origin: apache/jena
public static boolean containsGraph(Store store, Node graphNode)
{
String qs = "SELECT * { GRAPH "+FmtUtils.stringForNode(graphNode)+" { ?s ?p ?o }} LIMIT 1" ;
Dataset ds = SDBFactory.connectDataset(store) ;
try ( QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ) {
ResultSet rs = qExec.execSelect() ;
return rs.hasNext() ;
}
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
private SortedSet<String> getAllResources(String query){
SortedSet<String> resources = new TreeSet<>();
query = query + " LIMIT 1000";
QueryExecution qe = qef.createQueryExecution(query);
ResultSet rs = qe.execSelect();
QuerySolution qs;
while(rs.hasNext()){
qs = rs.next();
resources.add(qs.getResource("x0").getURI());
}
qe.close();
return resources;
}
代码示例来源:origin: Galigator/openllet
public SlicedResultSet(final ResultSet results, final long offset, final long limit)
{
_results = results;
_row = 0;
_limit = limit;
for (int i = 0; i < offset && results.hasNext(); i++)
results.next();
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static List<Node> executeList(QueryExecutionFactory qef, Query query, Var var) {
List<Node> result = new ArrayList<Node>();
QueryExecution qe = qef.createQueryExecution(query);
ResultSet rs = qe.execSelect();
while(rs.hasNext()) {
//QuerySolutiors.next()
Binding binding = rs.nextBinding();
Node node = binding.get(var);
result.add(node);
}
return result;
}
代码示例来源:origin: vivo-project/Vitro
@Override
protected boolean sparqlSelectQueryHasResults(String queryStr) throws RDFServiceException {
Query query = createQuery(queryStr);
QueryExecution qe = QueryExecutionFactory.sparqlService(readEndpointURI, query);
try {
ResultSet resultSet = qe.execSelect();
return resultSet.hasNext();
} finally {
qe.close();
}
}
代码示例来源:origin: apache/jena
/**
* Execute, expecting the result to be one row, one column. Return that one.
* RDFNode or throw an exception.
* Use with {@code try ( QueryExecution qExec = ....)}.
*/
public static RDFNode getExactlyOne(QueryExecution qExec, String varname) {
ResultSet rs = qExec.execSelect() ;
if ( !rs.hasNext() )
throw new ARQException("Not found: var ?" + varname) ;
QuerySolution qs = rs.nextSolution() ;
RDFNode r = qs.get(varname) ;
if ( rs.hasNext() )
throw new ARQException("More than one: var ?" + varname) ;
return r ;
}
代码示例来源:origin: org.aksw.rdfunit/rdfunit-core
private int getCountNumber(QueryExecutionFactory model, Query query, String var) {
checkNotNull(query);
checkNotNull(var);
int result = 0;
try ( QueryExecution qe = model.createQueryExecution(query) ) {
ResultSet results = qe.execSelect();
if (results != null && results.hasNext()) {
QuerySolution qs = results.next();
result = qs.get(var).asLiteral().getInt();
}
}
return result;
}
}
代码示例来源:origin: Galigator/openllet
public SlicedResultSet(final ResultSet results, final long offset, final long limit)
{
_results = results;
_row = 0;
_limit = limit;
for (int i = 0; i < offset && results.hasNext(); i++)
results.next();
}
代码示例来源:origin: SmartDataAnalytics/Sparqlify
public static void sparqlIntoView(ModelSparqlEndpoint sparqlEndpoint, String queryString, ViewTable viewTable)
throws SQLException
{
ResultSet rs = sparqlEndpoint.createQueryExecution(queryString).execSelect();
while(rs.hasNext()) {
Binding binding = rs.nextBinding();
viewTable.insert(binding);
}
}
代码示例来源:origin: apache/jena
private void assertNoResults() {
assertFalse(qe.execSelect().hasNext());
}
代码示例来源:origin: apache/jena
@Test(expected=QueryCancelledException.class)
public void test_Cancel_API_1()
{
try(QueryExecution qExec = makeQExec("SELECT * {?s ?p ?o}")) {
ResultSet rs = qExec.execSelect() ;
assertTrue(rs.hasNext()) ;
qExec.abort();
assertTrue(rs.hasNext()) ;
rs.nextSolution();
assertFalse("Results not expected after cancel.", rs.hasNext()) ;
}
}
代码示例来源:origin: AKSW/RDFUnit
private int getCountNumber(QueryExecutionFactory model, Query query, String var) {
checkNotNull(query);
checkNotNull(var);
int result = 0;
try ( QueryExecution qe = model.createQueryExecution(query) ) {
ResultSet results = qe.execSelect();
if (results != null && results.hasNext()) {
QuerySolution qs = results.next();
result = qs.get(var).asLiteral().getInt();
}
}
return result;
}
}
代码示例来源:origin: apache/jena
private static RDFNode getExactlyOne(ResultSet rs, String varname) {
if ( ! rs.hasNext() )
return null;
QuerySolution qs = rs.next();
if ( rs.hasNext() )
return null;
return qs.get(varname);
}
代码示例来源:origin: apache/jena
public static Iterator<Node> storeGraphNames(Store store)
{
List<Node> x = new ArrayList<Node>() ;
String qs = "SELECT ?g { GRAPH ?g { }}" ;
QueryExecution qExec = QueryExecutionFactory.create(qs, SDBFactory.connectDataset(store)) ;
ResultSet rs = qExec.execSelect() ;
Var var_g = Var.alloc("g") ;
while(rs.hasNext())
{
Node n = rs.nextBinding().get(var_g) ;
x.add(n) ;
}
return x.iterator() ;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static <T> void processExecSelect(FlowableEmitter<T> emitter, QueryExecution qe, Function<? super ResultSet, ? extends T> next) {
try {
emitter.setCancellable(qe::abort);
ResultSet rs = qe.execSelect();
while(!emitter.isCancelled() && rs.hasNext()) {
T binding = next.apply(rs);
emitter.onNext(binding);
}
emitter.onComplete();
} catch (Exception e) {
emitter.onError(e);
}
}
代码示例来源:origin: apache/jena
@Test(expected=QueryCancelledException.class)
public void test_Cancel_API_2()
{
try(QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> SELECT * {?s ?p ?o . FILTER ex:wait(100) }")) {
ResultSet rs = qExec.execSelect() ;
assertTrue(rs.hasNext()) ;
qExec.abort();
assertTrue(rs.hasNext()) ;
rs.nextSolution();
assertFalse("Results not expected after cancel.", rs.hasNext()) ;
}
}
内容来源于网络,如有侵权,请联系作者删除!