Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Oct 15, 2024
1 parent 960d0ab commit ef154c8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,10 @@ public Optional<CodecServiceFactory> getCustomCodecServiceFactory(final IndexSet
|| codecName.equals(CustomCodecService.QAT_DEFLATE_CODEC)) {
return Optional.of(new CustomCodecServiceFactory());
} else {
if (codecName.equals(Lucene99QatCodec.Mode.QAT_LZ4.getCodec())
|| codecName.equals(Lucene99QatCodec.Mode.QAT_DEFLATE.getCodec())) {
if (!QatZipperFactory.isQatAvailable()) {
throw new IllegalArgumentException("QAT codecs are not supported. Please create indices with a different codec.");
}
}

if (codecName.equals(Lucene912QatCodec.Mode.QAT_LZ4.getCodec())
|| codecName.equals(Lucene912QatCodec.Mode.QAT_DEFLATE.getCodec())) {
if (!QatZipperFactory.isQatAvailable()) {
throw new IllegalArgumentException("QAT codecs are not supported. Please create indices with a different codec.");
}
if (!QatZipperFactory.isQatAvailable() && isQatCodec(codecName)) {
throw new IllegalArgumentException(
"QAT codecs are not supported (QAT is not available). Please create indices with a different codec."
);
}
}
return Optional.empty();
Expand All @@ -71,4 +63,11 @@ public Optional<CodecServiceFactory> getCustomCodecServiceFactory(final IndexSet
public List<Setting<?>> getSettings() {
return Arrays.asList(Lucene99QatCodec.INDEX_CODEC_QAT_MODE_SETTING);
}

private static boolean isQatCodec(String codecName) {
return codecName.equals(Lucene99QatCodec.Mode.QAT_LZ4.getCodec())
|| codecName.equals(Lucene99QatCodec.Mode.QAT_DEFLATE.getCodec())
|| codecName.equals(Lucene912QatCodec.Mode.QAT_LZ4.getCodec())
|| codecName.equals(Lucene912QatCodec.Mode.QAT_DEFLATE.getCodec());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected ZstdCompressionMode() {
*
* @param compressionLevel The compression level to use.
*/
public ZstdCompressionMode(int compressionLevel) {
protected ZstdCompressionMode(int compressionLevel) {
this.compressionLevel = compressionLevel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected ZstdNoDictCompressionMode() {
*
* @param compressionLevel The compression level.
*/
public ZstdNoDictCompressionMode(int compressionLevel) {
protected ZstdNoDictCompressionMode(int compressionLevel) {
this.compressionLevel = compressionLevel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ public Lucene99CustomStoredFieldsFormat(Lucene99CustomCodec.Mode mode) {
public Lucene99CustomStoredFieldsFormat(Lucene99CustomCodec.Mode mode, int compressionLevel) {
this.mode = Objects.requireNonNull(mode);
this.compressionLevel = compressionLevel;
zstdCompressionMode = new ZstdCompressionMode(compressionLevel);
zstdNoDictCompressionMode = new ZstdNoDictCompressionMode(compressionLevel);
zstdCompressionMode = new ZstdCompressionMode(compressionLevel) {
};
zstdNoDictCompressionMode = new ZstdNoDictCompressionMode(compressionLevel) {
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* compatible open source license.
*/

package org.opensearch.index.codec.customcodecs;
package org.opensearch.index.codec.customcodecs.backward_codecs;

import org.opensearch.index.codec.customcodecs.backward_codecs.Lucene95CustomCodec;
import org.opensearch.index.codec.customcodecs.backward_codecs.Lucene95CustomStoredFieldsFormat;
import org.opensearch.index.codec.customcodecs.ZstdCompressionMode;
import org.opensearch.index.codec.customcodecs.ZstdNoDictCompressionMode;
import org.opensearch.test.OpenSearchTestCase;

public class Lucene95CustomStoredFieldsFormatTests extends OpenSearchTestCase {
Expand Down

0 comments on commit ef154c8

Please sign in to comment.