public class ZarrKeyValueReader extends Object implements org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Reader, org.janelia.saalfeldlab.n5.cache.N5JsonCacheableContainer
N5Reader implementation through KeyValueAccess with JSON attributes parsed with Gson.org.janelia.saalfeldlab.n5.N5Reader.Version| Modifier and Type | Field and Description |
|---|---|
protected ZarrJsonCache |
cache |
protected boolean |
cacheMeta |
protected HashMap<org.janelia.saalfeldlab.n5.DatasetAttributes,ZarrDatasetAttributes> |
datasetAttributesMap |
protected String |
dimensionSeparator |
protected com.google.gson.Gson |
gson |
protected org.janelia.saalfeldlab.n5.KeyValueAccess |
keyValueAccess |
protected boolean |
mapN5DatasetAttributes |
protected boolean |
mergeAttributes |
protected URI |
uri |
static org.janelia.saalfeldlab.n5.N5Reader.Version |
VERSION |
static org.janelia.saalfeldlab.n5.N5Reader.Version |
VERSION_ZERO |
static String |
ZARR_FORMAT_KEY |
static String |
ZARRAY_FILE |
static String |
ZATTRS_FILE |
static String |
ZGROUP_FILE |
NO_VERSION, VERSION_KEY| Modifier | Constructor and Description |
|---|---|
|
ZarrKeyValueReader(boolean checkVersion,
org.janelia.saalfeldlab.n5.KeyValueAccess keyValueAccess,
String basePath,
com.google.gson.GsonBuilder gsonBuilder,
boolean mapN5DatasetAttributes,
boolean mergeAttributes,
boolean cacheMeta)
Opens an
ZarrKeyValueReader at a given base path with a custom GsonBuilder to support custom
attributes. |
protected |
ZarrKeyValueReader(boolean checkVersion,
org.janelia.saalfeldlab.n5.KeyValueAccess keyValueAccess,
String basePath,
com.google.gson.GsonBuilder gsonBuilder,
boolean mapN5DatasetAttributes,
boolean mergeAttributes,
boolean cacheMeta,
boolean checkRootExists) |
|
ZarrKeyValueReader(org.janelia.saalfeldlab.n5.KeyValueAccess keyValueAccess,
String basePath,
com.google.gson.GsonBuilder gsonBuilder,
boolean mapN5DatasetAttributes,
boolean mergeAttributes,
boolean cacheMeta)
Opens an
ZarrKeyValueReader at a given base path with a custom GsonBuilder to support custom
attributes. |
| Modifier and Type | Method and Description |
|---|---|
protected static com.google.gson.GsonBuilder |
addTypeAdapters(com.google.gson.GsonBuilder gsonBuilder) |
boolean |
cacheMeta() |
protected static com.google.gson.JsonElement |
combine(com.google.gson.JsonElement base,
com.google.gson.JsonElement add)
Returns one
JsonElement that combines two others. |
protected static com.google.gson.JsonElement |
combineAll(com.google.gson.JsonElement... elements)
Returns one
JsonElement that (attempts to) combine all passed json elements. |
org.janelia.saalfeldlab.n5.DatasetAttributes |
createDatasetAttributes(com.google.gson.JsonElement attributes) |
boolean |
datasetExists(String pathName) |
boolean |
exists(String pathName) |
boolean |
existsFromContainer(String normalPathName)
Tests whether the key at normalPathName exists for the backend.
|
<T> T |
getAttribute(String pathName,
String key,
Class<T> clazz) |
<T> T |
getAttribute(String pathName,
String key,
Type type) |
com.google.gson.JsonElement |
getAttributes(String path)
Returns the attributes at the given path.
|
com.google.gson.JsonElement |
getAttributesFromContainer(String normalResourceParent,
String normalResourcePath) |
String |
getAttributesKey() |
protected com.google.gson.JsonElement |
getAttributesUnmapped(String path) |
ZarrJsonCache |
getCache() |
ZarrDatasetAttributes |
getConvertedDatasetAttributes(org.janelia.saalfeldlab.n5.DatasetAttributes attributes) |
org.janelia.saalfeldlab.n5.DatasetAttributes |
getDatasetAttributes(String pathName)
Returns the
ZarrDatasetAttributes located at the given path, if present. |
com.google.gson.Gson |
getGson() |
protected com.google.gson.JsonElement |
getJsonResource(String normalPath,
String jsonName)
Returns a
JsonElement representing the contents of a JSON file located at the given path if present, and
null if not. |
org.janelia.saalfeldlab.n5.KeyValueAccess |
getKeyValueAccess() |
URI |
getURI() |
org.janelia.saalfeldlab.n5.N5Reader.Version |
getVersion()
Returns the version of this zarr container.
|
protected static org.janelia.saalfeldlab.n5.N5Reader.Version |
getVersion(com.google.gson.JsonElement json) |
protected com.google.gson.JsonElement |
getZArray(String path)
Returns a
JsonElement representing the contents of .zarray located at the given path if present, and null
if not. |
protected ZArrayAttributes |
getZArrayAttributes(com.google.gson.JsonElement attributes)
Constructs
ZArrayAttributes from a JsonElement. |
ZArrayAttributes |
getZArrayAttributes(String pathName)
Returns the
ZArrayAttributes located at the given path, if present. |
com.google.gson.JsonElement |
getZAttributes(String path)
Returns a
JsonElement representing the contents of .zattrs located at the given path if present, and null
if not. public static JsonObject serialize(JsonSerializationContext context, final DefaultChunkKeyEncoding cke) {
final JsonObject out = new JsonObject(); out.addProperty("name", "default");
final JsonObject config = new JsonObject(); config.addProperty("separator", cke.separator);
out.add("configuration", config);
return out; } |
protected com.google.gson.JsonElement |
getZGroup(String path)
Returns a
JsonElement representing the contents of .zgroup located at the given path if present, and null
if not. |
boolean |
groupExists(String pathName) |
boolean |
isDatasetFromAttributes(String normalCacheKey,
com.google.gson.JsonElement attributes) |
boolean |
isDatasetFromContainer(String normalPathName) |
boolean |
isGroupFromAttributes(String normalCacheKey,
com.google.gson.JsonElement attributes) |
boolean |
isGroupFromContainer(String normalPath) |
protected com.google.gson.JsonElement |
n5ToZarrDatasetAttributes(com.google.gson.JsonElement elem) |
ZarrJsonCache |
newCache() |
protected static com.google.gson.JsonElement |
reverseAttrsWhenCOrder(com.google.gson.JsonElement elem) |
String |
toString() |
protected com.google.gson.JsonElement |
zarrToN5DatasetAttributes(com.google.gson.JsonElement elem) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexistsFromContainer, hasDatasetAttributes, list, listFromContainer, normalGetDatasetAttributesabsoluteAttributesPath, absoluteGroupPath, blockExists, readBlock, readChunk, readChunkslistAttributesclose, deepList, deepList, deepList, deepList, deepList, deepListDatasets, deepListDatasets, deepListDatasets, deepListDatasets, deepListHelper, getGroupSeparator, groupPath, readSerializedBlockpublic static final org.janelia.saalfeldlab.n5.N5Reader.Version VERSION_ZERO
public static final org.janelia.saalfeldlab.n5.N5Reader.Version VERSION
public static final String ZARR_FORMAT_KEY
public static final String ZARRAY_FILE
public static final String ZATTRS_FILE
public static final String ZGROUP_FILE
protected final org.janelia.saalfeldlab.n5.KeyValueAccess keyValueAccess
protected final com.google.gson.Gson gson
protected final ZarrJsonCache cache
protected final boolean cacheMeta
protected URI uri
protected final HashMap<org.janelia.saalfeldlab.n5.DatasetAttributes,ZarrDatasetAttributes> datasetAttributesMap
protected final boolean mapN5DatasetAttributes
protected final boolean mergeAttributes
protected String dimensionSeparator
public ZarrKeyValueReader(boolean checkVersion,
org.janelia.saalfeldlab.n5.KeyValueAccess keyValueAccess,
String basePath,
com.google.gson.GsonBuilder gsonBuilder,
boolean mapN5DatasetAttributes,
boolean mergeAttributes,
boolean cacheMeta)
throws org.janelia.saalfeldlab.n5.N5Exception
ZarrKeyValueReader at a given base path with a custom GsonBuilder to support custom
attributes.checkVersion - perform version checkkeyValueAccess - basePath - N5 base pathgsonBuilder - the gson buildermapN5DatasetAttributes - If true, getAttributes and variants of getAttribute methods will contain keys used by n5 datasets, and
whose values are those for their corresponding zarr fields. For example, if true, the key "dimensions"
(from n5) may be used to obtain the value of the key "shape" (from zarr).mergeAttributes - If true, fields from .zgroup, .zarray, and .zattrs will be merged when calling getAttributes, and
variants of getAttributecacheMeta - cache attributes and meta data Setting this to true avoids frequent reading and parsing of JSON
encoded attributes and other meta data that requires accessing the store. This is most interesting for
high latency backends. Changes of cached attributes and meta data by an independent writer will not be
tracked.org.janelia.saalfeldlab.n5.N5Exception - if the base path cannot be read or does not exist, if the N5 version of the container is not
compatible with this implementation.protected ZarrKeyValueReader(boolean checkVersion,
org.janelia.saalfeldlab.n5.KeyValueAccess keyValueAccess,
String basePath,
com.google.gson.GsonBuilder gsonBuilder,
boolean mapN5DatasetAttributes,
boolean mergeAttributes,
boolean cacheMeta,
boolean checkRootExists)
public ZarrKeyValueReader(org.janelia.saalfeldlab.n5.KeyValueAccess keyValueAccess, String basePath, com.google.gson.GsonBuilder gsonBuilder, boolean mapN5DatasetAttributes, boolean mergeAttributes, boolean cacheMeta) throws org.janelia.saalfeldlab.n5.N5Exception
ZarrKeyValueReader at a given base path with a custom GsonBuilder to support custom
attributes.keyValueAccess - basePath - N5 base pathgsonBuilder - cacheMeta - cache attributes and meta data Setting this to true avoids frequent reading and parsing of JSON
encoded attributes and other meta data that requires accessing the store. This is most interesting for
high latency backends. Changes of cached attributes and meta data by an independent writer will not be
tracked.org.janelia.saalfeldlab.n5.N5Exception - if the base path cannot be read or does not exist, if the N5 version of the container is not
compatible with this implementation.public String getAttributesKey()
getAttributesKey in interface org.janelia.saalfeldlab.n5.GsonN5Readerpublic com.google.gson.Gson getGson()
getGson in interface org.janelia.saalfeldlab.n5.GsonN5Readerpublic ZarrJsonCache newCache()
newCache in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerpublic boolean cacheMeta()
cacheMeta in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerpublic ZarrJsonCache getCache()
getCache in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerpublic org.janelia.saalfeldlab.n5.KeyValueAccess getKeyValueAccess()
getKeyValueAccess in interface org.janelia.saalfeldlab.n5.GsonKeyValueN5Readerpublic URI getURI()
getURI in interface org.janelia.saalfeldlab.n5.N5Readerpublic org.janelia.saalfeldlab.n5.N5Reader.Version getVersion() throws org.janelia.saalfeldlab.n5.N5Exception
getVersion in interface org.janelia.saalfeldlab.n5.N5ReaderVersionorg.janelia.saalfeldlab.n5.N5Exceptionpublic boolean exists(String pathName)
exists in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerexists in interface org.janelia.saalfeldlab.n5.GsonKeyValueN5Readerexists in interface org.janelia.saalfeldlab.n5.N5Readerpublic boolean existsFromContainer(String normalPathName)
normalPathName - normalized path namepublic boolean groupExists(String pathName)
groupExists in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5ReadergroupExists in interface org.janelia.saalfeldlab.n5.GsonKeyValueN5Readerpublic boolean isGroupFromContainer(String normalPath)
isGroupFromContainer in interface org.janelia.saalfeldlab.n5.cache.N5JsonCacheableContainerisGroupFromContainer in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerpublic boolean isGroupFromAttributes(String normalCacheKey, com.google.gson.JsonElement attributes)
isGroupFromAttributes in interface org.janelia.saalfeldlab.n5.cache.N5JsonCacheableContainerisGroupFromAttributes in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerpublic boolean datasetExists(String pathName) throws org.janelia.saalfeldlab.n5.N5Exception.N5IOException
datasetExists in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5ReaderdatasetExists in interface org.janelia.saalfeldlab.n5.GsonKeyValueN5ReaderdatasetExists in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exception.N5IOExceptionpublic boolean isDatasetFromContainer(String normalPathName) throws org.janelia.saalfeldlab.n5.N5Exception
isDatasetFromContainer in interface org.janelia.saalfeldlab.n5.cache.N5JsonCacheableContainerisDatasetFromContainer in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic boolean isDatasetFromAttributes(String normalCacheKey, com.google.gson.JsonElement attributes)
isDatasetFromAttributes in interface org.janelia.saalfeldlab.n5.cache.N5JsonCacheableContainerisDatasetFromAttributes in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerpublic org.janelia.saalfeldlab.n5.DatasetAttributes getDatasetAttributes(String pathName) throws org.janelia.saalfeldlab.n5.N5Exception
ZarrDatasetAttributes located at the given path, if present.getDatasetAttributes in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5ReadergetDatasetAttributes in interface org.janelia.saalfeldlab.n5.GsonN5ReadergetDatasetAttributes in interface org.janelia.saalfeldlab.n5.N5ReaderpathName - the path relative to the container's rootorg.janelia.saalfeldlab.n5.N5Exception - the exceptionpublic ZarrDatasetAttributes getConvertedDatasetAttributes(org.janelia.saalfeldlab.n5.DatasetAttributes attributes)
getConvertedDatasetAttributes in interface org.janelia.saalfeldlab.n5.N5Readerpublic ZArrayAttributes getZArrayAttributes(String pathName) throws org.janelia.saalfeldlab.n5.N5Exception
ZArrayAttributes located at the given path, if present.pathName - the path relative to the container's rootorg.janelia.saalfeldlab.n5.N5Exception - the exceptionprotected ZArrayAttributes getZArrayAttributes(com.google.gson.JsonElement attributes)
ZArrayAttributes from a JsonElement.attributes - the json elementpublic org.janelia.saalfeldlab.n5.DatasetAttributes createDatasetAttributes(com.google.gson.JsonElement attributes)
createDatasetAttributes in interface org.janelia.saalfeldlab.n5.GsonN5Readerpublic <T> T getAttribute(String pathName, String key, Class<T> clazz) throws org.janelia.saalfeldlab.n5.N5Exception
getAttribute in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5ReadergetAttribute in interface org.janelia.saalfeldlab.n5.GsonN5ReadergetAttribute in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionpublic <T> T getAttribute(String pathName, String key, Type type) throws org.janelia.saalfeldlab.n5.N5Exception
getAttribute in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5ReadergetAttribute in interface org.janelia.saalfeldlab.n5.GsonN5ReadergetAttribute in interface org.janelia.saalfeldlab.n5.N5Readerorg.janelia.saalfeldlab.n5.N5Exceptionprotected com.google.gson.JsonElement getJsonResource(String normalPath, String jsonName) throws org.janelia.saalfeldlab.n5.N5Exception
JsonElement representing the contents of a JSON file located at the given path if present, and
null if not. Also updates the cache.normalPath - the normalized pathjsonName - the name of the JSON fileorg.janelia.saalfeldlab.n5.N5Exception - the exceptionprotected static com.google.gson.JsonElement reverseAttrsWhenCOrder(com.google.gson.JsonElement elem)
protected com.google.gson.JsonElement getZGroup(String path) throws org.janelia.saalfeldlab.n5.N5Exception
JsonElement representing the contents of .zgroup located at the given path if present, and null
if not.path - the pathorg.janelia.saalfeldlab.n5.N5Exception - the exceptionprotected com.google.gson.JsonElement getZArray(String path) throws org.janelia.saalfeldlab.n5.N5Exception
JsonElement representing the contents of .zarray located at the given path if present, and null
if not.path - the pathorg.janelia.saalfeldlab.n5.N5Exception - the exceptionprotected com.google.gson.JsonElement zarrToN5DatasetAttributes(com.google.gson.JsonElement elem)
protected com.google.gson.JsonElement n5ToZarrDatasetAttributes(com.google.gson.JsonElement elem)
public com.google.gson.JsonElement getZAttributes(String path) throws org.janelia.saalfeldlab.n5.N5Exception
JsonElement representing the contents of .zattrs located at the given path if present, and null
if not. public static JsonObject serialize(JsonSerializationContext context, final DefaultChunkKeyEncoding cke) {
final JsonObject out = new JsonObject(); out.addProperty("name", "default");
final JsonObject config = new JsonObject(); config.addProperty("separator", cke.separator);
out.add("configuration", config);
return out; }path - the pathorg.janelia.saalfeldlab.n5.N5Exception - the exceptionpublic com.google.gson.JsonElement getAttributes(String path) throws org.janelia.saalfeldlab.n5.N5Exception
If this reader was constructed with mergeAttributes as true, this method will attempt to combine the contents of
.zgroup, .zarray, and .zattrs, when present using ZarrUtils#combineAll(JsonElement...). Otherwise, this
method will return only the contents of .zattrs, as getZAttributes.
getAttributes in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5ReadergetAttributes in interface org.janelia.saalfeldlab.n5.GsonKeyValueN5ReadergetAttributes in interface org.janelia.saalfeldlab.n5.GsonN5Readerpath - the pathorg.janelia.saalfeldlab.n5.N5Exception - the exceptionprotected com.google.gson.JsonElement getAttributesUnmapped(String path) throws org.janelia.saalfeldlab.n5.N5Exception
public com.google.gson.JsonElement getAttributesFromContainer(String normalResourceParent, String normalResourcePath) throws org.janelia.saalfeldlab.n5.N5Exception
getAttributesFromContainer in interface org.janelia.saalfeldlab.n5.cache.N5JsonCacheableContainergetAttributesFromContainer in interface org.janelia.saalfeldlab.n5.CachedGsonKeyValueN5Readerorg.janelia.saalfeldlab.n5.N5Exceptionprotected static org.janelia.saalfeldlab.n5.N5Reader.Version getVersion(com.google.gson.JsonElement json)
protected static com.google.gson.JsonElement combineAll(com.google.gson.JsonElement... elements)
JsonElement that (attempts to) combine all passed json elements. Reduces the list by
repeatedly calling the two-argument combine method.elements - an array of json elementsprotected static com.google.gson.JsonElement combine(com.google.gson.JsonElement base, com.google.gson.JsonElement add)
JsonElement that combines two others. The returned instance is a deep copy, and the arguments
are not modified. A copy of base element is returned if the two arguments can not be combined. The two arguments
may be combined if they are both JsonObjects or both JsonArrays.
If both arguments are JsonObjects, every key-value pair in the add argument is added to the (copy of) the
base argument, overwriting any duplicate keys. If both arguments are JsonArrays, the add argument is
concatenated to the (copy of) the base argument.
base - the base elementadd - the element to addprotected static com.google.gson.GsonBuilder addTypeAdapters(com.google.gson.GsonBuilder gsonBuilder)
Copyright © 2019–2026 Saalfeld Lab. All rights reserved.