The following comment has been added to this issue: Author: James Schopp Created: Thu, 14 Oct 2004 5:10 PM Body: We have implemented data-level pagination by creating a smart lists backed by a database. While iterating over the list, it can load and unload records as necessary to save memory.
I have run into the same probelm with DisplayTag since it iterates over the entire list (causing the entire dataset to be loaded up) even if you only want to view some small subset on page, say, 100. I have not yet made any modifications to the source, but I think the changes you mentioned plus the "lazy list" I have created could solve the problem. --------------------------------------------------------------------- View this comment: http://jira.codehaus.org/browse/DISPL-19?page=comments#action_25383 --------------------------------------------------------------------- View the issue: http://jira.codehaus.org/browse/DISPL-19 Here is an overview of the issue: --------------------------------------------------------------------- Key: DISPL-19 Summary: Pagination - use subList instead of iterating all records Type: Improvement Status: Unassigned Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: DisplayTag Components: Tag Library Versions: 1.0 RC2 Assignee: Reporter: fabrizio giustina Created: Sat, 25 Sep 2004 5:17 AM Updated: Thu, 14 Oct 2004 5:10 PM Description: ==== imported from sf tracker id 1023387 submitted by Ian Barnett - ianbdev http://sourceforge.net/tracker/index.php?func=detail&group_id=73068&atid=536613&aid=1023387 ==== The code that obtains a subset of records from the List object (which is the subject of the display table) iterates through all the records in the list until it finds the ones it requires. This is no problem for small lists where the subset might be page 2 as 21-40 for example as only 20 records are skipped during iteration. But when the lists are very large (for example 20,000 records) and the page is a high numbered page (e.g. page 9001, records 18001-18021) the iteration is very expensive as it must iterate through and skip over 18,000 records just to get to the first record. We have a simple modified verision of SmartListHelp.java (based on the 1.0rc-1 library) that does not iterate through unwanted records but rather uses the List interface's subList method to retrieve only the records required. Then it is up to the application developer to either burden the list with all (for example 20,000) records or implement a List class that provides a subList method that intelligently retrieves only the records required from the List's datasource (e.g. may only grab 20 records at a time for the database). This is a very lightweight solution to the calls for improved long list pagination that has a low impact on the Display Tag code base. Below is the current code for paginated record retrieval: /** * Returns a subsection of the list that contains just the elements that are supposed to be shown on the given page. * @param pageNumber page number * @return List subsection of the list that contains just the elements that are supposed to be shown on the given * page */ protected List getListForPage(int pageNumber) { log.debug("getListForPage page=" + pageNumber); List list = new ArrayList(this.pageSize + 1); int firstIndex = getFirstIndexForPage(pageNumber); int lastIndex = getLastIndexForPage(pageNumber); Iterator iterator = this.fullList.iterator(); int j = 0; while (iterator.hasNext()) { Object object = iterator.next(); if (j > lastIndex) { break; } else if (j >= firstIndex) { list.add(object); } j++; } return list; } The recommended fix is: protected List getListForPage(int pageNumber) { log.debug("getListForPage page=" + pageNumber); int firstIndex = getFirstIndexForPage(pageNumber); int lastIndex = getLastIndexForPage(pageNumber); return fullList.subList(firstIndex, lastIndex+1); } --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ displaytag-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/displaytag-devel