Skip to content

Commit 29acd65

Browse files
mkittifm3
andauthored
Add Zstd to N5CompressorFactory.scala (#8703)
N5 supports Zstandard compression via https://github.com/JaneliaSciComp/n5-zstandard ### Steps to test: - Test against https://s3.janelia.org/keller-lab/s12a/samples_for_stitching/fly_brain_3/basic_corrected/dataset.n5/setup201/timepoint0/s4/ with the following attributes.json ``` { "blockSize": [64, 64, 64], "compression": { "level": 3, "type": "zstd" }, "dataType": "uint16", "dimensions": [256, 160, 413] } ``` ------ - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`) - [x] Needs datastore update after deployment --------- Co-authored-by: Florian M <fm3@users.noreply.github.com>
1 parent b61f0ce commit 29acd65

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

unreleased_changes/8703.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Added
2+
- Added Zstandard support for N5

webknossos-datastore/app/com/scalableminds/webknossos/datastore/datareaders/n5/N5CompressorFactory.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import com.scalableminds.webknossos.datastore.datareaders.{
88
GzipCompressor,
99
NullCompressor,
1010
StringCompressionSetting,
11-
ZlibCompressor
11+
ZlibCompressor,
12+
ZstdCompressor,
13+
IntCompressionSetting,
1214
}
1315

1416
object N5CompressorFactory {
@@ -28,6 +30,13 @@ object N5CompressorFactory {
2830
new ZlibCompressor(properties)
2931
case "gzip" => new GzipCompressor(properties)
3032
case "blosc" => new BloscCompressor(properties)
33+
case "zstd" => {
34+
val level = properties.get("level") match {
35+
case Some(IntCompressionSetting(l)) => l
36+
case _ => throw new IllegalArgumentException("Zstd level must be int")
37+
}
38+
new ZstdCompressor(level, checksum = false)
39+
}
3140
case _ => throw new IllegalArgumentException("Compressor id:'" + id + "' not supported.")
3241
}
3342
}

0 commit comments

Comments
 (0)