Hi all, I have been trying to optimize the performance of LowessNormalization plugin a little bit lately. It is extremely slow on our Postgres database when using small 'block groups'.
Anyway, I came across something that surprised me. When using DynamicResultIterator I noticed that hasNext() does not behave in the way I expect. After fetching a row by next() method, invoking hasNext() causes iterator to move to the next row. I checked that on the following example (it = iterator): command | result ----------------------- r = it.next() | - r.getInt(pos) | 324 it.hasNext() | true r.getInt(pos) | 325 ----------------------- I looked into the code to check what is going on. DynamicResultIterator.hasNext() invokes next() method on java.sql.ResultSet object to check if there are rows to read, but it does not move the cursor back(ResultSet.previous()). In addition, next() method uses hasNext() to move the cursor forward (otherwise executing if(it.hasNext) r=it.next() would skip one row). Is this how it is meant to be? I realize that the usual way of using hasNext() is in the context like: while(it.hasNext) r=it.next() // process r where this issue is not a problem, but sometimes it is useful to check if there are next rows of data without actually moving the cursor. One could also benefit from previous() method in that DynamicResultIterator class. There are probably reasons behind this kind of implementation I am not aware of. Then mentioning in the docs that hasNext moves the pointer to next result would be nice. Best wishes, Pawel ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ basedb-devel mailing list basedb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/basedb-devel