Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
On 6/10/07, Eelco Hillenius [EMAIL PROTECTED] wrote: if calling paging 1,2,3 n each time requires a call to iterator(first, count) and size(), which means a call to db, wouldn't this way, it ll give a bottleneck at the database layer? Imagine there are about concurrent 5000 users doing the pagingim sure the database will slowdown significantly? can it be any way where iterator() can return the size value as well, just to reduce to one query rather than 2 queries being made each time the paging is executed? No, this is not possible. Relational database don't work that way. Read up on this first please, it's basic programming knowledge. There is actually a way around, though with it's own potential ceveat. Read more on for example http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/rs/CountResult.html Eelco - 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/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
in my experience this wont cause a problem. any reasonable db keeps a count of the total rows in any given table. the size() query is most likely select count(*) from foo, which will use that stored count. and even if there is something more dynamic to it, the db will most likely put that statement in a cache and use that. so basically, dont cry wolf until you actually encounter the problem. you can play what-if for a long time :) -igor On 6/10/07, Lec [EMAIL PROTECTED] wrote: Igor, if calling paging 1,2,3 n each time requires a call to iterator(first, count) and size(), which means a call to db, wouldn't this way, it ll give a bottleneck at the database layer? Imagine there are about concurrent 5000 users doing the pagingim sure the database will slowdown significantly? can it be any way where iterator() can return the size value as well, just to reduce to one query rather than 2 queries being made each time the paging is executed? igor.vaynberg wrote: the iterator() and size() are not meant to be used together and there is no, nor ever be, a contract that guarantees any ordering of invocations between these two methods. size() is meant to return the total number of rows iterator() is used to return a window that will be displayed those are the only contracts. what exactly is the problem? -Igor On 4/4/06, Frank Silbermann [EMAIL PROTECTED] wrote: I have a question about the intended use of the DataTable components provided in Wicket Extensions. The DataTable relies upon an IDataProvider to provide the data. To do this, we implement: Iterator iterate(first, count) Lacking any advice to the contrary, I assumed that this is the method which would retrieve data from the database, but this does not seem to be working well for me. My database query is parameterized based on page-component model values, and these may change with each rendering. My problem is that when one rendering presents a short data set, on the next rendering the DataTable is not always requesting all of the rows. The count seems to be affected by the number of rows returned by the previous rendering. I suspect this is because my implementation of int DataProvider.size () assumes that it will be called _*after*_ Iterator iterate(first, count) pulls down the data – so it's always one rendering behind. Should I give the int IDataProvider.size() method the responsibility for figuring out the query string and going to the database? (How else would it be able to tell the DataProvider how many rows to request?) -- View this message in context: http://www.nabble.com/RE%3A--Contract-for-%22Iterator-IDataProvider.iterator%28int-first%2C-int-count%29%22-tf1395451.html#a11054989 Sent from the Wicket - User mailing list archive at Nabble.com. - 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/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - 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/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
Igor, if calling paging 1,2,3 n each time requires a call to iterator(first, count) and size(), which means a call to db, wouldn't this way, it ll give a bottleneck at the database layer? Imagine there are about concurrent 5000 users doing the pagingim sure the database will slowdown significantly? can it be any way where iterator() can return the size value as well, just to reduce to one query rather than 2 queries being made each time the paging is executed? igor.vaynberg wrote: the iterator() and size() are not meant to be used together and there is no, nor ever be, a contract that guarantees any ordering of invocations between these two methods. size() is meant to return the total number of rows iterator() is used to return a window that will be displayed those are the only contracts. what exactly is the problem? -Igor On 4/4/06, Frank Silbermann [EMAIL PROTECTED] wrote: I have a question about the intended use of the DataTable components provided in Wicket Extensions. The DataTable relies upon an IDataProvider to provide the data. To do this, we implement: Iterator iterate(first, count) Lacking any advice to the contrary, I assumed that this is the method which would retrieve data from the database, but this does not seem to be working well for me. My database query is parameterized based on page-component model values, and these may change with each rendering. My problem is that when one rendering presents a short data set, on the next rendering the DataTable is not always requesting all of the rows. The count seems to be affected by the number of rows returned by the previous rendering. I suspect this is because my implementation of int DataProvider.size() assumes that it will be called _*after*_ Iterator iterate(first, count) pulls down the data – so it's always one rendering behind. Should I give the int IDataProvider.size() method the responsibility for figuring out the query string and going to the database? (How else would it be able to tell the DataProvider how many rows to request?) -- View this message in context: http://www.nabble.com/RE%3A--Contract-for-%22Iterator-IDataProvider.iterator%28int-first%2C-int-count%29%22-tf1395451.html#a11054989 Sent from the Wicket - User mailing list archive at Nabble.com. - 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/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
Igor, if calling paging 1,2,3 n each time requires a call to iterator(first, count) and size(), which means a call to db, wouldn't this way, it ll give a bottleneck at the database layer? Imagine there are about 5000 concurrent users doing the same pagingif 2 queries ( iterator() and size() ) are being issued each time a paging is clicked, the extra query will caused unnecessary slowdown to the database. can it be any way where iterator() can return the size value as well, just to reduce to one query rather than 2 queries being made each time the paging is executed? Lec wrote: Igor, if calling paging 1,2,3 n each time requires a call to iterator(first, count) and size(), which means a call to db, wouldn't this way, it ll give a bottleneck at the database layer? Imagine there are about concurrent 5000 users doing the pagingim sure the database will slowdown significantly? can it be any way where iterator() can return the size value as well, just to reduce to one query rather than 2 queries being made each time the paging is executed? igor.vaynberg wrote: the iterator() and size() are not meant to be used together and there is no, nor ever be, a contract that guarantees any ordering of invocations between these two methods. size() is meant to return the total number of rows iterator() is used to return a window that will be displayed those are the only contracts. what exactly is the problem? -Igor On 4/4/06, Frank Silbermann [EMAIL PROTECTED] wrote: I have a question about the intended use of the DataTable components provided in Wicket Extensions. The DataTable relies upon an IDataProvider to provide the data. To do this, we implement: Iterator iterate(first, count) Lacking any advice to the contrary, I assumed that this is the method which would retrieve data from the database, but this does not seem to be working well for me. My database query is parameterized based on page-component model values, and these may change with each rendering. My problem is that when one rendering presents a short data set, on the next rendering the DataTable is not always requesting all of the rows. The count seems to be affected by the number of rows returned by the previous rendering. I suspect this is because my implementation of int DataProvider.size() assumes that it will be called _*after*_ Iterator iterate(first, count) pulls down the data – so it's always one rendering behind. Should I give the int IDataProvider.size() method the responsibility for figuring out the query string and going to the database? (How else would it be able to tell the DataProvider how many rows to request?) -- View this message in context: http://www.nabble.com/RE%3A--Contract-for-%22Iterator-IDataProvider.iterator%28int-first%2C-int-count%29%22-tf1395451.html#a11055010 Sent from the Wicket - User mailing list archive at Nabble.com. - 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/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
RE: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Igor Vaynberg Sent: Tuesday, April 04, 2006 6:32 PM To: wicket-user@lists.sourceforge.net Subject: Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ??? If so, I would ask _which_ framework method _should_ trigger the retrieval of database information needed by both IDataProvider methods? If I knew which of the two methods were called first I could put the database query there. Or, perhaps the database query should be triggered by some other framework method which is called before either of them. you are meant to do two queries: size() { return { select count(*) from blah } } iterator(int first, int count) { return { select * from blah where rownum=first and rownumfirst+count }} -Igor These two methods could return inconsistent results if other users intervening CRUD operations affected the number of rows returned. So if I want to guard against that, I should allow either one of these methods to download the rows and count them. Each method should do that only if the other method hasnt done it first. Is that the idea?
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
you cannot guard against such a thing in the database unless you have an exclusive lock on the table. size() and iterator() are independent of each other unless you are on the last page of the datatable. and even then there is not much you can do if someone is inserting/removing data from under you. -IgorOn 4/5/06, Frank Silbermann [EMAIL PROTECTED] wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Igor Vaynberg Sent: Tuesday, April 04, 2006 6:32 PM To: wicket-user@lists.sourceforge.net Subject: Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ??? If so, I would ask _which_ framework method _ should_ trigger the retrieval of database information needed by both IDataProvider methods? If I knew which of the two methods were called first – I could put the database query there. Or, perhaps the database query should be triggered by some other framework method which is called before either of them. you are meant to do two queries: size() { return { select count(*) from blah } } iterator(int first, int count) { return { select * from blah where rownum=first and rownumfirst+count }} -Igor These two methods could return inconsistent results if other users' intervening CRUD operations affected the number of rows returned. So if I want to guard against that, I should allow either one of these methods to download the rows and count them. Each method should do that only if the other method hasn't done it first. Is that the idea?
RE: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
I have a question about the intended use of the DataTable components provided in Wicket Extensions. The DataTable relies upon an IDataProvider to provide the data. To do this, we implement: Iterator iterate(first, count) Lacking any advice to the contrary, I assumed that this is the method which would retrieve data from the database, but this does not seem to be working well for me. My database query is parameterized based on page-component model values, and these may change with each rendering. My problem is that when one rendering presents a short data set, on the next rendering the DataTable is not always requesting all of the rows. The count seems to be affected by the number of rows returned by the previous rendering. I suspect this is because my implementation of int DataProvider.size() assumes that it will be called _after_ Iterator iterate(first, count) pulls down the data so its always one rendering behind. Should I give the int IDataProvider.size() method the responsibility for figuring out the query string and going to the database? (How else would it be able to tell the DataProvider how many rows to request?)
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
the iterator() and size() are not meant to be used together and there is no, nor ever be, a contract that guarantees any ordering of invocations between these two methods.size() is meant to return the total number of rows iterator() is used to return a window that will be displayedthose are the only contracts.what exactly is the problem?-IgorOn 4/4/06, Frank Silbermann [EMAIL PROTECTED] wrote: I have a question about the intended use of the DataTable components provided in Wicket Extensions. The DataTable relies upon an IDataProvider to provide the data. To do this, we implement: "Iterator iterate(first, count)" Lacking any advice to the contrary, I assumed that this is the method which would retrieve data from the database, but this does not seem to be working well for me. My database query is parameterized based on page-component model values, and these may change with each rendering. My problem is that when one rendering presents a short data set, on the next rendering the DataTable is not always requesting all of the rows. The "count" seems to be affected by the number of rows returned by the previous rendering. I suspect this is because my implementation of "int DataProvider.size()" assumes that it will be called _after_ "Iterator iterate(first, count)" pulls down the data – so it's always one rendering behind. Should I give the "int IDataProvider.size()" method the responsibility for figuring out the query string and going to the database? (How else would it be able to tell the DataProvider how many rows to request?)
RE: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
Assuming that the database query depends upon whatever page-component selections prompted the post-back, both int IDataProvider.size() and Iterator IDataProvider.iterator(first,count) require information that can only be gotten by a database query.: Therefore, for each post-back, Ill need to query the database before _either_ of these methods return. If both methods query the database independently, intervening CRUD operations may cause them to return inconsistent results (a size that is too small or too large). I can and should retrieve both the rows and their number with a single query. The question is where I should do this. My present implementation retrieves the ResultSet when iterator(first,count) is called, setting a size variable that the size() method relies upon. MY PROBLEM is that Im seeing an inconsistent number of rows displayed for the same query. It seems to depend upon how large the previous querys results were. If the value of count in Iterator IDataProvider.iterate(first,count) depends upon the results returned by int IDataProvider.size() that would explain my problem, because the value of count would have been based on obsolete information (it would be based on the previous query). I am wondering whether this is the cause of my problem. If so, I would ask _which_ framework method _should_ trigger the retrieval of database information needed by both IDataProvider methods? If I knew which of the two methods were called first I could put the database query there. Or, perhaps the database query should be triggered by some other framework method which is called before either of them. What are my options? . -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Igor Vaynberg Sent: Tuesday, April 04, 2006 3:56 PM To: wicket-user@lists.sourceforge.net Subject: Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ??? the iterator() and size() are not meant to be used together and there is no, nor ever be, a contract that guarantees any ordering of invocations between these two methods. size() is meant to return the total number of rows iterator() is used to return a window that will be displayed those are the only contracts. what exactly is the problem? -Igor On 4/4/06, Frank Silbermann [EMAIL PROTECTED] wrote: I have a question about the intended use of the DataTable components provided in Wicket Extensions. The DataTable relies upon an IDataProvider to provide the data. To do this, we implement: Iterator iterate(first, count) Lacking any advice to the contrary, I assumed that this is the method which would retrieve data from the database, but this does not seem to be working well for me. My database query is parameterized based on page-component model values, and these may change with each rendering. My problem is that when one rendering presents a short data set, on the next rendering the DataTable is not always requesting all of the rows. The count seems to be affected by the number of rows returned by the previous rendering. I suspect this is because my implementation of int DataProvider.size() assumes that it will be called _after_ Iterator iterate(first, count) pulls down the data so it's always one rendering behind. Should I give the int IDataProvider.size() method the responsibility for figuring out the query string and going to the database? (How else would it be able to tell the DataProvider how many rows to request?)
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
Therefore, for each post-back, I'll need to query the database before _either_ of these methods return. If both methods query the database independently, intervening CRUD operations may cause them to return inconsistent results (a size that is too small or too large). I can and should retrieve both the rows and their number with a single query. The question is where I should do this. Like I stated in my other email, hide this in your model implementation. For example, on detach load the results (window) and the current row count in one transaction. MY PROBLEM is that I'm seeing an inconsistent number of rows displayed for the same query. It seems to depend upon how large the previous query's results were. That sounds like something very specific for your situation. Is the database regularly updated from outside your application? Please don't cross post and keep discussions about the same topic in the same thread so that it is easier for people to follow them. Eelco --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid0944bid$1720dat1642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
you dont need to hide/cache anything. instead of trying to push your formstate into the idataprovider, PULL it by letting the dataprovider have a reference to the form's model.-Igor On 4/4/06, Eelco Hillenius [EMAIL PROTECTED] wrote: Therefore, for each post-back, I'll need to query the database before _either_ of these methods return. If both methods query the database independently, intervening CRUD operations may cause them to return inconsistent results (a size that is too small or too large).I can and should retrieve both the rows and their number with a single query.The question is where I should do this.Like I stated in my other email, hide this in your model implementation. For example, on detach load the results (window) andthe current row count in one transaction. MY PROBLEM is that I'm seeing an inconsistent number of rows displayed for the same query.It seems to depend upon how large the previous query's results were.That sounds like something very specific for your situation. Is thedatabase regularly updated from outside your application?Please don't cross post and keep discussions about the same topic in the same thread so that it is easier for people to follow them.Eelco---This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcastand join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmdlnkkid0944bid$1720dat1642___Wicket-user mailing listWicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
If so, I would ask _which_ framework method _should_ trigger the retrieval of database information needed by both IDataProvider methods? If I knew which of the two methods were called first – I could put the database query there. Or, perhaps the database query should be triggered by some other framework method which is called before either of them.you are meant to do two queries:size() { return { select count(*) from blah } } iterator(int first, int count) { return { select * from blah where rownum=first and rownumfirst+count }}-Igor
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
On 4/4/06, Frank Silbermann [EMAIL PROTECTED] wrote: If the value of "count" in "Iterator IDataProvider.iterate(first,count)" depends upon the results returned by "int IDataProvider.size()" that would explain my problem, because the value of "count" would have been based on obsolete information (it would be based on the previous query). I am wondering whether this is the cause size() is to return the /total/ number of rows available. count is the number of rows you should return for the window. if you set max of 10 rows per page on the datatable then count will always be 10 except for the last page where it can be less. -Igor
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
the implementation will trim to size()-IgorOn 3/24/06, Frank Silbermann [EMAIL PROTECTED] wrote: To use the Wicket-extensions 1.2 DataTable, we must provide an implementation of IDataProvider. IDataProvider , in turn, requires that we implement "int size()" and "Iterator iterator(int first, int count)" If the DataTable is paging data, is it likely that "count" on the last page will be larger than the result determined by "size()" – so that we must return "count" rows or however many remain, whichever is less -- or does the DataTable reduce "count" on the last page so that "first + count" never exceeds "size()"?
RE: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
That suggests to me that the implementation might assume it always gets all the rows it asks for, and may raise an exception otherwise. Is that correct? If so, then any change in the number of rows between displays requires not merely that the DataTable page be reset to 1 (assuming page headers), but that the whole DataTable should be replaced for each response if the data is not static. Was that the intent? If DataTable assumes that the number of rows is static, and if the implementers assumed that in the usual case IDataProvider.iterate(first,count) would go to the database each time rather than storing data, then isnt there a danger that the total size will change while paging through the data as other users insert and delete while one traverses the DataTable pages? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Igor Vaynberg Sent: Friday, March 24, 2006 10:41 AM To: wicket-user@lists.sourceforge.net Subject: Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ??? the implementation will trim to size() -Igor On 3/24/06, Frank Silbermann [EMAIL PROTECTED] wrote: To use the Wicket-extensions 1.2 DataTable, we must provide an implementation of IDataProvider. IDataProvider , in turn, requires that we implement int size() and Iterator iterator(int first, int count) If the DataTable is paging data, is it likely that count on the last page will be larger than the result determined by size() so that we must return count rows or however many remain, whichever is less -- or does the DataTable reduce count on the last page so that first + count never exceeds size()?
Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ???
it doesnt assume anything, it tries to be as lenient as possibleso if your size() suggests that there should be 5 entries on this page, but your iterator only returns 3 - only 3 will be displayed w/out any errors. also if your iterator returns 7 then still only 5 are shown. -IgorOn 3/24/06, Frank Silbermann [EMAIL PROTECTED] wrote: That suggests to me that the implementation might assume it always gets all the rows it asks for, and may raise an exception otherwise. Is that correct? If so, then any change in the number of rows between displays requires not merely that the DataTable page be reset to 1 (assuming page headers), but that the whole DataTable should be replaced for each response if the data is not static. Was that the intent? If DataTable assumes that the number of rows is static, and if the implementers assumed that in the usual case "IDataProvider.iterate(first,count)" would go to the database each time rather than storing data, then isn't there a danger that the total size will change while paging through the data – as other users insert and delete while one traverses the DataTable pages? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Igor Vaynberg Sent: Friday, March 24, 2006 10:41 AM To: wicket-user@lists.sourceforge.net Subject: Re: [Wicket-user] ?Contract for Iterator IDataProvider.iterator(int first, int count) ??? the implementation will trim to size() -Igor On 3/24/06, Frank Silbermann [EMAIL PROTECTED] wrote: To use the Wicket-extensions 1.2 DataTable, we must provide an implementation of IDataProvider. IDataProvider , in turn, requires that we implement int size() and Iterator iterator(int first, int count) If the DataTable is paging data, is it likely that count on the last page will be larger than the result determined by size() – so that we must return count rows or however many remain, whichever is less -- or does the DataTable reduce count on the last page so that first + count never exceeds size()?