Please anyone with permissions correct that horrible “freezed” typo to frozen, as I cannot change the title.
I have a Grid being populated from an SQLContainer with nearly 25000 rows.
When I scroll down (looks to me as it happens when I surpass some item limit / offset from the “lazy loading” method), the
Grid gets its rows blank and the loading blue bar on top starts growing, but it never ends “growing” - so, in the end, the Grid doesn’t get updated and the program gets stuck (I can still scroll on the Grid but no content is loaded, and I cannot navigate through the application until I stop the server or close the tab and it reaches its timeout).
Trying to figure out what the heck happens, I placed several breakpoints in strategic places. During the “hanged” state I have plenty time to disable / reenable the breakpoints and it will still stop there. It’s like the operation that calculates the LIMIT and/or OFFSET for the next iteration makes the number of fetched items APPROACHES a limit wich is the total number of rows, but ¿never reaches it?, with this limit approaching slower and slower each time.
Also this seems more prone to happen when I drag the scroll bar quickly to the middle or the 3rd lower part of the grid than if I scroll “slowly” with the mouse wheel.
Anyway, here there go the “favourite breakpoints” where it uses to stop and/or the “suspicious” parts in the code I’ve found:
SQLContainer.java:
Method indexOfId(Object itemId), line 660:
// this protects against infinite looping
int counter = 0;
int oldIndex;
-> while (counter < size) { <-
if (itemIndexes.containsValue(itemId)) {
for (Integer idx : itemIndexes.keySet()) {
if (itemIndexes.get(idx).equals(itemId)) {
return idx;
}
}
}
"
Counter
" approaches "
size
" but in my debugging sessions never seems to reach it.
Method updateOffsetAndCache(int index):
currentOffset
grows veeeeery slowly (?)
Method getPage():
pageLength is 100 – sound like a very small size to me. Where can this be changed?
CACHE_RATIO is 2 – same as above.
cacheOverlap is 100 – is this normal?
This 3 parameters are used for calculating the fetchedRows amount, which is 300 - again, it looks to me like a too small size.
Then there is a call to queryDelegate.getResults(currentOffset, fetchedRows);
My implemented getQueryStatemente, which is common for all classes as it lies in an Abstract class, does someething like the following:
public StatementHelper getQueryStatement(int offset, int limit) throws UnsupportedOperationException {
StatementHelper helper = new StatementHelper();
String query = this.consulta;
if(filters != null){ // afegir && !isEmpty() també??
query += QueryBuilder.getWhereStringForFilters(filters, helper);
}
query += getOrderByString();
if (offset != 0 || limit != 0) {
query += " LIMIT " + limit;
query += " OFFSET " + offset;
}
helper.setQueryString(query);
return helper;
}
Is maybe some sort of bug there I cannot identify? I got the inspiration for this method from here and there - mainly recommendations from this forum…
Please forgive my lack of clearness in this question but I’m already lost enough to be more concise…