Skip to content

Commit

Permalink
Making indexFieldData provate in FloatValuesComparatorSource
Browse files Browse the repository at this point in the history
Signed-off-by: Chaitanya Gohel <[email protected]>
  • Loading branch information
gashutos committed Oct 31, 2023
1 parent 4eefa77 commit 41cba16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
*/
public class FloatValuesComparatorSource extends IndexFieldData.XFieldComparatorSource {

protected final IndexNumericFieldData indexFieldData;
private final IndexNumericFieldData indexFieldData;

public FloatValuesComparatorSource(
IndexNumericFieldData indexFieldData,
Expand All @@ -78,7 +78,7 @@ public SortField.Type reducedType() {
return SortField.Type.FLOAT;
}

protected NumericDoubleValues getNumericDocValues(LeafReaderContext context, float missingValue) throws IOException {
private NumericDoubleValues getNumericDocValues(LeafReaderContext context, float missingValue) throws IOException {
final SortedNumericDoubleValues values = indexFieldData.load(context).getDoubleValues();
if (nested == null) {
return FieldData.replaceMissing(sortMode.select(values), missingValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.LeafFieldComparator;
import org.apache.lucene.util.BitSet;
import org.opensearch.index.fielddata.FieldData;
import org.opensearch.index.fielddata.IndexNumericFieldData;
import org.opensearch.index.fielddata.NumericDoubleValues;
import org.opensearch.index.fielddata.SortedNumericDoubleValues;
import org.opensearch.index.search.comparators.HalfFloatComparator;
import org.opensearch.search.MultiValueMode;

Expand All @@ -24,13 +29,16 @@
* @opensearch.internal
*/
public class HalfFloatValuesComparatorSource extends FloatValuesComparatorSource {
private final IndexNumericFieldData indexFieldData;

public HalfFloatValuesComparatorSource(
IndexNumericFieldData indexFieldData,
Object missingValue,
MultiValueMode sortMode,
Nested nested
) {
super(indexFieldData, missingValue, sortMode, nested);
this.indexFieldData = indexFieldData;
}

@Override
Expand All @@ -52,4 +60,16 @@ protected NumericDocValues getNumericDocValues(LeafReaderContext context, String
}
};
}

private NumericDoubleValues getNumericDocValues(LeafReaderContext context, float missingValue) throws IOException {
final SortedNumericDoubleValues values = indexFieldData.load(context).getDoubleValues();
if (nested == null) {
return FieldData.replaceMissing(sortMode.select(values), missingValue);
} else {
final BitSet rootDocs = nested.rootDocs(context);
final DocIdSetIterator innerDocs = nested.innerDocs(context);
final int maxChildren = nested.getNestedSort() != null ? nested.getNestedSort().getMaxChildren() : Integer.MAX_VALUE;
return sortMode.select(values, missingValue, rootDocs, innerDocs, context.reader().maxDoc(), maxChildren);
}
}
}

0 comments on commit 41cba16

Please sign in to comment.