Hi,
Playing with the nice new async and client library together to generate asynchronous remote query I got randomly the following exception:
java.lang.ClassCastException: org.basex.query.value.seq.tree.BigSeq cannot be cast to org.basex.query.value.item.Item at org.basex.query.value.ValueBuilder.concat(ValueBuilder.java:37) at org.basex.query.expr.List.value(List.java:147) at org.basex.query.QueryContext.value(QueryContext.java:420) at org.basex.query.expr.If.value(If.java:131) at org.basex.query.expr.gflwor.GFLWOR.value(GFLWOR.java:78) at org.basex.query.QueryContext.value(QueryContext.java:420) at org.basex.query.value.item.FuncItem.invValue(FuncItem.java:129) at org.basex.query.func.FuncCall.invoke(FuncCall.java:87) at org.basex.query.func.FuncCall.value(FuncCall.java:159) at org.basex.query.value.item.FItem.invokeValue(FItem.java:45) at org.basex.query.func.hof.HofUntil.value(HofUntil.java:27) at org.basex.query.func.hof.HofUntil.iter(HofUntil.java:18) at org.basex.query.QueryContext.iter(QueryContext.java:409) at org.basex.query.expr.List$1.next(List.java:134) at org.basex.query.MainModule$1.next(MainModule.java:123) at org.basex.core.cmd.AQuery.query(AQuery.java:92) at org.basex.core.cmd.XQuery.run(XQuery.java:22) at org.basex.core.Command.run(Command.java:398) at org.basex.core.Command.execute(Command.java:100) at org.basex.server.ClientListener.run(ClientListener.java:136)
This happen with the attached code where 10.0.0.5 is another basexserver than the current one. The code is a preliminary test on launching system command on another basexserver asynchronously.
Have a nice evening.
Pablo
Hi Pablo,
java.lang.ClassCastException: org.basex.query.value.seq.tree.BigSeq cannot be cast to org.basex.query.value.item.Item
The reason for the exception was that you were creating a huge result in your query. The input value of $result was added multiple times, resulting in a much larger result:
function ($result) { for $id in async:ids() return if ... else $result }
After repeated calls of this function, the length of the $result sequence exceeded many billion items and eventually got negative (because our size counter is limited to 64 bits).
See the following simplified query:
hof:until( function ($result) { false() }, function ($result) { for $id in 1 to 100 return $result }, 'value' )
Or this one:
fold-left( 1 to 100, "value", function($seq, $curr) { ($seq, $seq) } )
As the error message was not very helpful, I have added a little range check [1, 2].
Hope this helps Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/ba... [2] http://files.basex.org/releases/latest/
Thanks.
Helped me a lot, found the bug in my code. Tested the new version and the error message is clearer. I don't know if its possible in case of java exception like this one to not only have the java stack trace but also the xquery one to be able to easier spot the line of code generating the error.
Have a nice day.
Pablo
On 15. 04. 16 10:23, Christian Grün wrote:
Hi Pablo,
java.lang.ClassCastException: org.basex.query.value.seq.tree.BigSeq cannot be cast to org.basex.query.value.item.Item
The reason for the exception was that you were creating a huge result in your query. The input value of $result was added multiple times, resulting in a much larger result:
function ($result) { for $id in async:ids() return if ... else $result }
After repeated calls of this function, the length of the $result sequence exceeded many billion items and eventually got negative (because our size counter is limited to 64 bits).
See the following simplified query:
hof:until( function ($result) { false() }, function ($result) { for $id in 1 to 100 return $result }, 'value' )
Or this one:
fold-left( 1 to 100, "value", function($seq, $curr) { ($seq, $seq) } )
As the error message was not very helpful, I have added a little range check [1, 2].
Hope this helps Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/ba... [2] http://files.basex.org/releases/latest/
I don't know if its possible in case of java exception like this one to not only have the java stack trace but also the xquery one to be able to easier spot the line of code generating the error.
It’s a bit difficult to catch these kinds of errors, because integer overflows and out-of-memory errors can occur all over the place… Let’s see, maybe we’ll find a nice way out.
basex-talk@mailman.uni-konstanz.de