Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#11506 LazyDataModel: no need to count if first == 0 and lazyData.size #11873

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

cocorossello
Copy link
Contributor

@cocorossello cocorossello commented May 4, 2024

Reopened the PR to see what makes the build fail

Fix #11506

@melloware melloware added the 🐞 defect Bug...Something isn't working label May 5, 2024
@melloware
Copy link
Member

OK good just a single failing test @Rapster

DataTable045Test.selectionMultipleWithPaging:53 expected: <true> but was: <false>

@cocorossello
Copy link
Contributor Author

cocorossello commented May 5, 2024

The problem is in CustomerLazyDataModelNoCountImpl.

I don't think this is correct however it is intentional:

    @Override
    public int count(Map<String, FilterMeta> filterBy) {
        return 0;
    }

Changing it to return datasource.size() works

@tandraschko
Copy link
Member

Return 0 is a supported feature If you check the docs.

@cocorossello
Copy link
Contributor Author

cocorossello commented May 5, 2024

ok, then this should do the trick. The logic should be extracted to a method but I'm not sure on where should I put this this.

Maybe in LazyDataModel, something like


    private void calculateRowCount(List<?> loadedData, Map<String, FilterMeta> filterBy, int rows, int first) {
        if (getRowCount() != 0) {
            return;
        }
        if (data.size() < rows && first == 0) {
            setRowCount(data.size());
        }
        else if (first == 0) {
            setRowCount(count(filterBy));
        }
    }

@tandraschko
Copy link
Member

Maybe we should change the return type of count to a nullable int
Makes it more clear

@cocorossello
Copy link
Contributor Author

cocorossello commented May 6, 2024

That is not possible, LazyDataModel extends javax.faces.model.DataModel and has

public abstract int getRowCount();

@tandraschko
Copy link
Member

tandraschko commented May 6, 2024

I was talking about the count method, Not the getRowCount

To make a difference between not implemented (null) vs zero rows

@melloware
Copy link
Member

It looks like all Integration Tests are passing!

@melloware melloware added ⚡ performance Performance related issue or enhancement and removed 🐞 defect Bug...Something isn't working labels May 7, 2024
@melloware melloware requested a review from tandraschko May 7, 2024 10:44
@Rapster
Copy link
Member

Rapster commented May 7, 2024

I'll have a look later in the week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ performance Performance related issue or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LazyDataModel: no need to count if first == 0 and lazyData.size < pageSize
5 participants