Skip to content

Optimise fromEnriched function #227

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

Closed
chuwy opened this issue Aug 9, 2021 · 0 comments
Closed

Optimise fromEnriched function #227

chuwy opened this issue Aug 9, 2021 · 0 comments

Comments

@chuwy
Copy link
Contributor

chuwy commented Aug 9, 2021

def fromEnriched(inputs: List[Result]): Batch[List[Result]] = {
val earliest = Common.getEarliestTstamp(inputs)
val count = inputs.length
Batch(Meta(earliest, count), inputs)
}

Currently it does multiple linked list traversals that can be reduced into one:

  1. flatMap traversal to get all timestamps
  2. Sorting which is even worse than plain traversal
  3. Length-calculation which can be fused into main traversal

We can have a single fold instead of above three.

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

No branches or pull requests

1 participant