Jody Garnett ha scritto: > Hi Martin - I found another fun bit of code today (as I try to unplug > connection from daily use...): AuthorityCodes > > This is an amazing example of being lazy - the Set is returned - and > each call to iterator() will produce a result set ... (no word on > leaking results set when normal people call "Object sample = > authorityCodes.iterator().next()";
Eeek.... yeah, this is scary (not to mention that a set has, again, no IOException declared, yet they are there, hidden under some runtime exception is guess). > Letting these AuthorityCodes sets escape out into the wild world of user > code would prove fatal for me - since the connection could be reclaimed > at any time (indeed I suspect that they would break in the existing > implementation when the connection is reclaimed at the twenty minuet mark?). > > Regardless I need to figure out how I can be greedy - and aquire all the > authority codes on set creation :-( > I have two ideas: > - just do it - slurp up the codes on creation and pay the price of doing > my query right away > - half implement - do a quick query to a set of the keys referenced, and > then be willing to look up the keys (using full createObject calls - one > at a time as iterator() is called :-( Third option: implement with block access. Between the first (which may be very memory intensive, but you should try out before saying so to be sure), and the second, which will kill you with nextwork latency, how about a compromise: you gather all of the ids, keep a reference to the DataSource, and then issue a query every 100 object, loading the results in memory and closing the resultset and connection right away? Of course, this is harder to implement that the first two options... Cheers Andrea ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
