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

Unify ZQuery.foreach implementations and cleanups #469

Merged

Conversation

kyri-petrou
Copy link
Collaborator

The main change in this PR is that we unify the implementation for foreach, foreachPar and foreachBatched. This way, the foreach and foreachPar methods can take advantage of the optimizations that were done in #457.

The other somewhat big change is adding a dependency on scala-collection-compat. I was a bit divided about this at first, but I think it's likely for the best as I kept finding myself having to write workarounds for missing constructors / methods in Scala 2.12.

} else
Promise.makeAs[E, B](fiberId).map { promise =>
} else {
ZIO.succeed {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why this change? Isn't Promise.makeAs doing the same thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when using Promise.makeAs we have to use .map afterwards (which is an extra flatMap). Since this is run for every ZQuery.fromRequest, I think it's worth to use the unsafe method in order to reduce the overall number of flatMaps in the query

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I missed that

ghostdogpr
ghostdogpr previously approved these changes Apr 7, 2024
@kyri-petrou kyri-petrou merged commit 33e1054 into zio:series/2.x Apr 7, 2024
26 checks passed
@kyri-petrou kyri-petrou deleted the unify-zquery-foreach-implementations branch April 7, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants