Skip to content

Commit

Permalink
moving codec aliases to custom codec
Browse files Browse the repository at this point in the history
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
  • Loading branch information
sarthakaggarwal97 committed Sep 3, 2023
1 parent a473a9e commit dffd269
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@
import org.apache.lucene.codecs.FilterCodec;
import org.apache.lucene.codecs.StoredFieldsFormat;
import org.apache.lucene.codecs.lucene95.Lucene95Codec;
import org.opensearch.index.codec.CodecAliases;
import org.opensearch.index.codec.PerFieldMappingPostingFormatCodec;
import org.opensearch.index.mapper.MapperService;

import java.util.Set;

/**
*
* Extends {@link FilterCodec} to reuse the functionality of Lucene Codec.
* Supports two modes zstd and zstd_no_dict.
*
* @opensearch.internal
*/
public abstract class Lucene95CustomCodec extends FilterCodec {
public class Lucene95CustomCodec extends FilterCodec implements CodecAliases {

/** Default compression level used for compression */
public static final int DEFAULT_COMPRESSION_LEVEL = 3;
Expand Down Expand Up @@ -100,4 +103,9 @@ public StoredFieldsFormat storedFieldsFormat() {
public String toString() {
return getClass().getSimpleName();
}

@Override
public Set<String> aliases() {
return Set.of("zstd", "zstd_no_dict");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@

import org.apache.logging.log4j.Logger;
import org.opensearch.common.settings.Setting;
import org.opensearch.index.codec.CodecAliases;
import org.opensearch.index.codec.CodecSettings;
import org.opensearch.index.engine.EngineConfig;
import org.opensearch.index.mapper.MapperService;

import java.util.Set;

/**
* ZstdCodec provides ZSTD compressor using the <a href="https://github.com/luben/zstd-jni">zstd-jni</a> library.
*/
public class ZstdCodec extends Lucene95CustomCodec implements CodecSettings, CodecAliases {
public class ZstdCodec extends Lucene95CustomCodec implements CodecSettings {

/**
* Creates a new ZstdCodec instance with the default compression level.
Expand Down Expand Up @@ -59,9 +56,4 @@ public String toString() {
public boolean supports(Setting<?> setting) {
return setting.equals(EngineConfig.INDEX_CODEC_COMPRESSION_LEVEL_SETTING);
}

@Override
public Set<String> aliases() {
return Set.of("zstd");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@

import org.apache.logging.log4j.Logger;
import org.opensearch.common.settings.Setting;
import org.opensearch.index.codec.CodecAliases;
import org.opensearch.index.codec.CodecSettings;
import org.opensearch.index.engine.EngineConfig;
import org.opensearch.index.mapper.MapperService;

import java.util.Set;

/**
* ZstdNoDictCodec provides ZSTD compressor without a dictionary support.
*/
public class ZstdNoDictCodec extends Lucene95CustomCodec implements CodecSettings, CodecAliases {
public class ZstdNoDictCodec extends Lucene95CustomCodec implements CodecSettings {

/**
* Creates a new ZstdNoDictCodec instance with the default compression level.
Expand Down Expand Up @@ -60,8 +57,4 @@ public boolean supports(Setting<?> setting) {
return setting.equals(EngineConfig.INDEX_CODEC_COMPRESSION_LEVEL_SETTING);
}

@Override
public Set<String> aliases() {
return Set.of("zstd_no_dict");
}
}

0 comments on commit dffd269

Please sign in to comment.