Avoid eagerly calling DataProvider.size() when client-side filter cannot be used #222
Comments
I'm not sure I understand the ticket.
Does it mean that you want to configure somehow at what time At the moment it looks as a too generic request and you may configure this via providing your own So please provide exact request via API contract. |
The use case is quite clear: if the same view contains many combo boxes that all depend on relatively expensive database queries to find the size, then rendering performance will suffer for not good reason. The reason it's implemented to eagerly do As can be seen from the quoted code snippet, that kind of optimisation is not even considered in cases when filtering cannot happen on the client, which is always the case if a lazy data provider is used. I'm not sure we'd even need any new API for this case. Just changing the quoted logic so that |
The ticket title is : The optimization of |
@Legioth @denis-anisimov I am just not 100% sure I completely understood the architecture. As far as I can see So I assume the following code would be needed for the method mentioned in the original post:
(or better for |
Client-side filtering is used whenever feasible. It requires these three conditions to be true:
|
Now it is not called when using a lazy data provider, because - the size is used to check if client-side filtering can be used - lazy data providers always handle filtering in server-side anyway Fix #222
If I understood correctly, @Juchar just wants to avoid this expensive call to Like @Legioth pointed out, server-side filtering is forced when using a lazy data provider, so the size-comparison is not needed. I made the suggested change and marked it to close the issue: #230 |
Now it is not called when using a lazy data provider, because - the size is used to check if client-side filtering can be used - lazy data providers always handle filtering in server-side anyway Fix #222
Now it is not called when using a lazy data provider, because - the size is used to check if client-side filtering can be used - lazy data providers always handle filtering in server-side anyway Fix #222
Now it is not called when using a lazy data provider, because - the size is used to check if client-side filtering can be used - lazy data providers always handle filtering in server-side anyway Fix #222
Unfortunately the public class MainView extends VerticalLayout {
public MainView() {
ComboBox<String> comboBox = new ComboBox<>("Callbacks");
comboBox.setDataProvider((filter, offset, limit) -> getItems(), s -> getSize());
add(comboBox);
}
private int getSize() {
return 2;
}
private Stream<String> getItems() {
return Stream.of("1", "2");
}
} As far as I have analysed this call to Thank you already! |
The call for I guess that initializing the I created a new ticket #242 |
@pekam Thank you for your analysis! |
It would be nice to be able to specify when the call to the
size()
method happens.Right now, it immediately happens as soon as the dataprovider is set:
I would expect it to happen as soon as the dropdown popup is opened for the first time.
This would be especially useful in the situations where multiple ComboBoxes are added inside a form.
Using the current approach the user would have to wait until all the
size()
calls are done.Additionally, if the user ust keeps the page open and comes back after some Minutes the size might be obsolete I assume.
Also it sometimes happens that the backend does not expose a proper
size()
call and unfortunately you have to load the full data right away. Also there it would be useful to be able to decide if the data get's loaded once the user opens the popup.Best case would be if the call to
size()
would somehow happen asynchronously and the UI does not have to wait.Am I overseeing something?
The text was updated successfully, but these errors were encountered: