You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "romseygeek (via GitHub)" <gi...@apache.org> on 2025/12/05 16:55:11 UTC
[I] Make SortField immutable [lucene]
romseygeek opened a new issue, #15480:
URL: https://github.com/apache/lucene/issues/15480
### Description
`Sort` objects are shallowly immutable, but their inner `SortField` implementations are not, which could cause hard-to-track down bugs. We should make `SortField` immutable as well.
The `field`, `type` and `reverse` fields can be made final with no change in API. Missing values are trickier, as they are currently mutable via a `setMissingValue` method. My suggestion would be to deprecate this method in 10.4, and add constructors that explicitly take missing values (which could also enhance type safety); and then remove the method in 11.0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] Make SortField immutable [lucene]
Posted by "romseygeek (via GitHub)" <gi...@apache.org>.
romseygeek commented on issue #15480:
URL: https://github.com/apache/lucene/issues/15480#issuecomment-3674775395
The one remaining non-final method is `comparatorSource` which is only used by custom sorts. Given the tight coupling between `SortField.Type` and the comparator factory methods, I wonder if it makes sense to set `comparatorSource` for all types and add some basic factory methods to the various different FieldComparator implementations. Then `SortField.getComparator()` just becomes a simple call to `comparatorSource.getComparator()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] Make SortField immutable [lucene]
Posted by "SYEDMDSAAD (via GitHub)" <gi...@apache.org>.
SYEDMDSAAD commented on issue #15480:
URL: https://github.com/apache/lucene/issues/15480#issuecomment-3927142312
@romseygeek That makes sense — moving the comparator creation logic out of `SortField` would both simplify `getComparator()` and avoid type-based mutation paths.
Before I start prototyping, should this issue aim for a full delegation model (all types backed by a `FieldComparatorSource`), or would you prefer an incremental step first (e.g., making existing state final and then refactoring comparator creation in follow-ups)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org