From 97e679c44b1fec824e6fa647bb3876f2bf74483b Mon Sep 17 00:00:00 2001 From: Patrick Edson Date: Fri, 21 Apr 2023 07:35:34 -0400 Subject: [PATCH 1/2] Allow configuration of default properties of blosc compressor. --- src/main/java/com/bc/zarr/CompressorFactory.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/bc/zarr/CompressorFactory.java b/src/main/java/com/bc/zarr/CompressorFactory.java index 4465164..12604b5 100644 --- a/src/main/java/com/bc/zarr/CompressorFactory.java +++ b/src/main/java/com/bc/zarr/CompressorFactory.java @@ -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; @@ -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 defaultProperties = Collections - .unmodifiableMap(new HashMap() {{ + public final static Map defaultProperties = new HashMap() {{ put(keyCname, defaultCname); put(keyClevel, defaultCLevel); put(keyShuffle, defaultShuffle); put(keyBlocksize, defaultBlocksize); put(keyNumThreads, defaultNumThreads); - }}); + }}; private final int clevel; private final int blocksize; @@ -290,14 +289,16 @@ private BloscCompressor(Map 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(); } + System.out.println(nthreads); } @Override From 4ca3f11d27bc29f6445ded309923970b1eb8268a Mon Sep 17 00:00:00 2001 From: Patrick Edson Date: Fri, 21 Apr 2023 12:09:21 -0400 Subject: [PATCH 2/2] Remove extraneous statement. --- src/main/java/com/bc/zarr/CompressorFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/bc/zarr/CompressorFactory.java b/src/main/java/com/bc/zarr/CompressorFactory.java index 12604b5..d32a29a 100644 --- a/src/main/java/com/bc/zarr/CompressorFactory.java +++ b/src/main/java/com/bc/zarr/CompressorFactory.java @@ -298,7 +298,6 @@ private BloscCompressor(Map map) { } else { this.nthreads = ((Number) nthreadsObj).intValue(); } - System.out.println(nthreads); } @Override