-
-
Notifications
You must be signed in to change notification settings - Fork 386
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
Add EffSort, rework ExprInput to use ParserData #6737
Conversation
This reverts commit 20169a1.
and tests!
couldnt we do the sorting async? |
pikachu please you're killing me |
@Pikachu920 we can do the actual sorting asynchronously, but we cannot ensure the expression is safe to evaluate asynchronously, so this would be of limited assistance. Do you think it's still worth adding? |
yes please. I am imagining people will use this for things like "top" listings which might have a lot of elements to sort. I think you have pointed out a larger issue though. anything that uses asynceffect at the moment is probably calling getters async 😖 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super cool. i am wondering if it is a bit confusing to have both a sorting expression and effect? and if we do keep both, does it make sense for ExprFilter to get an effect equivalent?
} | ||
|
||
@Override | ||
public boolean isSingle() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be before return type
Co-authored-by: Patrick Miller <[email protected]>
…into feature/sorted-by
Description
This PR supersedes @Pikachu920's #6342 PR to be more generic and extendable. Syntaxes can now implement InputSource to declare themselves as valid sources of input for ExprInput.
This also adds
input index
as a pattern for ExprInput, which will allow the accessing of a value's index when filtering/sorting a variable list.Also added is EffSort, an effect for sorting variable lists. This effect allows a custom expression to map the values before sorting, so lists can now be sorted in a somewhat custom manner. The sorting is still done with the natural ordering of the mapped values, so this does not current support custom comparators.
If the custom expression has returns a null value at any point, the sort will be aborted and the list will remain the same, as null values cannot be compared. Alternatively, we could just strip out the invalid values, but I think that's a destructive failure state that could result in users losing valuable data if they make a small mistake.
Target Minecraft Versions: any
Requirements: none
Related Issues: #6715 #4327