-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add Lucene Codec 9.9 Signed-off-by: Naveen Tatikonda <[email protected]> * Fix import statements for Lucene95 Codec Signed-off-by: Naveen Tatikonda <[email protected]> * Fix SegmentInfo Constructor in Test Signed-off-by: Naveen Tatikonda <[email protected]> * Temporarily Ignore Old Codec Tests Signed-off-by: Naveen Tatikonda <[email protected]> * Add CHANGELOG Signed-off-by: Naveen Tatikonda <[email protected]> * Delete Old Codec Tests Signed-off-by: Naveen Tatikonda <[email protected]> --------- Signed-off-by: Naveen Tatikonda <[email protected]> (cherry picked from commit 45e9e54)
- Loading branch information
1 parent
7c65643
commit 7900dbb
Showing
13 changed files
with
142 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/org/opensearch/knn/index/codec/KNN990Codec/KNN990Codec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.codec.KNN990Codec; | ||
|
||
import lombok.Builder; | ||
import org.apache.lucene.codecs.Codec; | ||
import org.apache.lucene.codecs.CompoundFormat; | ||
import org.apache.lucene.codecs.DocValuesFormat; | ||
import org.apache.lucene.codecs.FilterCodec; | ||
import org.apache.lucene.codecs.KnnVectorsFormat; | ||
import org.apache.lucene.codecs.perfield.PerFieldKnnVectorsFormat; | ||
import org.opensearch.knn.index.codec.KNNCodecVersion; | ||
import org.opensearch.knn.index.codec.KNNFormatFacade; | ||
|
||
/** | ||
* KNN Codec that wraps the Lucene Codec which is part of Lucene 9.9 | ||
*/ | ||
public class KNN990Codec extends FilterCodec { | ||
private static final KNNCodecVersion VERSION = KNNCodecVersion.V_9_9_0; | ||
private final KNNFormatFacade knnFormatFacade; | ||
private final PerFieldKnnVectorsFormat perFieldKnnVectorsFormat; | ||
|
||
/** | ||
* No arg constructor that uses Lucene99 as the delegate | ||
*/ | ||
public KNN990Codec() { | ||
this(VERSION.getDefaultCodecDelegate(), VERSION.getPerFieldKnnVectorsFormat()); | ||
} | ||
|
||
/** | ||
* Sole constructor. When subclassing this codec, create a no-arg ctor and pass the delegate codec | ||
* and a unique name to this ctor. | ||
* | ||
* @param delegate codec that will perform all operations this codec does not override | ||
* @param knnVectorsFormat per field format for KnnVector | ||
*/ | ||
@Builder | ||
protected KNN990Codec(Codec delegate, PerFieldKnnVectorsFormat knnVectorsFormat) { | ||
super(VERSION.getCodecName(), delegate); | ||
knnFormatFacade = VERSION.getKnnFormatFacadeSupplier().apply(delegate); | ||
perFieldKnnVectorsFormat = knnVectorsFormat; | ||
} | ||
|
||
@Override | ||
public DocValuesFormat docValuesFormat() { | ||
return knnFormatFacade.docValuesFormat(); | ||
} | ||
|
||
@Override | ||
public CompoundFormat compoundFormat() { | ||
return knnFormatFacade.compoundFormat(); | ||
} | ||
|
||
@Override | ||
public KnnVectorsFormat knnVectorsFormat() { | ||
return perFieldKnnVectorsFormat; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/opensearch/knn/index/codec/KNN990Codec/KNN990PerFieldKnnVectorsFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.codec.KNN990Codec; | ||
|
||
import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat; | ||
import org.opensearch.index.mapper.MapperService; | ||
import org.opensearch.knn.index.codec.BasePerFieldKnnVectorsFormat; | ||
import org.opensearch.knn.index.util.KNNEngine; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Class provides per field format implementation for Lucene Knn vector type | ||
*/ | ||
public class KNN990PerFieldKnnVectorsFormat extends BasePerFieldKnnVectorsFormat { | ||
|
||
public KNN990PerFieldKnnVectorsFormat(final Optional<MapperService> mapperService) { | ||
super( | ||
mapperService, | ||
Lucene99HnswVectorsFormat.DEFAULT_MAX_CONN, | ||
Lucene99HnswVectorsFormat.DEFAULT_BEAM_WIDTH, | ||
() -> new Lucene99HnswVectorsFormat(), | ||
(maxConnm, beamWidth) -> new Lucene99HnswVectorsFormat(maxConnm, beamWidth) | ||
); | ||
} | ||
|
||
@Override | ||
/** | ||
* This method returns the maximum dimension allowed from KNNEngine for Lucene codec | ||
* | ||
* @param fieldName Name of the field, ignored | ||
* @return Maximum constant dimension set by KNNEngine | ||
*/ | ||
public int getMaxDimensions(String fieldName) { | ||
return KNNEngine.getMaxDimensionByEngine(KNNEngine.LUCENE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
src/test/java/org/opensearch/knn/index/codec/KNN910Codec/KNN910CodecTests.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
src/test/java/org/opensearch/knn/index/codec/KNN920Codec/KNN920CodecTests.java
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
src/test/java/org/opensearch/knn/index/codec/KNN940Codec/KNN940CodecTests.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters