Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of default properties of blosc compressor #6

Merged
merged 3 commits into from
Jun 14, 2023
Merged
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
14 changes: 7 additions & 7 deletions src/main/java/com/bc/zarr/CompressorFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void uncompress(InputStream is, OutputStream os) throws IOException {
}
}

static class BloscCompressor extends Compressor {
public static class BloscCompressor extends Compressor {

final static int AUTOSHUFFLE = -1;
final static int NOSHUFFLE = 0;
Expand All @@ -228,14 +228,13 @@ static class BloscCompressor extends Compressor {
public final static int[] supportedShuffle = new int[]{/*AUTOSHUFFLE, */NOSHUFFLE, BYTESHUFFLE, BITSHUFFLE};
public final static String[] supportedCnames = new String[]{"zstd", "blosclz", defaultCname, "lz4hc", "zlib"/*, "snappy"*/};

public final static Map<String, Object> defaultProperties = Collections
.unmodifiableMap(new HashMap<String, Object>() {{
public final static Map<String, Object> defaultProperties = new HashMap<String, Object>() {{
put(keyCname, defaultCname);
put(keyClevel, defaultCLevel);
put(keyShuffle, defaultShuffle);
put(keyBlocksize, defaultBlocksize);
put(keyNumThreads, defaultNumThreads);
}});
}};

private final int clevel;
private final int blocksize;
Expand Down Expand Up @@ -290,10 +289,11 @@ private BloscCompressor(Map<String, Object> map) {
this.blocksize = ((Number) blocksizeObj).intValue();
}

final Object nthreadsObj = map.get(keyNumThreads);
Object nthreadsObj = map.get(keyNumThreads);
if (nthreadsObj == null) {
this.nthreads = defaultNumThreads;
} else if (nthreadsObj instanceof String) {
nthreadsObj = defaultProperties.get(keyNumThreads);
}
if (nthreadsObj instanceof String) {
this.nthreads = Integer.parseInt((String) nthreadsObj);
} else {
this.nthreads = ((Number) nthreadsObj).intValue();
Expand Down