-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling sort optimizatin back for half_float with custom comparators
Signed-off-by: Chaitanya Gohel <[email protected]>
- Loading branch information
Showing
8 changed files
with
324 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
.../java/org/opensearch/index/fielddata/fieldcomparator/HalfFloatValuesComparatorSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.fielddata.fieldcomparator; | ||
|
||
import org.apache.lucene.index.LeafReaderContext; | ||
import org.apache.lucene.index.NumericDocValues; | ||
import org.apache.lucene.search.FieldComparator; | ||
import org.apache.lucene.search.LeafFieldComparator; | ||
import org.opensearch.index.fielddata.IndexNumericFieldData; | ||
import org.opensearch.index.search.comparators.HalfFloatComparator; | ||
import org.opensearch.search.MultiValueMode; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Comparator source for half_float values. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class HalfFloatValuesComparatorSource extends FloatValuesComparatorSource { | ||
public HalfFloatValuesComparatorSource( | ||
IndexNumericFieldData indexFieldData, | ||
Object missingValue, | ||
MultiValueMode sortMode, | ||
Nested nested | ||
) { | ||
super(indexFieldData, missingValue, sortMode, nested); | ||
} | ||
|
||
@Override | ||
public FieldComparator<?> newComparator(String fieldname, int numHits, boolean enableSkipping, boolean reversed) { | ||
assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); | ||
|
||
final float fMissingValue = (Float) missingObject(missingValue, reversed); | ||
// NOTE: it's important to pass null as a missing value in the constructor so that | ||
// the comparator doesn't check docsWithField since we replace missing values in select() | ||
return new HalfFloatComparator(numHits, fieldname, null, reversed, enableSkipping && this.enableSkipping) { | ||
@Override | ||
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException { | ||
return new HalfFloatLeafComparator(context) { | ||
@Override | ||
protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException { | ||
return HalfFloatValuesComparatorSource.this.getNumericDocValues(context, fMissingValue).getRawFloatValues(); | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.