Skip to content

Commit

Permalink
renames and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHegarty committed May 3, 2024
1 parent 8c6ab61 commit fd47ee5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.hnsw.RandomAccessVectorValues;

final class DotProduct extends MemorySegmentByteVectorScorerSupplier {
final class DotProductByteVectorScorerSupplier extends MemorySegmentByteVectorScorerSupplier {

DotProduct(
DotProductByteVectorScorerSupplier(
int dims, int maxOrd, int vectorByteSize, IndexInput input, RandomAccessVectorValues values) {
super(dims, maxOrd, vectorByteSize, input, values);
}
Expand All @@ -35,7 +35,8 @@ public float score(int node) throws IOException {
}

@Override
public DotProduct copy() throws IOException {
return new DotProduct(dims, maxOrd, vectorByteSize, input.clone(), values);
public DotProductByteVectorScorerSupplier copy() throws IOException {
return new DotProductByteVectorScorerSupplier(
dims, maxOrd, vectorByteSize, input.clone(), values);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.hnsw.RandomAccessVectorValues;

final class Euclidean extends MemorySegmentByteVectorScorerSupplier {
final class EuclideanByteVectorScorerSupplier extends MemorySegmentByteVectorScorerSupplier {

Euclidean(
EuclideanByteVectorScorerSupplier(
int dims, int maxOrd, int vectorByteSize, IndexInput input, RandomAccessVectorValues values) {
super(dims, maxOrd, vectorByteSize, input, values);
}
Expand All @@ -34,7 +34,8 @@ public float score(int node) throws IOException {
}

@Override
public Euclidean copy() throws IOException {
return new Euclidean(dims, maxOrd, vectorByteSize, input.clone(), values);
public EuclideanByteVectorScorerSupplier copy() throws IOException {
return new EuclideanByteVectorScorerSupplier(
dims, maxOrd, vectorByteSize, input.clone(), values);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

/** A scorer of vectors whose element size is byte. */
public abstract sealed class MemorySegmentByteVectorScorerSupplier
implements RandomVectorScorerSupplier, RandomVectorScorer permits DotProduct, Euclidean {
implements RandomVectorScorerSupplier, RandomVectorScorer
permits DotProductByteVectorScorerSupplier, EuclideanByteVectorScorerSupplier {
final int vectorByteSize;
final int dims;
final int maxOrd;
Expand Down Expand Up @@ -59,8 +60,10 @@ public static Optional<MemorySegmentByteVectorScorerSupplier> create(
}
checkInvariants(maxOrd, vectorByteSize, input);
return switch (type) {
case DOT_PRODUCT -> Optional.of(new DotProduct(dims, maxOrd, vectorByteSize, input, values));
case EUCLIDEAN -> Optional.of(new Euclidean(dims, maxOrd, vectorByteSize, input, values));
case DOT_PRODUCT -> Optional.of(
new DotProductByteVectorScorerSupplier(dims, maxOrd, vectorByteSize, input, values));
case EUCLIDEAN -> Optional.of(
new EuclideanByteVectorScorerSupplier(dims, maxOrd, vectorByteSize, input, values));
case MAXIMUM_INNER_PRODUCT -> Optional.empty(); // TODO: implement MAXIMUM_INNER_PRODUCT
case COSINE -> Optional.empty(); // TODO: implement Cosine
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.lucene.tests.store.BaseDirectoryWrapper;
import org.apache.lucene.tests.store.MockDirectoryWrapper;

@com.carrotsearch.randomizedtesting.annotations.Repeat(iterations = 100)
public class TestKnnByteVectorQueryMMap extends TestKnnByteVectorQuery {

@Override
Expand Down

0 comments on commit fd47ee5

Please sign in to comment.