Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -12,6 +12,7 @@
import org.opensearch.plugins.EnginePlugin;
import org.opensearch.index.codec.CodecServiceFactory;
import org.opensearch.index.IndexSettings;
import org.opensearch.index.engine.EngineConfig;

import java.util.Optional;

Expand All @@ -26,15 +27,25 @@
*/
public final class CustomCodecPlugin extends Plugin implements EnginePlugin {

/** ZSTD compression with dictionary */
protected static final String ZSTD_CODEC_NAME = "ZSTD";

/** ZSTD compression without dictionary */
protected static final String ZSTDNODICT_CODEC_NAME = "ZSTDNODICT";

/** Creates a new instance */
public CustomCodecPlugin() {}

/**
* @param indexSettings is the default indexSettings
* @return the engine factory
* @return the custom-codec service factory
*/
@Override
public Optional<CodecServiceFactory> getCustomCodecServiceFactory(final IndexSettings indexSettings) {
return Optional.of(new CustomCodecServiceFactory());
String codec = indexSettings.getValue(EngineConfig.INDEX_CODEC_SETTING);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add unit test for this class.

if (codec.equals(ZSTD_CODEC_NAME) || codec.equals(ZSTDNODICT_CODEC_NAME)) {
return Optional.of(new CustomCodecServiceFactory());
}
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ abstract class Lucene95CustomCodec extends FilterCodec {

/** Each mode represents a compression algorithm. */
public enum Mode {
ZSTD,
ZSTDNODICT
ZSTD(CustomCodecPlugin.ZSTD_CODEC_NAME),
ZSTDNODICT(CustomCodecPlugin.ZSTDNODICT_CODEC_NAME);

private final String name;

Mode(String name) {
this.name = name;
}
}

private final StoredFieldsFormat storedFieldsFormat;
Expand Down