Skip to content

Introduce sorting and distinct operation improvements #1828

@mohamedsamehsalah

Description

@mohamedsamehsalah

Problem

Performing an expensive sort operation on data that will largely be discarded by the subsequent distinct operation should be avoided.

Description of the proposed new feature

  • Support a stylistic preference.
  • Avoid a common gotcha, or potential problem.
  • Improve performance.

I would like to rewrite the following code:

stream.sorted().distinct()
// Rewrite to:
stream.distinct().sorted()
flux.sort().distinct()
// Rewrite to:
flux.distinct().sort()

Considerations

These rewrite rules can be implemented using Refaster by adding new rules to StreamRules and ReactorRules respectively.

Consider the overloads of the sort, sorted, and distinct APIs.

Participation

  • I am willing to submit a pull request to implement this improvement.

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions