On 28/02/2017 13:13, [email protected] wrote:
> Try using a service like Github Gist. 

I guess you say Gist for posting code. I can also use pastebin next time.

> Is it possible that only one of
> the legs of the query has results in it? Have you confirmed that
> _neither_ of the legs executed separately shows the problem?

Yes. As @Andy said UNION are executed separately. So the problem seems
to be that one branch works while the other no.


> ajs6f
> 
>> On Feb 28, 2017, at 4:51 AM, Andy Seaborne <[email protected]>
>> wrote:
>> 
>> What people on the list receive is:
>> 
>> https://lists.apache.org/api/source.lua/8d17e5299cbbe585e7d45ff8ce156021162a9e16fe77818d8f7cff6c@%3Cusers.jena.apache.org%3E
>>
>>
>> 
Looks like HTML to text conversion.
>> 
>>> On 27/02/17 23:58, George News wrote: But the funny thing is that
>>> in both cases (with and without UNION) the code is the same. I
>>> know I close the transaction, but I don’t understand why in one
>>> case it works and in the other no.
>> 
>> Probably you close the transaction before the resultset is all
>> consumed.
>> 
>> Some work is done on execSelect so internally, the use of the
>> dataset can finish early.
>> 
>> UNION has two branches calculated separately.
>> 
>> It depends on the real query.
>> 
>> Andy
>> 
>>> 
>>> I would like to ask another thing:  In a @requestscope is the
>>> reading transaction automatically close when finished the REST
>>> processing or is it mandatory to call dataset.end()?
>>> 
>>> I don't knw why example code is unreadable. I have perfectly seen
>>> the code.
>>> 
>>> Thanks a lot Jorge
>>> 
>>> Sent from jlanza_lumia820
>>> 
>>> From: Andy Seaborne Sent: martes, 28 de febrero de 2017 0:12 To:
>>> [email protected] Subject: Re: SPARQL with UNION returning
>>> TDBTransactionException
>>> 
>>> Unreadable.
>>> 
>>> -------------------------
>>> 
>>> Probably you are passing the result stream out of the
>>> transaction.
>>> 
>>> Reading a ResultSet requires reading the dataset and must be
>>> inside a transaction when the calls to hasNext/next are
>>> happening.
>>> 
>>> Andy
>>> 
>>>> On 27/02/17 18:18, George News wrote: |public SparqlResult
>>>> executeSparql(String sparql) throws SparqlExecutionException {
>>>> String queryString = sparql; Query query = 
>>>> QueryFactory.create(queryString);
>>>> dataset.begin(ReadWrite.READ); try { QueryExecution qExec =
>>>> QueryExecutionFactory.create(query, getModel()); //
>>>> System.out.println(qExec.getQuery().serialize()); // 
>>>> System.out.println(qExec.getQuery().toString()); SparqlResult
>>>> result; if (query.isSelectType()) { result = new
>>>> SparqlResult(qExec.execSelect(), qExec); } else if
>>>> (query.isDescribeType()) { result = new 
>>>> SparqlResult(qExec.execDescribe(), qExec); } else if
>>>> (query.isAskType()) { result = new
>>>> SparqlResult(qExec.execAsk(), qExec); } else if 
>>>> (query.isConstructType()) { result = new 
>>>> SparqlResult(qExec.execConstruct(), qExec); } else { throw new 
>>>> SparqlExecutionException("Unsupported query type: " + 
>>>> query.getQueryType()); } return result; } finally {
>>>> dataset.end(); } private Map<String, Integer>
>>>> getSummaryStatistics() { String queryString = "THE_ONE";
>>>> Map<String, Integer> statistics = new HashMap<>(); 
>>>> GlobalTripleStore gts = new GlobalTripleStore(); try
>>>> (SparqlResult result = gts.executeSparql(queryString)) {
>>>> ResultSet resultSet = (ResultSet) result.getResult(); while
>>>> (resultSet.hasNext()) { QuerySolution sol = resultSet.next();
>>>> int devices = sol.get("count_devices").asLiteral().getInt();
>>>> int observations =sol.get("count_o").asLiteral().getInt();
>>>> statistics.put("devices", resources); statistics.put("o",
>>>> observations); } } catch (SparqlExecutionException e) { // TODO
>>>> Auto-generated catch block e.printStackTrace(); } return
>>>> statistics; } |
>>> 
>>> 
> 

Reply via email to