You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Jan Martin Keil (Jira)" <ji...@apache.org> on 2020/09/25 08:49:00 UTC

[jira] [Commented] (JENA-1956) ResultSet should implement Iterable

    [ https://issues.apache.org/jira/browse/JENA-1956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17202003#comment-17202003 ] 

Jan Martin Keil commented on JENA-1956:
---------------------------------------

{quote}The code example would fail to close the query execution. For remote execution, it is important to close the QueryExecution object to free up HTTP cache connections for the cached connection pool.
{quote}
Sure, but they are just minimal examples and the error handling can be added the same way in both:
{code:java}
try (QueryExecution qExec = QueryExecutionFactory.create(...) ) {
  for (QuerySolution result : qExec.execSelect()) {
    …
  }
}
{code}
instead of
{code:java}
try (QueryExecution qExec = QueryExecutionFactory.create(...) ) {
  ResultSet results = qExec.execSelect();
  while (results.hasNext()) {
    QuerySolution result = results.next();
    …
  }
}
{code}
On the other hand, Consumers are limited in error handling to throw RuntimeExceptions only. But it is an option.

> ResultSet should implement Iterable
> -----------------------------------
>
>                 Key: JENA-1956
>                 URL: https://issues.apache.org/jira/browse/JENA-1956
>             Project: Apache Jena
>          Issue Type: Improvement
>            Reporter: Jan Martin Keil
>            Priority: Major
>
> The class {{ResultSet}} should implement {{Iterable<QuerySolution>}}. That would significantly ease query result processing. It would allow to write
> {code:java}
> for (QuerySolution result : QueryExecutionFactory.create(query, model).execSelect()) {
>   …
> }
> {code}
> instead of
> {code:java}
> ResultSet results = QueryExecutionFactory.create(query, model).execSelect();
> while (results.hasNext()) {
>   QuerySolution result = results.next();
>   …
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)