melistik / vaadin-grid-util

simplify the use of vaadin's grid and add features
https://vaadin.com/directory/component/gridutil
MIT License
32 stars 21 forks source link

Custom filter predicate test execution very slow #58

Closed mrtnebrle closed 5 years ago

mrtnebrle commented 5 years ago

I am not certain whether this is an issue with Vaadin or the vaadin-grid-util. Using Vaadin 8.5.2, I have implemented a custom filter as outlined in the demo. The CellFilterComponent#triggerUpdate#replaceFilter and subsequent invocation of CustomFilter#test(T value) is executed in the second range which - at 300 rows in the grid - takes 300 seconds or 5 minutes to render any filter change.

[...]
    final CellFilterComponent<ComboBox<Taxonomy>> taxonomyFilter = new CellFilterComponent<ComboBox<Taxonomy>>() {
         @Override
         public void triggerUpdate() {
                 final Optional<Taxonomy> selectedItem = comboBox.getSelectedItem();
                 if (selectedItem.isPresent()) {
                     filter.replaceFilter(new CustomFilter(selectedItem.get()), COLUMN_IDS.TAXONOMY.name());
                 }
         }
[...}
    };
[...]
    private class CustomFilter implements SerializablePredicate<AdvancedTokenField> {

        private final Long taxonomyId;

        public CustomFilterTaxonomy(final Taxonomy taxonomy) {
            this.taxonomyId = taxonomy.getId();
        }

        @Override
        public boolean test(final AdvancedTokenField tokenField) {
            customFilterIterationCounter++;
            log.info("ListDataProvider has {} items", Integer.valueOf(dataProvider.getItems().size()));
            log.info("Performing predicate iteration #test {} on field {}", Integer.valueOf(customFilterIterationCounter), tokenField.getInputField());
                return false;
        }
    }   
[...]

It appears the #test method is executed infinitely. My ListDataProvider only has 310 rows, still the predicate test continues and never ends.

2019-02-22 08:27:20.236  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:20.236  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 352 on field org.vaadin.alump.searchdropdown.SearchDropDown@56fe6c8
2019-02-22 08:27:20.358  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:20.359  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 353 on field org.vaadin.alump.searchdropdown.SearchDropDown@5b4578a3
2019-02-22 08:27:20.491  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:20.491  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 354 on field org.vaadin.alump.searchdropdown.SearchDropDown@30469d95
2019-02-22 08:27:20.622  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:20.622  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 355 on field org.vaadin.alump.searchdropdown.SearchDropDown@287f8df1
2019-02-22 08:27:20.759  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:20.759  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 356 on field org.vaadin.alump.searchdropdown.SearchDropDown@77b99463
2019-02-22 08:27:20.897  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:20.897  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 357 on field org.vaadin.alump.searchdropdown.SearchDropDown@766f084f
2019-02-22 08:27:21.035  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:21.035  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 358 on field org.vaadin.alump.searchdropdown.SearchDropDown@5b828a1
2019-02-22 08:27:21.173  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : ListDataProvider has 310 items
2019-02-22 08:27:21.173  INFO COMPUTERNAME --- [nio-8080-exec-1] c.d.c.u.c.f.ArtifactsForm                : Performing predicate iteration #test 359 on field org.vaadin.alump.searchdropdown.SearchDropDown@252b793a
mrtnebrle commented 5 years ago

Just figured it is the implementation for AdvancedTokenField and its nested components that is causing the issue.