Skip to content

Commit

Permalink
accessors for custom compression modes (#89)
Browse files Browse the repository at this point in the history
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
(cherry picked from commit 804fe11)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Dec 15, 2023
1 parent 05dc7cb commit 56543e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class Lucene95CustomStoredFieldsFormat extends StoredFieldsFormat {
/** A key that we use to map to a mode */
public static final String MODE_KEY = Lucene95CustomStoredFieldsFormat.class.getSimpleName() + ".mode";

private static final int ZSTD_BLOCK_LENGTH = 10 * 48 * 1024;
private static final int ZSTD_MAX_DOCS_PER_BLOCK = 4096;
private static final int ZSTD_BLOCK_SHIFT = 10;
protected static final int ZSTD_BLOCK_LENGTH = 10 * 48 * 1024;
protected static final int ZSTD_MAX_DOCS_PER_BLOCK = 4096;
protected static final int ZSTD_BLOCK_SHIFT = 10;

private final CompressionMode zstdCompressionMode;
private final CompressionMode zstdNoDictCompressionMode;
Expand Down Expand Up @@ -122,7 +122,7 @@ StoredFieldsFormat impl(Lucene95CustomCodec.Mode mode) {
}
}

Lucene95CustomCodec.Mode getMode() {
public Lucene95CustomCodec.Mode getMode() {
return mode;
}

Expand All @@ -132,4 +132,9 @@ Lucene95CustomCodec.Mode getMode() {
public int getCompressionLevel() {
return compressionLevel;
}

public CompressionMode getCompressionMode() {
return mode == Lucene95CustomCodec.Mode.ZSTD_NO_DICT ? zstdNoDictCompressionMode : zstdCompressionMode;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,14 @@ public void testZstdNoDictLucene95CustomCodecModeWithCompressionLevel() {
assertEquals(randomCompressionLevel, lucene95CustomStoredFieldsFormat.getCompressionLevel());
}

public void testCompressionModes(){
Lucene95CustomStoredFieldsFormat lucene95CustomStoredFieldsFormat = new Lucene95CustomStoredFieldsFormat();
assertTrue(lucene95CustomStoredFieldsFormat.getCompressionMode() instanceof ZstdCompressionMode);
}

public void testZstdNoDictCompressionModes(){
Lucene95CustomStoredFieldsFormat lucene95CustomStoredFieldsFormat = new Lucene95CustomStoredFieldsFormat(Lucene95CustomCodec.Mode.ZSTD_NO_DICT);
assertTrue(lucene95CustomStoredFieldsFormat.getCompressionMode() instanceof ZstdNoDictCompressionMode);
}

}

0 comments on commit 56543e5

Please sign in to comment.