Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/compressor #37

Merged
merged 11 commits into from
Mar 4, 2024
Merged
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

<json-simple.version>1.1.1</json-simple.version>

<n5.version>3.1.3</n5.version>
<n5.version>3.2.0</n5.version>
<n5-zstandard.version>1.0.2</n5-zstandard.version>

</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.gson.JsonNull;
import com.google.gson.JsonSerializer;
import org.janelia.saalfeldlab.n5.Bzip2Compression;
import org.janelia.saalfeldlab.n5.Compression;
import org.janelia.saalfeldlab.n5.GzipCompression;
Expand Down Expand Up @@ -265,12 +267,12 @@ public Bzip2Compression getCompression() {
}
}

public static class Raw extends RawCompression implements ZarrCompressor {

class Raw implements ZarrCompressor {
public Raw() {}
@Override
public RawCompression getCompression() {

return this;
return new RawCompression();
}
}

Expand All @@ -294,4 +296,6 @@ public ZarrCompressor deserialize(final JsonElement json, final Type typeOfT, fi
return context.deserialize(json, compressorClass);
}
}

JsonSerializer<Raw> rawNullAdapter = (src, typeOfSrc, context) -> JsonNull.INSTANCE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ public ZarrKeyValueReader(
final boolean cacheMeta)
throws N5Exception {

this(checkVersion, keyValueAccess, basePath, gsonBuilder, mapN5DatasetAttributes, mergeAttributes, cacheMeta, true);
}

protected ZarrKeyValueReader(
final boolean checkVersion,
final KeyValueAccess keyValueAccess,
final String basePath,
final GsonBuilder gsonBuilder,
final boolean mapN5DatasetAttributes,
final boolean mergeAttributes,
final boolean cacheMeta,
final boolean checkRootExists
) {


this.keyValueAccess = keyValueAccess;
this.gson = registerGson(gsonBuilder);
this.cacheMeta = cacheMeta;
Expand All @@ -169,6 +184,10 @@ public ZarrKeyValueReader(
cache = newCache();
else
cache = null;

if( checkRootExists && !exists("/"))
throw new N5Exception.N5IOException("No container exists at " + basePath );

}

/**
Expand Down Expand Up @@ -837,6 +856,7 @@ protected static GsonBuilder addTypeAdapters(final GsonBuilder gsonBuilder) {

gsonBuilder.registerTypeAdapter(DataType.class, new DataType.JsonAdapter());
gsonBuilder.registerTypeAdapter(ZarrCompressor.class, ZarrCompressor.jsonAdapter);
gsonBuilder.registerTypeAdapter(ZarrCompressor.Raw.class, ZarrCompressor.rawNullAdapter);
gsonBuilder.registerTypeHierarchyAdapter(Compression.class, CompressionAdapter.getJsonAdapter());
gsonBuilder.registerTypeAdapter(Compression.class, CompressionAdapter.getJsonAdapter());
gsonBuilder.registerTypeAdapter(ZArrayAttributes.class, ZArrayAttributes.jsonAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public ZarrKeyValueWriter(
gsonBuilder,
mapN5DatasetAttributes,
mergeAttributes,
cacheAttributes);
cacheAttributes,
false);
this.dimensionSeparator = dimensionSeparator;
Version version = null;
if (exists("/")) {
Expand Down
Loading
Loading