Skip to content

Commit 6e7d58e

Browse files
authored
Merge pull request #1514 from lesserwhirls/gh-1447
Add support for blosc compression
2 parents b4a818c + 5a5e311 commit 6e7d58e

File tree

23 files changed

+696
-80
lines changed

23 files changed

+696
-80
lines changed

.github/workflows/test-native-compression.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ jobs:
1515
ubuntu-24.04,
1616
ubuntu-24.04-arm,
1717
windows-2022,
18-
macos-13,
1918
macos-14,
20-
macos-15
19+
macos-15,
20+
macos-15-intel
2121
]
2222
name: netCDF-Java Native Compression Tests
2323
runs-on: ${{ matrix.os }}
2424
steps:
2525
- uses: actions/checkout@v4
2626
- name: Setup JDK 8, 17
27-
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-13' }}
27+
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-15-intel' }}
2828
uses: actions/setup-java@v5
2929
with:
3030
distribution: 'temurin'
3131
java-version: |
3232
8
3333
17
3434
- name: Setup JDK 21
35-
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-13' }}
35+
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-15-intel' }}
3636
uses: actions/setup-java@v5
3737
with:
3838
distribution: 'temurin'
@@ -47,12 +47,12 @@ jobs:
4747
restore-keys: |
4848
${{ runner.os }}-gradle-
4949
- name: Run libaec JNA tests
50-
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-13' }}
50+
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-15-intel' }}
5151
run: ./gradlew -Dorg.gradle.java.installations.auto-detect=true clean :libaec-jna:test
5252
env:
5353
JDK8: /usr/thredds-test-environment/temurin8
5454
- name: Run libaec JNA tests (JDK 21 tests)
55-
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-13' }}
55+
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-15-intel' }}
5656
run: ./gradlew clean :libaec-jna:test21
5757
- uses: actions/upload-artifact@v4
5858
if: failure()

build-logic/src/main/kotlin/base-conventions.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ val publicArtifacts =
4848
":legacy",
4949
":libaec-jna",
5050
":libaec-native",
51+
":libblosc2-jna",
52+
":libblosc2-native",
5153
":netcdf4",
5254
":opendap",
5355
":udunits",

cdm/core/src/main/java/ucar/nc2/filter/Blosc.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

cdm/core/src/main/resources/META-INF/services/ucar.nc2.filter.FilterProvider

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ucar.nc2.filter.Blosc$Provider
21
ucar.nc2.filter.Deflate$Provider
32
ucar.nc2.filter.Checksum32$Fletcher32Provider
43
ucar.nc2.filter.Checksum32$Adler32Provider

cdm/zarr/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ dependencies {
2020
implementation(libs.jackson.databind)
2121
implementation(libs.slf4j.api)
2222

23+
runtimeOnly(project(":libblosc2-jna"))
24+
2325
testImplementation(platform(project(":netcdf-java-testing-platform")))
2426

2527
testImplementation(project(":cdm-s3"))
@@ -38,6 +40,8 @@ dependencies {
3840

3941
testCompileOnly(libs.junit4)
4042

43+
testRuntimeOnly(project(":libblosc2-native"))
44+
4145
testRuntimeOnly(libs.junit5.platformLauncher)
4246
testRuntimeOnly(libs.junit5.vintageEngine)
4347
}

cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import ucar.ma2.ArrayLong;
1616
import ucar.ma2.DataType;
1717
import ucar.ma2.InvalidRangeException;
18+
import ucar.ma2.MAMath;
19+
import ucar.ma2.MAMath.MinMax;
1820
import ucar.ma2.Section;
1921
import ucar.nc2.*;
2022

@@ -399,4 +401,24 @@ public void testGeozarrSharedDimension() throws IOException {
399401
}
400402
}
401403
}
404+
405+
@Test
406+
public void testBloscCompressedData() throws IOException {
407+
NetcdfFile ncfile = NetcdfFiles.open(SCALAR_GEOZARR_DATA);
408+
Variable bloscVariable = ncfile.findVariable("temperature");
409+
assertThat(bloscVariable != null).isTrue();
410+
Attribute compressor = bloscVariable.findAttribute("_Compressor");
411+
assertThat(compressor).isNotNull();
412+
assertThat(compressor.getStringValue()).isEqualTo("blosc");
413+
Array data = bloscVariable.read();
414+
assertThat(data).isNotNull();
415+
MinMax mm = MAMath.getMinMax(data);
416+
assertThat(mm).isNotNull();
417+
// values from python zarr implementation
418+
double expectedMin = 1.9752643660053693e-05;
419+
double expectedMax = 0.9999808929333684;
420+
assertThat(mm.min).isWithin(1e-9).of(expectedMin);
421+
assertThat(mm.max).isWithin(1e-7).of(expectedMax);
422+
}
423+
402424
}

docs/src/site/_config.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ sidebars:
6464
- netcdfJavaTutorial_sidebar
6565

6666
# project logo (32x32), name, main landing page (currently used in the footer)
67-
project_logo: https://www.unidata.ucar.edu/images/logos/thredds_netcdf-32x32.png
67+
project_logo: https://assets.unidata.ucar.edu/images/logos/thredds_netcdf-32x32.png
6868
project_name: netCDF-Java
6969
project_landing_page: https://unidata.ucar.edu/software/netcdf-java/
7070

@@ -74,3 +74,9 @@ description: "This is a documentation site for the netCDF-Java, which is part of
7474
# needed for sitemap.xml file only
7575
# must include trailing slash, leave off the version :-)
7676
base_docs_url: https://docs.unidata.ucar.edu/netcdf-java/
77+
78+
# these will appear in various doc pages
79+
java_version_build: 17
80+
java_version_runtime: 8
81+
libaec_version: 1.1.3.0
82+
cblosc2_version: 2.22.0.0

docs/src/site/pages/netcdfJava/Upgrade.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ permalink: upgrade.html
88

99
## Requirements
1010

11-
* Java 8 or later is required to use the library.
12-
* Starting with version 5.10.0, Java 17 is required to build the library.
11+
* Java {{ site.java_version_runtime }} or later is required to use the library.
12+
* Java {{ site.java_version_build }} is required to build the library.
1313

1414
## Quick Navigation
1515
* [Summary of changes for v5.10.x](#netcdf-java-api-changes-510x)
@@ -29,10 +29,23 @@ permalink: upgrade.html
2929
Point release notes:
3030
* [5.10.0](https://github.com/Unidata/netcdf-java/releases/tag/v5.10.0){:target="_blank"} (_yyyy-mm-dd, unreleased_)
3131

32-
Starting with 5.10.x, the netCDF-Java library requires Java 17 to build (although the build will produce Java 8 bytecode, so the minimum supported version is still Java 8).
32+
Starting with 5.10.0, the netCDF-Java library requires Java 17 to build (although the build will produce Java 8 bytecode, so the minimum supported version is still Java 8).
3333
Note: we are looking to update the minimum version of the JVM we support for the project.
3434
Please consider taking a moment to participate in the [poll on GitHub](https://github.com/Unidata/netcdf-java/discussions/1468){:target="_blank"}.
3535

36+
The 5.10.0 release adds support for reading blosc compressed data using the C-Blosc2 native library.
37+
The new artifact for JNA support is `edu.ucar.unidata:libblosc2-jna` (the current version is `2.22.0.0`).
38+
39+
### Native jar group name changes
40+
41+
Going forard, all native jars will be published under the `edu.ucar.unidata` group.
42+
Their version will match the version of the native library that they contain, plus a build number.
43+
This is to help make clear which version of the native library is being used by the jar.
44+
Starting with this release, `libaec-native` will be published under the `edu.ucar.unidata` group as well.
45+
Consider using the netcdf-java-bom artifact to manage your netCDF-Java dependencies, as it will always contain the latest versions of the native jars.
46+
The new `edu.ucar.unidata:libaec-native:1.1.3.0` is equivalent to the previous `edu.ucar:libaec-native:5.9.1`.
47+
Please use the new group name for any `*-native` artifacts going forward.
48+
3649
## netCDF-Java API Changes (5.9.x)
3750

3851
Point release notes:

docs/src/site/pages/netcdfJava/coordattributeconvention.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ toc: false
88

99
{% include image.html file="netcdf-java/tutorial/coordsystems/CoordSys.png" alt="Coordinate Systems UML" caption="Coordinate Systems UML" %}
1010

11-
For an overview, see: [CDM Object Model]( /common_data_model_overview.html). The Coordinate Axes for a Variable must use a subset of the Variables's dimensions.
11+
For an overview, see: [CDM Object Model](common_data_model_overview.html). The Coordinate Axes for a Variable must use a subset of the Variables's dimensions.
1212

1313
## Goals of _Coordinate Attribute Convention
1414

docs/src/site/pages/netcdfJava/developer/CdmUtilityPrograms.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.ft.point.writer.CFPointW
152152

153153
## GribCdmIndex
154154

155-
Write GRIB Collection Indexes from an XML file containing a [GRIB `<featureCollection>`](/grib_feature_collections_ref.html) XML element.
155+
Write GRIB Collection Indexes from an XML file containing a [GRIB `<featureCollection>`](grib_feature_collections_ref.html) XML element.
156156

157157
~~~bash
158158
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.grib.collection.GribCdmIndex [options]
@@ -173,7 +173,7 @@ Example:
173173
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.grib.collection.GribCdmIndex -fc /data/fc/gfs_example.xml
174174
~~~
175175

176-
Note that the output file is placed in the root directory of the collection, as specified by the [Collection Specification](/collection_spec_string_ref.html) of the GRIB [`<featureCollection>`](feature_collections_ref.html).
176+
Note that the output file is placed in the root directory of the collection, as specified by the [Collection Specification string](https://docs.unidata.ucar.edu/tds/current/userguide/collection_spec_string_ref.html){:target="_blank"} of the GRIB [`<featureCollection>`](grib_feature_collections_ref.html).
177177

178178
## FeatureScan
179179

0 commit comments

Comments
 (0)