Skip to content

Commit

Permalink
Replace SingletonSortedNumericUnsignedLongValues with LongToSortedNum…
Browse files Browse the repository at this point in the history
…ericUnsignedLongValues (as per review comments)

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Jan 2, 2025
1 parent cfbf241 commit bbb1858
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
19 changes: 0 additions & 19 deletions server/src/main/java/org/opensearch/index/fielddata/FieldData.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,6 @@ public static SortedNumericDocValues castToLong(final SortedNumericDoubleValues
}
}

/**
* Returns a multi-valued view over the provided {@link NumericDoubleValues}.
*/
public static SortedNumericUnsignedLongValues singleton(SortedNumericDocValues values) {
return new SingletonSortedNumericUnsignedLongValues(values);
}

/**
* Returns a multi-valued view over the provided {@link NumericDoubleValues}.
*/
Expand All @@ -318,18 +311,6 @@ public static NumericDoubleValues unwrapSingleton(SortedNumericDoubleValues valu
return null;
}

/**
* Returns a single-valued view of the {@link SortedNumericDoubleValues},
* if it was previously wrapped with {@link DocValues#singleton(NumericDocValues)},
* or null.
*/
public static SortedNumericDocValues unwrapSingleton(SortedNumericUnsignedLongValues values) {
if (values instanceof SingletonSortedNumericUnsignedLongValues) {
return ((SingletonSortedNumericUnsignedLongValues) values).getNumericUnsignedLongValues();
}
return null;
}

/**
* Returns a multi-valued view over the provided {@link GeoPointValues}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
import java.io.IOException;

/**
* Exposes multi-valued view over a single-valued instance.
* <p>
* This can be used if you want to have one multi-valued implementation
* that works for single or multi-valued types.
* Wraps long-based {@link SortedNumericDocValues} as unsigned long ones
* (primarily used by {@link org.opensearch.search.MultiValueMode}
*
* @opensearch.internal
*/

final class SingletonSortedNumericUnsignedLongValues extends SortedNumericUnsignedLongValues {
public final class LongToSortedNumericUnsignedLongValues extends SortedNumericUnsignedLongValues {
private final SortedNumericDocValues values;

SingletonSortedNumericUnsignedLongValues(SortedNumericDocValues values) {
public LongToSortedNumericUnsignedLongValues(SortedNumericDocValues values) {
this.values = values;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.opensearch.index.fielddata.IndexFieldData;
import org.opensearch.index.fielddata.IndexNumericFieldData;
import org.opensearch.index.fielddata.LeafNumericFieldData;
import org.opensearch.index.fielddata.LongToSortedNumericUnsignedLongValues;
import org.opensearch.index.fielddata.SortedNumericUnsignedLongValues;
import org.opensearch.index.search.comparators.UnsignedLongComparator;
import org.opensearch.search.DocValueFormat;
Expand Down Expand Up @@ -59,7 +60,7 @@ public SortField.Type reducedType() {

private SortedNumericUnsignedLongValues loadDocValues(LeafReaderContext context) {
final LeafNumericFieldData data = indexFieldData.load(context);
return FieldData.singleton(data.getLongValues());
return new LongToSortedNumericUnsignedLongValues(data.getLongValues());
}

private NumericDocValues getNumericDocValues(LeafReaderContext context, BigInteger missingValue) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.opensearch.index.fielddata.AbstractNumericDocValues;
import org.opensearch.index.fielddata.AbstractSortedDocValues;
import org.opensearch.index.fielddata.FieldData;
import org.opensearch.index.fielddata.LongToSortedNumericUnsignedLongValues;
import org.opensearch.index.fielddata.NumericDoubleValues;
import org.opensearch.index.fielddata.SortedBinaryDocValues;
import org.opensearch.index.fielddata.SortedNumericDoubleValues;
Expand Down Expand Up @@ -1240,7 +1241,11 @@ protected int pick(SortedDocValues values, DocIdSetIterator docItr, int startDoc
* Allowed Modes: SUM, AVG, MEDIAN, MIN, MAX
*/
public NumericDocValues select(final SortedNumericUnsignedLongValues values) {
final SortedNumericDocValues sortedNumericDocValues = FieldData.unwrapSingleton(values);
SortedNumericDocValues sortedNumericDocValues = null;
if (values instanceof LongToSortedNumericUnsignedLongValues) {
sortedNumericDocValues = ((LongToSortedNumericUnsignedLongValues) values).getNumericUnsignedLongValues();
}

final NumericDocValues singleton = DocValues.unwrapSingleton(sortedNumericDocValues);
if (singleton != null) {
return singleton;
Expand Down

0 comments on commit bbb1858

Please sign in to comment.