-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lucene codec after lucene version bumped to 9.12
Signed-off-by: Navneet Verma <[email protected]>
- Loading branch information
Showing
11 changed files
with
241 additions
and
34 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
61 changes: 61 additions & 0 deletions
61
src/main/java/org/opensearch/knn/index/codec/KNN9120Codec/KNN9120Codec.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.KNN9120Codec; | ||
|
||
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.12 | ||
*/ | ||
public class KNN9120Codec extends FilterCodec { | ||
private static final KNNCodecVersion VERSION = KNNCodecVersion.V_9_12_0; | ||
private final KNNFormatFacade knnFormatFacade; | ||
private final PerFieldKnnVectorsFormat perFieldKnnVectorsFormat; | ||
|
||
/** | ||
* No arg constructor that uses Lucene99 as the delegate | ||
*/ | ||
public KNN9120Codec() { | ||
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 KNN9120Codec(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; | ||
} | ||
} |
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
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
Oops, something went wrong.