ZK Huge Grouping Model
Robert Wenzel, Engineer, Potix Corporation
August, 2013
ZK 6.5 (or later)
Introduction
bla bla you have some big data... how to display
article already handles display big data in a flat list http://books.zkoss.org/wiki/Small_Talks/2009/July/Handling_huge_data_using_ZK
based on the concepts (paging at DB level, separate paging control from grid) there how to do grouping...
The challenges
grouping is a powerful feature in ZK but also adds an extra layer of complexity
paging and grouping challenges
1. groups can be open or closed (also interactively)
- -> the total count and the number of pages changes, when opening/closing nodes... (needs efficient counting, and state keeping)
2. groups can have arbitrary number of children
- -> random access to a specific page ... how to know the current group and position inside the group for that page
- --> implement a feaseable search
3. minimize DB operations (accumulating network/DB latency)
- -> caching vs. memory consumption
1. + 2. + 3. !!!! combining all three in an efficient, memory preserving way
limitations... needs to store the state in memory (humans are limited, so one is unlikely to toggle 100+ groups)
Maxing out what is possible... ZK GroupsModel supports int indexes so go up to Integer.MAX_VALUE (~ 2.000.000.000 records)
not unrealistic -> Hibernate have changed their paging api to long already...
Implementation
Generating the Test data
not use DB, just deterministic random value... caching the group sizes in memory e.g. 400.000.000 of groups child counts stored in an int[] are still 160 MB of memory
record
package org.zkoss.grouping.dao;
import java.util.Date;
public class AccessDataRecord {
private String ipAddress;
private String browser;
private long contentLength;
private String country;
private Date accessTime;
private String url;
//... Constructor + getters
Counting & State keeping
Random Access Paging
Appendix
Download
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |