[
https://issues.apache.org/jira/browse/SOLR-11132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jason Gerlowski updated SOLR-11132:
-----------------------------------
Attachment: SOLR-11132.patch
The change worked out pretty much just as you suggested. Was able to kill a
lot of duplication.
Tests and precommit pass.
> Refactor common getSortField logic in various FieldTypes
> --------------------------------------------------------
>
> Key: SOLR-11132
> URL: https://issues.apache.org/jira/browse/SOLR-11132
> Project: Solr
> Issue Type: Improvement
> Security Level: Public(Default Security Level. Issues are Public)
> Reporter: Hoss Man
> Assignee: Hoss Man
> Attachments: SOLR-11132.patch
>
>
> This pattern exists a lot w/ some minor fluxuations in copy/paste variation...
> {code}
> @Override
> public SortField getSortField(SchemaField field, boolean top) {
> field.checkSortability();
> Object missingValue = null;
> boolean sortMissingLast = field.sortMissingLast();
> boolean sortMissingFirst = field.sortMissingFirst();
> if (sortMissingLast) {
> missingValue = top ? SOMECLASS.MIN_VALUE : SOMECLASS.MAX_VALUE;
> } else if (sortMissingFirst) {
> missingValue = top ? SOMECLASS.MAX_VALUE : SOMECLASS.MIN_VALUE;
> }
> SortField sf = new SortField(field.getName(), SortField.Type.SOMETYPE,
> top);
> sf.setMissingValue(missingValue);
> return sf;
> }
> {code}
> We should refactor it into a helper method along the lines of...
> {code}
> @Override
> public static SortField getSortField(SchemaField field, boolean top,
> SortField.Type sortType,
> Object missingLow, Object missingHigh)
> {
> field.checkSortability();
> Object missingValue = null;
> boolean sortMissingLast = field.sortMissingLast();
> boolean sortMissingFirst = field.sortMissingFirst();
> if (sortMissingLast) {
> missingValue = top ? missingLow : missingHigh;
> } else if (sortMissingFirst) {
> missingValue = top ? missingHigh : missingLow;
> }
> SortField sf = new SortField(field.getName(), sortType, top);
> sf.setMissingValue(missingValue);
> return sf;
> }
> {code}
> So it can be re-used via...
> {code}
> @Override
> public SortField getSortField(SchemaField field, boolean top) {
> return getSortField(field, top, SortField.Type.SOMETIME,
> SOMECLASS.MIN_VALUE, SOMECLASS.MAX_VALUE);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]