Skip to content

Commit 8453798

Browse files
authored
Merge pull request #6 from joshmoore/blosc-multithread-read
Allow configuration of default properties of blosc compressor
2 parents 5c6a217 + 2df7d17 commit 8453798

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/com/bc/zarr/CompressorFactory.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void uncompress(InputStream is, OutputStream os) throws IOException {
208208
}
209209
}
210210

211-
static class BloscCompressor extends Compressor {
211+
public static class BloscCompressor extends Compressor {
212212

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

231-
public final static Map<String, Object> defaultProperties = Collections
232-
.unmodifiableMap(new HashMap<String, Object>() {{
231+
public final static Map<String, Object> defaultProperties = new HashMap<String, Object>() {{
233232
put(keyCname, defaultCname);
234233
put(keyClevel, defaultCLevel);
235234
put(keyShuffle, defaultShuffle);
236235
put(keyBlocksize, defaultBlocksize);
237236
put(keyNumThreads, defaultNumThreads);
238-
}});
237+
}};
239238

240239
private final int clevel;
241240
private final int blocksize;
@@ -290,10 +289,11 @@ private BloscCompressor(Map<String, Object> map) {
290289
this.blocksize = ((Number) blocksizeObj).intValue();
291290
}
292291

293-
final Object nthreadsObj = map.get(keyNumThreads);
292+
Object nthreadsObj = map.get(keyNumThreads);
294293
if (nthreadsObj == null) {
295-
this.nthreads = defaultNumThreads;
296-
} else if (nthreadsObj instanceof String) {
294+
nthreadsObj = defaultProperties.get(keyNumThreads);
295+
}
296+
if (nthreadsObj instanceof String) {
297297
this.nthreads = Integer.parseInt((String) nthreadsObj);
298298
} else {
299299
this.nthreads = ((Number) nthreadsObj).intValue();

0 commit comments

Comments
 (0)