mirror of https://github.com/apache/lucene.git
Make KnnVectorsFormat#getMaxDimensions abstract (#12466)
- Backward codecs use 1024 as max dims - Test classes use the current KnnVectorsFormat#DEFAULT_MAX_DIMENSIONS Relates to PR#12436 Closes #12309
This commit is contained in:
parent
98320d7616
commit
119635ad80
|
@ -120,6 +120,11 @@ public class Lucene90HnswVectorsFormat extends KnnVectorsFormat {
|
|||
return new Lucene90HnswVectorsReader(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getMaxDimensions(String fieldName) {
|
||||
return 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Lucene90HnswVectorsFormat(name = Lucene90HnswVectorsFormat, maxConn = "
|
||||
|
|
|
@ -136,6 +136,11 @@ public class Lucene91HnswVectorsFormat extends KnnVectorsFormat {
|
|||
return new Lucene91HnswVectorsReader(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getMaxDimensions(String fieldName) {
|
||||
return 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Lucene91HnswVectorsFormat(name = Lucene91HnswVectorsFormat, maxConn = "
|
||||
|
|
|
@ -149,6 +149,11 @@ public class Lucene92HnswVectorsFormat extends KnnVectorsFormat {
|
|||
return new Lucene92HnswVectorsReader(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getMaxDimensions(String fieldName) {
|
||||
return 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Lucene92HnswVectorsFormat(name = Lucene92HnswVectorsFormat, maxConn = "
|
||||
|
|
|
@ -155,6 +155,11 @@ public class Lucene94HnswVectorsFormat extends KnnVectorsFormat {
|
|||
return new Lucene94HnswVectorsReader(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getMaxDimensions(String fieldName) {
|
||||
return 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Lucene94HnswVectorsFormat(name=Lucene94HnswVectorsFormat, maxConn="
|
||||
|
|
|
@ -47,6 +47,11 @@ public final class SimpleTextKnnVectorsFormat extends KnnVectorsFormat {
|
|||
return new SimpleTextKnnVectorsReader(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDimensions(String fieldName) {
|
||||
return KnnVectorsFormat.DEFAULT_MAX_DIMENSIONS;
|
||||
}
|
||||
|
||||
/** Extension of vectors data file */
|
||||
static final String VECTOR_EXTENSION = "vec";
|
||||
|
||||
|
|
|
@ -83,14 +83,12 @@ public abstract class KnnVectorsFormat implements NamedSPILoader.NamedSPI {
|
|||
* Returns the maximum number of vector dimensions supported by this codec for the given field
|
||||
* name
|
||||
*
|
||||
* <p>Codecs should override this method to specify the maximum number of dimensions they support.
|
||||
* <p>Codecs implement this method to specify the maximum number of dimensions they support.
|
||||
*
|
||||
* @param fieldName the field name
|
||||
* @return the maximum number of vector dimensions.
|
||||
*/
|
||||
public int getMaxDimensions(String fieldName) {
|
||||
return DEFAULT_MAX_DIMENSIONS;
|
||||
}
|
||||
public abstract int getMaxDimensions(String fieldName);
|
||||
|
||||
/**
|
||||
* EMPTY throws an exception when written. It acts as a sentinel indicating a Codec that does not
|
||||
|
@ -140,5 +138,10 @@ public abstract class KnnVectorsFormat implements NamedSPILoader.NamedSPI {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDimensions(String fieldName) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -263,6 +263,11 @@ public class TestPerFieldKnnVectorsFormat extends BaseKnnVectorsFormatTestCase {
|
|||
public KnnVectorsReader fieldsReader(SegmentReadState state) throws IOException {
|
||||
return delegate.fieldsReader(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDimensions(String fieldName) {
|
||||
return KnnVectorsFormat.DEFAULT_MAX_DIMENSIONS;
|
||||
}
|
||||
}
|
||||
|
||||
private static class KnnVectorsFormatMaxDims32 extends KnnVectorsFormat {
|
||||
|
|
|
@ -54,6 +54,11 @@ public class AssertingKnnVectorsFormat extends KnnVectorsFormat {
|
|||
return new AssertingKnnVectorsReader(delegate.fieldsReader(state), state.fieldInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDimensions(String fieldName) {
|
||||
return KnnVectorsFormat.DEFAULT_MAX_DIMENSIONS;
|
||||
}
|
||||
|
||||
static class AssertingKnnVectorsWriter extends KnnVectorsWriter {
|
||||
final KnnVectorsWriter delegate;
|
||||
|
||||
|
|
Loading…
Reference in New Issue