Skip to content

Conversation

@laborg
Copy link
Contributor

@laborg laborg commented Dec 11, 2024

Fix #110

The last chunk wasn't handled properly when resizing, leading to errors downstream in sort, unique! and so on.

# resize individual chunk
resize!(A.arrays[chunk], A.inds[chunk] - len)
A.inds[chunk] -= A.inds[chunk] - len
resize!(A.arrays[chunk], length(A.arrays[chunk]) - (A.inds[chunk] - len))
Copy link
Contributor

Choose a reason for hiding this comment

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

An alternative (unsure what is more readable):

Suggested change
resize!(A.arrays[chunk], length(A.arrays[chunk]) - (A.inds[chunk] - len))
resize!(A.arrays[chunk], chunk == 1 ? len : len - A.inds[chunk - 1])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer branchless code and length should be O(1) in most cases... But its your call.

Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

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

Thanks!

@quinnj quinnj merged commit 96714b2 into JuliaData:main Dec 12, 2024
4 checks passed
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.

Correctness issues and errors after sorting

3 participants