Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
benwtrent committed Dec 6, 2024
1 parent 71b87d1 commit bef908c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

import java.util.Iterator;

public class RankVectorsScriptDocValues extends ScriptDocValues<BytesRef> {
public class MultiDenseVectorScriptDocValues extends ScriptDocValues<BytesRef> {

public static final String MISSING_VECTOR_FIELD_MESSAGE = "A document doesn't have a value for a vector field!";

private final int dims;
protected final MultiDenseVectorSupplier dvSupplier;

public RankVectorsScriptDocValues(MultiDenseVectorSupplier supplier, int dims) {
public MultiDenseVectorScriptDocValues(MultiDenseVectorSupplier supplier, int dims) {
super(supplier);
this.dvSupplier = supplier;
this.dims = dims;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static float[] getMultiMagnitudes(BytesRef magnitudes) {

public static void decodeMultiDenseVector(BytesRef vectorBR, int numVectors, float[][] multiVectorValue) {
if (vectorBR == null) {
throw new IllegalArgumentException(RankVectorsScriptDocValues.MISSING_VECTOR_FIELD_MESSAGE);
throw new IllegalArgumentException(MultiDenseVectorScriptDocValues.MISSING_VECTOR_FIELD_MESSAGE);
}
FloatBuffer fb = ByteBuffer.wrap(vectorBR.bytes, vectorBR.offset, vectorBR.length).order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer();
for (int i = 0; i < numVectors; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.ElementType;
import org.elasticsearch.index.mapper.vectors.RankVectorsScriptDocValues;
import org.elasticsearch.index.mapper.vectors.MultiDenseVectorScriptDocValues;

import java.io.IOException;
import java.util.Iterator;
Expand Down Expand Up @@ -63,8 +63,8 @@ public void setNextDocId(int docId) throws IOException {
}

@Override
public RankVectorsScriptDocValues toScriptDocValues() {
return new RankVectorsScriptDocValues(this, dims);
public MultiDenseVectorScriptDocValues toScriptDocValues() {
return new MultiDenseVectorScriptDocValues(this, dims);
}

protected MultiDenseVector getVector() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.ElementType;
import org.elasticsearch.index.mapper.vectors.RankVectorsScriptDocValues;
import org.elasticsearch.index.mapper.vectors.MultiDenseVectorScriptDocValues;

import java.io.IOException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -66,8 +66,8 @@ public void setNextDocId(int docId) throws IOException {
}

@Override
public RankVectorsScriptDocValues toScriptDocValues() {
return new RankVectorsScriptDocValues(this, dims);
public MultiDenseVectorScriptDocValues toScriptDocValues() {
return new MultiDenseVectorScriptDocValues(this, dims);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package org.elasticsearch.script.field.vectors;

import org.elasticsearch.index.mapper.vectors.RankVectorsScriptDocValues;
import org.elasticsearch.index.mapper.vectors.MultiDenseVectorScriptDocValues;
import org.elasticsearch.script.field.AbstractScriptFieldFactory;
import org.elasticsearch.script.field.DocValuesScriptFieldFactory;
import org.elasticsearch.script.field.Field;
Expand All @@ -22,7 +22,7 @@ public abstract class MultiDenseVectorDocValuesField extends AbstractScriptField
implements
Field<MultiDenseVector>,
DocValuesScriptFieldFactory,
RankVectorsScriptDocValues.MultiDenseVectorSupplier {
MultiDenseVectorScriptDocValues.MultiDenseVectorSupplier {
protected final String name;
protected final ElementType elementType;

Expand All @@ -47,7 +47,7 @@ public ElementType getElementType() {

public abstract MultiDenseVector get(MultiDenseVector defaultValue);

public abstract RankVectorsScriptDocValues toScriptDocValues();
public abstract MultiDenseVectorScriptDocValues toScriptDocValues();

// DenseVector fields are single valued, so Iterable does not make sense.
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testFloatGetVectorValueAndGetMagnitude() throws IOException {
ElementType.FLOAT,
dims
);
RankVectorsScriptDocValues scriptDocValues = field.toScriptDocValues();
MultiDenseVectorScriptDocValues scriptDocValues = field.toScriptDocValues();
for (int i = 0; i < vectors.length; i++) {
field.setNextDocId(i);
assertEquals(vectors[i].length, field.size());
Expand Down Expand Up @@ -78,7 +78,7 @@ public void testByteGetVectorValueAndGetMagnitude() throws IOException {
ElementType.BYTE,
dims
);
RankVectorsScriptDocValues scriptDocValues = field.toScriptDocValues();
MultiDenseVectorScriptDocValues scriptDocValues = field.toScriptDocValues();
for (int i = 0; i < vectors.length; i++) {
field.setNextDocId(i);
assertEquals(vectors[i].length, field.size());
Expand Down Expand Up @@ -171,7 +171,7 @@ public void testFloatMissingValues() throws IOException {
ElementType.FLOAT,
dims
);
RankVectorsScriptDocValues scriptDocValues = field.toScriptDocValues();
MultiDenseVectorScriptDocValues scriptDocValues = field.toScriptDocValues();

field.setNextDocId(3);
assertEquals(0, field.size());
Expand All @@ -195,7 +195,7 @@ public void testByteMissingValues() throws IOException {
ElementType.BYTE,
dims
);
RankVectorsScriptDocValues scriptDocValues = field.toScriptDocValues();
MultiDenseVectorScriptDocValues scriptDocValues = field.toScriptDocValues();

field.setNextDocId(3);
assertEquals(0, field.size());
Expand All @@ -219,7 +219,7 @@ public void testFloatGetFunctionIsNotAccessible() throws IOException {
ElementType.FLOAT,
dims
);
RankVectorsScriptDocValues scriptDocValues = field.toScriptDocValues();
MultiDenseVectorScriptDocValues scriptDocValues = field.toScriptDocValues();

field.setNextDocId(0);
Exception e = expectThrows(UnsupportedOperationException.class, () -> scriptDocValues.get(0));
Expand All @@ -245,7 +245,7 @@ public void testByteGetFunctionIsNotAccessible() throws IOException {
ElementType.BYTE,
dims
);
RankVectorsScriptDocValues scriptDocValues = field.toScriptDocValues();
MultiDenseVectorScriptDocValues scriptDocValues = field.toScriptDocValues();

field.setNextDocId(0);
Exception e = expectThrows(UnsupportedOperationException.class, () -> scriptDocValues.get(0));
Expand Down

0 comments on commit bef908c

Please sign in to comment.