Feat/permsort #435
No reviewers
Labels
No Label
bug
dependencies
discussion
documentation
duplicate
feature
good first issue
misc
performance
question
test
use case
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kscience/kmath#435
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/permsort"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello,
This PR adds a prototype for permutation sorting. Related issue: #431
This only adds two public extensions:
Buffer<V: Comparable>.permSort()
ColumnarData<Buffer<V : Comparable>>.permSort()
Notes:
I wait for any guidance and feedback to improve the PR.
Thank you,
Ok, so I'll try to fix the branch (I admit I have only launched jvmTest task while working, my mistake).
Before that, do you want me to rebase it over a specific branch (dev ?) ?
Yes, all contributions are made to
dev
.Using a generic ordered index structure seems to be an overengineering. We do not have the aim to cover all data structures like database entities. On the other hand, using custom sequences for indexing significantly impacts performance, which could not be mitigated.
I suggest sticking with Buffers. We can add new functionality by wrapping everything we need in Buffer. The Buffer interface covers any random-access structure.
Other generic question : As I'll rework my PR to provide a single
Buffer<V : Comparable>.permSort()
function, I've got code style/management questions :permSort
andpermSortDescending
?@PerformancePitfall
for now, because standard utilities does not allow to sort indices in-place, so the sorting causes memory-management overhead. Do you think it is appropriate ?I think it is OK
Good question. I am not sure yet. It seems like it is a good idea to pass comparator to the method for non-naturally ordered entities. For naturally ordered it seems to simple enough to reverse the resulting list.
Indeed. We can always remove it later.
You're right. I'll add
fun Buffer<V>.permSortWith(Comparator<V>)
andfun <V, C : Comparable> Buffer<V>permSortBy((V) -> C)
alternatives.For descending, it sounds like a good idea to manage it directly when sorting. If we manage it directly, users don't have to add a manual inversion themselves (which would require an additional O(n/2) cost). Kotlin stdlib rather use separate functions for ascending/descending sorting (surely to make the inversion more explicit). Maybe I should use the same strategy.