Skip to content

Commit

Permalink
Extend MultiValueMode with dedicated support of unsigned_long doc values
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Dec 19, 2024
1 parent 92843d0 commit 94ef877
Show file tree
Hide file tree
Showing 8 changed files with 741 additions and 678 deletions.
12 changes: 12 additions & 0 deletions server/src/main/java/org/opensearch/index/fielddata/FieldData.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ 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
@@ -0,0 +1,78 @@
/*
* 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.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.index.fielddata;

import org.apache.lucene.index.SortedNumericDocValues;

import java.io.IOException;

/**
* Clone of {@link SortedNumericDocValues} for double values.
*
* @opensearch.internal
*/
public final class SingletonSortedNumericUnsignedLongValues extends SortedNumericUnsignedLongValues {
private final SortedNumericDocValues values;

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

@Override
public boolean advanceExact(int target) throws IOException {
return values.advanceExact(target);
}

@Override
public long nextValue() throws IOException {
return values.nextValue();
}

@Override
public int docValueCount() {
return values.docValueCount();
}

public int advance(int target) throws IOException {
return values.advance(target);
}

public int docID() {
return values.docID();
}

/** Return the wrapped values. */
public SortedNumericDocValues getNumericUnsignedLongValues() {
return values;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* 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.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.index.fielddata;

import org.apache.lucene.index.SortedNumericDocValues;
import org.opensearch.common.annotation.PublicApi;

import java.io.IOException;

/**
* Clone of {@link SortedNumericDocValues} for unsigned long values.
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class SortedNumericUnsignedLongValues {

/** Sole constructor. (For invocation by subclass
* constructors, typically implicit.) */
protected SortedNumericUnsignedLongValues() {}

/** Advance the iterator to exactly {@code target} and return whether
* {@code target} has a value.
* {@code target} must be greater than or equal to the current
* doc ID and must be a valid doc ID, ie. &ge; 0 and
* &lt; {@code maxDoc}.*/
public abstract boolean advanceExact(int target) throws IOException;

/**
* Iterates to the next value in the current document. Do not call this more than
* {@link #docValueCount} times for the document.
*/
public abstract long nextValue() throws IOException;

/**
* Retrieves the number of values for the current document. This must always
* be greater than zero.
* It is illegal to call this method after {@link #advanceExact(int)}
* returned {@code false}.
*/
public abstract int docValueCount();

/**
* Advances to the first beyond the current whose document number is greater than or equal to
* <i>target</i>, and returns the document number itself. Exhausts the iterator and returns {@link
* org.apache.lucene.search.DocIdSetIterator#NO_MORE_DOCS} if <i>target</i> is greater than the highest document number in the set.
*
* This method is being used by {@link org.apache.lucene.search.comparators.NumericComparator.NumericLeafComparator} when point values optimization kicks
* in and is implemented by most numeric types.
*/
public int advance(int target) throws IOException {
throw new UnsupportedOperationException();
}

public abstract int docID();
}
Loading

0 comments on commit 94ef877

Please sign in to comment.