Skip to content

Commit a95b464

Browse files
committed
readme + license + cleanup
1 parent 2c2a823 commit a95b464

8 files changed

Lines changed: 117 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,10 @@ jobs:
6969
bloscjni.c ..\\c-blosc\\build\\blosc\\libblosc.a
7070
7171
- name: Build blosc-java
72-
run: |
73-
mvn compile
72+
run: mvn compile
7473

7574
- name: Test blosc-java
76-
run: |
77-
mvn test
75+
run: mvn test
7876

7977
- uses: actions/upload-artifact@v3
8078
with:
@@ -86,6 +84,8 @@ jobs:
8684
runs-on: ubuntu-latest
8785
steps:
8886
- uses: actions/checkout@v3
87+
with:
88+
submodules: true
8989
- uses: actions/setup-java@v3
9090
with:
9191
distribution: 'temurin'
@@ -97,16 +97,18 @@ jobs:
9797
path: src/main/resources
9898

9999
- name: Rename JNI dynamic libraries
100-
run: |
101-
mv src/main/resources/*/* src/main/resources
100+
run: mv src/main/resources/*/* src/main/resources
102101

103-
- name: Assembly JAR
104-
run: |
105-
mvn package
102+
- name: Append c-blosc license
103+
run: cat c-blosc/LICENSE.txt >> LICENSE.txt
104+
105+
- name: Assemble JAR
106+
run: mvn package
106107

107108
- uses: actions/upload-artifact@v3
108109
with:
109110
name: blosc-jar
110111
path: target/*.jar
111112

112-
- run: java -cp target/*.jar dev.zarr.bloscjava.Blosc
113+
- name: Smoke test
114+
run: java -cp target/*.jar dev.zarr.bloscjava.Blosc

LICENSE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 scalable minds <https://scalableminds.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
---
24+

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# blosc-java
2+
3+
A cross-platform JNI-based wrapper around the [c-blosc](https://github.com/Blosc/c-blosc) library.
4+
5+
The packaged JARs contain binaries for Windows, Mac OS (x86_64 only) and Linux.
6+
7+
## Usage
8+
```java
9+
import dev.zarr.bloscjava.Blosc;
10+
11+
// Generate some random data
12+
int SIZE = 100 * 100 * 100;
13+
byte[] buf = new byte[SIZE];
14+
for (int i = 0; i < SIZE; i++) {
15+
buf[i] = (int)(i % 24);
16+
}
17+
18+
byte[] compressedBuf = Blosc.compress(buf, 1, Blosc.Compressor.ZSTD, 9);
19+
byte[] decompressedBuf = Blosc.decompress(compressedBuf);
20+
21+
assert Arrays.equals(buf, decompressedBuf);
22+
```
23+
24+
### API
25+
```java
26+
byte[] compress(byte[] src, int typeSize, Compressor compressor, int compressorLevel, Shuffle shuffle, int blockSize, int numThreads)
27+
```
28+
29+
- `src`: Byte array to be compressed. Required.
30+
- `typeSize`: Number of bytes per primitive value (e.g. 1 for int8, 2 for int16, 4 for int32). Required.
31+
- `compressor`: Compression algorithm. Available choices: `LZ4`, `LZ4HC`, `BLOSCLZ`, `ZSTD`, `SNAPPY`, `ZLIB`.
32+
Default: `ZSTD`
33+
- `compressorLevel`: Number from 0 to 9 (0 = little compression, 9 = strongest compression). Default: 5.
34+
- `shuffle`: Whether to use shuffling. Available choices: `NOSHUFFLE`, `BIT_SHUFFLE`, `BYTE_SHUFFLE`. Default:
35+
`BIT_SHUFFLE` for typeSize == 1, `BYTE_SHUFFLE` else
36+
- `blockSize`: Requested size of compressed blocks. Use 0 for automatic block sizes.
37+
- `numThreads`: Number of threads to be used internally. Default: 1.
38+
39+
```java
40+
byte[] decompress(byte[] src, int numThreads)
41+
```
42+
43+
- `src`: Byte array to be decompressed. Required.
44+
- `numThreads`: Number of threads to be used internally. Default: 1.
45+

pom.xml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,48 @@
66

77
<groupId>dev.zarr</groupId>
88
<artifactId>blosc-java</artifactId>
9-
<version>1.0-SNAPSHOT</version>
9+
<version>0.1-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

12+
<licenses>
13+
<license>
14+
<name>MIT</name>
15+
<url>https://unlicense.org/</url>
16+
<distribution>repo</distribution>
17+
</license>
18+
</licenses>
19+
<scm>
20+
<connection>scm:git:https://github.com/scalableminds/blosc-java</connection>
21+
<developerConnection>scm:git:git@github.com:scalableminds/blosc-java</developerConnection>
22+
<tag>HEAD</tag>
23+
<url>https://github.com/scalableminds/blosc-java</url>
24+
</scm>
25+
<issueManagement>
26+
<system>GitHub Issues</system>
27+
<url>https://github.com/scalableminds/blosc-java/issues</url>
28+
</issueManagement>
29+
<ciManagement>
30+
<system>GitHub Actions</system>
31+
<url>https://github.com/scalableminds/blosc-java/actions</url>
32+
</ciManagement>
33+
34+
<contributors>
35+
<contributor>
36+
<name>Norman Rzepka</name>
37+
<url>https://twitter.com/normanrz</url>
38+
<properties>
39+
<id>normanrz</id>
40+
</properties>
41+
</contributor>
42+
</contributors>
43+
1244
<properties>
1345
<maven.compiler.source>8</maven.compiler.source>
1446
<maven.compiler.target>8</maven.compiler.target>
1547
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1648
</properties>
1749
<dependencies>
50+
<!-- Test dependencies -->
1851
<dependency>
1952
<groupId>org.junit.jupiter</groupId>
2053
<artifactId>junit-jupiter</artifactId>
-1.52 KB
Binary file not shown.
-1.24 KB
Binary file not shown.
-1.7 KB
Binary file not shown.

src/test/java/dev/zarr/bloscjava/BloscTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public void testCompress() {
2121
System.out.println(Arrays.toString(buf));
2222
System.out.println(Arrays.toString(compBuf));
2323
System.out.println(Arrays.toString(decompBuf));
24+
25+
assert Arrays.equals(buf, decompBuf);
2426
}
2527

2628
}

0 commit comments

Comments
 (0)