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

PostingsFormat Fix for odfe 1.9 #249

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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