Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions src/main/java/dev/zarr/zarrjava/v3/codec/CodecBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public CodecBuilder withBytes() {
return withBytes(Endian.nativeOrder());
}

public CodecBuilder withGzip(int clevel) {
public CodecBuilder withGzip(int level) {
try {
codecs.add(new GzipCodec(new GzipCodec.Configuration(clevel)));
codecs.add(new GzipCodec(new GzipCodec.Configuration(level)));
} catch (ZarrException e) {
throw new RuntimeException(e);
}
Expand All @@ -96,9 +96,9 @@ public CodecBuilder withGzip() {
return withGzip(5);
}

public CodecBuilder withZstd(int clevel, boolean checksum) {
public CodecBuilder withZstd(int level, boolean checksum) {
try {
codecs.add(new ZstdCodec(new ZstdCodec.Configuration(clevel, checksum)));
codecs.add(new ZstdCodec(new ZstdCodec.Configuration(level, checksum)));
} catch (ZarrException e) {
throw new RuntimeException(e);
}
Expand All @@ -109,8 +109,8 @@ public CodecBuilder withZstd() {
return withZstd(5, true);
}

public CodecBuilder withZstd(int clevel) {
return withZstd(clevel, true);
public CodecBuilder withZstd(int level) {
return withZstd(level, true);
}

public CodecBuilder withSharding(int[] chunkShape) {
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/dev/zarr/zarrjava/ZarrPythonTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public void testWriteV3(String codec, String codecParam, DataType dataType) thro
builder = builder.withCodecs(c -> c.withGzip(Integer.parseInt(codecParam)));
break;
case "zstd":
int clevel_zstd = Integer.parseInt(codecParam.split("_")[0]);
int level_zstd = Integer.parseInt(codecParam.split("_")[0]);
boolean checksum = Boolean.parseBoolean(codecParam.split("_")[1]);
builder = builder.withCodecs(c -> c.withZstd(clevel_zstd, checksum));
builder = builder.withCodecs(c -> c.withZstd(level_zstd, checksum));
break;
case "bytes":
builder = builder.withCodecs(c -> c.withBytes(codecParam));
Expand Down Expand Up @@ -270,13 +270,13 @@ public void testWriteV2(String compressor, String compressorParam, dev.zarr.zarr

@CsvSource({"0,true", "0,false", "5, true", "10, false"})
@ParameterizedTest
public void testZstdLibrary(int clevel, boolean checksumFlag) throws IOException, InterruptedException {
public void testZstdLibrary(int level, boolean checksumFlag) throws IOException, InterruptedException {
//compress using ZstdCompressCtx
int number = 123456;
byte[] src = ByteBuffer.allocate(4).putInt(number).array();
byte[] compressed;
try (ZstdCompressCtx ctx = new ZstdCompressCtx()) {
ctx.setLevel(clevel);
ctx.setLevel(level);
ctx.setChecksum(checksumFlag);
compressed = ctx.compress(src);
}
Expand All @@ -286,7 +286,7 @@ public void testZstdLibrary(int clevel, boolean checksumFlag) throws IOException
Assertions.assertEquals(number, ByteBuffer.wrap(decompressed).getInt());

//write compressed to file
String compressedDataPath = TESTOUTPUT.resolve("compressed" + clevel + checksumFlag + ".bin").toString();
String compressedDataPath = TESTOUTPUT.resolve("compressed" + level + checksumFlag + ".bin").toString();
try (FileOutputStream fos = new FileOutputStream(compressedDataPath)) {
fos.write(compressed);
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/dev/zarr/zarrjava/ZarrV3Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ public void testCheckShardingBounds(int[] shardSize, boolean nested) {

@ParameterizedTest
@CsvSource({"0,true", "0,false", "5, true", "5, false"})
public void testZstdCodecReadWrite(int clevel, boolean checksum) throws ZarrException, IOException {
public void testZstdCodecReadWrite(int level, boolean checksum) throws ZarrException, IOException {
int[] testData = new int[16 * 16 * 16];
Arrays.setAll(testData, p -> p);

StoreHandle storeHandle = new FilesystemStore(TESTOUTPUT).resolve("testZstdCodecReadWrite", "checksum_" + checksum, "clevel_" + clevel);
StoreHandle storeHandle = new FilesystemStore(TESTOUTPUT).resolve("testZstdCodecReadWrite", "checksum_" + checksum, "level_" + level);
ArrayMetadataBuilder builder = Array.metadataBuilder()
.withShape(16, 16, 16)
.withDataType(DataType.UINT32)
.withChunkShape(2, 4, 8)
.withFillValue(0)
.withCodecs(c -> c.withZstd(clevel, checksum));
.withCodecs(c -> c.withZstd(level, checksum));
Array writeArray = Array.create(storeHandle, builder.build());
writeArray.write(ucar.ma2.Array.factory(ucar.ma2.DataType.UINT, new int[]{16, 16, 16}, testData));

Expand Down
Loading