Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
PostingsFormat Fix for odfe 1.9 (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
vamshin authored Oct 14, 2020
1 parent 68fd4d0 commit 9295b31
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class KNN84Codec extends Codec {
private final DocValuesFormat perFieldDocValuesFormat;
private final CompoundFormat compoundFormat;
private Codec lucene84Codec;
private PostingsFormat postingsFormat = null;

public static final String KNN_84 = "KNN84Codec";
public static final String LUCENE_84 = "Lucene84"; // Lucene Codec to be used
Expand Down Expand Up @@ -82,9 +83,16 @@ public DocValuesFormat docValuesFormat() {
* approach of manually overriding.
*/

public void setPostingsFormat(PostingsFormat postingsFormat) {
this.postingsFormat = postingsFormat;
}

@Override
public PostingsFormat postingsFormat() {
return getDelegatee().postingsFormat();
if (this.postingsFormat == null) {
return getDelegatee().postingsFormat();
}
return this.postingsFormat;
}

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

package com.amazon.opendistroforelasticsearch.knn.plugin;

import com.amazon.opendistroforelasticsearch.knn.index.codec.KNN84Codec.KNN84Codec;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.PostingsFormat;
import org.elasticsearch.index.codec.CodecService;

import static com.amazon.opendistroforelasticsearch.knn.index.codec.KNN84Codec.KNN84Codec.KNN_84;
Expand All @@ -35,7 +37,7 @@ class KNNCodecService extends CodecService {
* return the KNN Codec
*
* @param name dummy name
* @return KNN80Codec
* @return KNN84Codec
*/
@Override
public Codec codec(String name) {
Expand All @@ -45,4 +47,9 @@ public Codec codec(String name) {
}
return codec;
}

public void setPostingsFormat(PostingsFormat postingsFormat) {
((KNN84Codec)codec("")).setPostingsFormat(postingsFormat);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.amazon.opendistroforelasticsearch.knn.plugin;

import org.elasticsearch.index.codec.CodecService;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.engine.EngineConfig;
import org.elasticsearch.index.engine.EngineFactory;
Expand All @@ -27,10 +26,11 @@
*/
class KNNEngineFactory implements EngineFactory {

private static CodecService codecService = new KNNCodecService();
private static KNNCodecService codecService = new KNNCodecService();

@Override
public Engine newReadWriteEngine(EngineConfig config) {
codecService.setPostingsFormat(config.getCodec().postingsFormat());
EngineConfig engineConfig = new EngineConfig(config.getShardId(), config.getAllocationId(),
config.getThreadPool(), config.getIndexSettings(), config.getWarmer(), config.getStore(),
config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(), codecService,
Expand Down

0 comments on commit 9295b31

Please sign in to comment.