Git Product home page Git Product logo

jzarr's Introduction

JZarr

A Java version of the wonderful Python zarr API.

Build Documentation

This API is able to use blosc compression. To use this compression, a compiled c-blosc distributed library must be available on the operating system. If such a library is not available ... The C sourcecode and instructions to build the library can be found at https://github.com/Blosc/c-blosc. If you want to use the JZarr API and the integrated blosc compression, you have to start the Java Virtual Machine with the following VM parameter:

-Djna.library.path=<path which contains the compiled c-blosc library>

In order to include the blosc library for testing during the build process you need to create a copy of the template.blosc.properties file and rename the copy to blosc.properties. Provide the path to the bloscJnaLibraryPath property as explained in the comments of within the file.

Library Documentation

The latest detailed information can be found at JZarrs project documentation page.

Generating the Documentation

The projects documentation is automatically generated and provided using "Read the Docs". Some files, needed to build the "Read the Docs" documentation must be generated to be up to date and along with the code. Therefore, a class has been implemented which searches for classes whose filename ends with "_rtd.java" and invokes there main method. Rerun the class (ExecuteForReadTheDocs) to autogenerate these referenced files. The bloscJnaLibraryPath is also necessary for generating the "Read the Docs" files.

jzarr's People

Contributors

chris-allan avatar dependabot[bot] avatar electricsam avatar forman avatar marpet avatar sabineembacher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jzarr's Issues

Stream is not closed in ZarrArray.java

Currently in ZarrArray.java, the findNestedChunks method is implemented as:

 private static boolean findNestedChunks(ZarrPath relativePath, Store store, int[] chunks) throws IOException {
        final String oneOrMoreDigits = "\\d+";
        final StringBuilder sb = new StringBuilder(oneOrMoreDigits);
        for (int i = 0; i < chunks.length - 1; i++) {
            sb.append(DimensionSeparator.SLASH.getSeparatorChar());
            sb.append(oneOrMoreDigits);
        }
        final String regex = sb.toString();
        final Stream<String> keys = store.getRelativeLeafKeys(relativePath.storeKey);
        final boolean nestedChunks = keys.anyMatch(s -> s.matches(regex));
        return nestedChunks;
    }

The java.util.stream.Stream from store.getRelativeLeafKeys() is not wrapped in a try-with-resources block. Since the source of this stream is an interface, it is not known if closing the stream is required or not.

It should be as follows:

    private static boolean findNestedChunks(ZarrPath relativePath, Store store, int[] chunks) throws IOException {
        final String oneOrMoreDigits = "\\d+";
        final StringBuilder sb = new StringBuilder(oneOrMoreDigits);
        for (int i = 0; i < chunks.length - 1; i++) {
            sb.append(DimensionSeparator.SLASH.getSeparatorChar());
            sb.append(oneOrMoreDigits);
        }
        final String regex = sb.toString();
        try (final Stream<String> keys = store.getRelativeLeafKeys(relativePath.storeKey)){
            final boolean nestedChunks = keys.anyMatch(s -> s.matches(regex));
            return nestedChunks;
        }
    }

Make Synchronizing optional

Default Implementation = ThreadSynchronizer
Additional:
NullSynchronizer, ProzessSynchronizer, CombinedSynchronizer

  • Synchronizer Interface
  • NullSynchronizer
  • ThreadSynchronizer
  • ProcessSynchronizer
  • CombinedSynchronizer

POM example in docs didn't work

Hi - thanks for this library! I tried to use the sample POM extract in https://jzarr.readthedocs.io/en/latest/ but it didn't work. I found I needed to use https:// for the repo URL, i.e. https://nexus.senbox.net/nexus/content/groups/public/.

Also I wasn't able to use 0.3.2-SNAPSHOT as there is no POM for this, so I changed it to 0.3.5. This snippet worked for me:

    <dependencies>
        <dependency>
            <groupId>com.bc.zarr</groupId>
            <artifactId>jzarr</artifactId>
            <version>0.3.5</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>bc-nexus-repo</id>
            <name>Brockmann-Consult Public Maven Repository</name>
            <url>https://nexus.senbox.net/nexus/content/groups/public/</url>
        </repository>
    </repositories>

Struggling with using blosc compression

This probably isn't a JZarr problem per se, but I'm struggling to get my Java program to recognise my native c-blosc library.

I'm on an M1 Mac (which might be significant), using JDK17 with NetBeans, using maven as a build system. The c-blosc library was installed with Homebrew.

I've written a simple program and am trying to run it using the command-line switch -Djna.library.path=/opt/homebrew/Cellar/c-blosc/1.21.1/. I only need blosc at runtime, not compile time.

Whatever I try, I end up with:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /private/var/folders/s2/_3zsgdqd6pj0y20x4chv8g640000gn/T/jna-105417/jna11531817638949407677.tmp: dlopen(/private/var/folders/s2/_3zsgdqd6pj0y20x4chv8g640000gn/T/jna-105417/jna11531817638949407677.tmp, 1): no suitable image found.

Are there any more details you can provide about how to set this up in a maven-based system?

I'm wondering whether there may be an issue with the M1 processor (which is ARM based). The output of java -version is:

openjdk version "17.0.1" 2021-10-19 LTS
OpenJDK Runtime Environment Zulu17.30+15-CA (build 17.0.1+12-LTS)
OpenJDK 64-Bit Server VM Zulu17.30+15-CA (build 17.0.1+12-LTS, mixed mode, sharing)

Reading ome-zarr issue

I am trying to read a ome-zarr files available on embassy
https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001247.zarr

I wrote a little client download the zarr locally and I attempted to read the file using jzarr v0.3
I got the following error when reading the file:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.bc.zarr.ZarrHeader` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (BufferedReader); line: 1, column: 2]
        at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
        at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1592)
        at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1058)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1297)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4218)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3227)
        at com.bc.zarr.ZarrUtils.fromJson(ZarrUtils.java:104)
        at com.bc.zarr.ZarrArray.open(ZarrArray.java:69)
        at com.bc.zarr.ZarrArray.open(ZarrArray.java:60)
        at com.bc.zarr.ZarrArray.open(ZarrArray.java:56)
        at com.bc.zarr.ZarrArray.open(ZarrArray.java:52)
        at com.example.Zarr.readZarrFile(Zarr.java:193)

endianness character present in .zattr for single byte data types

cc @joshmoore

While running a branch of zarr_implementations with jzarr-based read/write tests (with jzarr 0.3.2), I encountered the following issue.

The data used in the example in that repository has an 8-bit unsigned integer format. The .zattr JSON files created by jzarr currently have the following entry

"dtype" : ">u1",

but .zattr files created by other libraries such as zarr-python, xtensor-zarr and z5py have:

"dtype" : "|u1",

It seems that the spec indicates that | should be used rather than > or < for data types with a single byte width where there is no endianness. A similar issue may also be present for |b1 and |i1 types, but I have not confirmed that.

License clarification

At @glencoesoftware we're very excited about the work going on with this library and in collaboration with @ome we are looking to add it to a variety of tools we support pursuant to our collective NGFF [1] goals in biomedical imaging. These tools are both open and closed source. A couple of weeks ago in fe2726e license headers were added to all source code specifying GPLv3 or later. The LICENSE at the root of the project remains MIT.

Is it the project's intention to relicense versions after 0.3.1 as GPLv3 or later?

  1. https://ngff.openmicroscopy.org/latest/

Persistence mode {‘r’, ‘r+’, ‘a’, ‘w’, ‘w-‘}

mode:{‘r’, ‘r+’, ‘a’, ‘w’, ‘w-‘}, optional
Persistence mode: ‘r’ means read only (must exist); ‘r+’ means read/write (must exist); ‘a’ means read/write (create if doesn’t exist); ‘w’ means create (overwrite if exists); ‘w-‘ means create (fail if exists).

Space in file path causes IllegalArgumentException

When a file path is converted to an URL in order to read a zipped ZNAP file in SNAP an IllegalArgumentException is thrown if this path contains a space.

java.net.URISyntaxException: Illegal character in opaque part at index 71: jar:file:/C:/Users/<snip>/RSEO content/S2A_MSIL2A_20230227T160221_N0509_R097_T17QLF_20230227T225659_subset20m.znap.zip at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.checkChars(URI.java:3021) at java.net.URI$Parser.parse(URI.java:3058) at java.net.URI.<init>(URI.java:588) at java.net.URI.create(URI.java:850) Caused: java.lang.IllegalArgumentException: Illegal character in opaque part at index 71: jar:file:/C:/Users/<snip>/RSEO content/S2A_MSIL2A_20230227T160221_N0509_R097_T17QLF_20230227T225659_subset20m.znap.zip at java.net.URI.create(URI.java:852) at com.bc.zarr.storage.ZipStore.<init>(ZipStore.java:57) at org.esa.snap.dataio.znap.ZnapProductWriter.writeProductNodesImpl(ZnapProductWriter.java:255) at org.esa.snap.core.dataio.AbstractProductWriter.writeProductNodes(AbstractProductWriter.java:111)

Before the JAR URI is created the URL needs probably be decoded.

Filters implementation

Hello, I'm currently using Jzarr and everything works fine
But I discovered that filters (as well as other things) are not implemented yet, so I need to create my own filter manually
Is this going to be available soon ?

Same question for the addition of other compressors, Zlib and Blosc are great but I want to try others just like in the Python library
In the doc it's written "More compressors will be implemented in the future." but since this project has seen no evolution since 1-2 years it might just be abandoned, and I hope it's still alive

Nested file system store

Implement a chunk name factory to allow nested chunk files.
Such a factory then can be set to and used by any com.bc.zarr.storage.Store implementation to create the name and or path of a chunk file.

Process synchronizing

Jzarr is implemented in a thread save way.
A process synchronizer shall be implemented.
A process synchronizer then can be used in combination or instead of a thread synchronizer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.