Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-13542

Code cleanup - Avoid using stream filter count where possible

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 8.3, 9.0
    • SolrJ
    • None

    Description

      This is another ticket in the logic of https://issues.apache.org/jira/browse/LUCENE-8847

       

      Not a feature, not serious, don't review this when you could be reviewing actual features or critical bugs, don't want to take your time away with this.

       

      Intellij's static code analysis bumped into this.

       

      I also saw most other instances in the code where such a filter needed to happen already used

      anyMatch

      instead of count(). So I applied the suggested fixes. Code cleanup and potentially a small performance gain. As far as my understanding goes, since it is not a simple count that's happening, there's no known size for the evaluator to return and as such it has to iterate over the entire collection. Whereas anyMatch and noneMatch will use the predicate to stop the instance the condition is met.

      It just so happens that all affected instances exist within the SolrJ namespace.

       

      All tests have run, all succeed.

       

      EDIT: Github PR: https://github.com/apache/lucene-solr/pull/717

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            KoenDG Koen De Groote
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m

                Slack

                  Issue deployment