Class ZarrJavaBackend
- java.lang.Object
-
- org.micromanager.mmomezarr.backend.ZarrJavaBackend
-
- All Implemented Interfaces:
AutoCloseable,ArrayBackend
public final class ZarrJavaBackend extends Object implements ArrayBackend
DefaultArrayBackendbuilt on zarr-java (Zarr v3), writing through anAtomicFilesystemStoreso chunk and metadata writes are crash- and reader-safe.Group
zarr.jsonfiles are written directly with Jackson (rather than via a zarr-javaGroup) to avoid the root store-handle ambiguity present in zarr-java 0.0.4 — the same workaround used by the siblingome-writersJproject.
-
-
Constructor Summary
Constructors Constructor Description ZarrJavaBackend(Path root)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcreateArray(String arrayId, String relPath, long[] shape, int[] chunkShape, int[] shardShape, String dtype, String compressionId)Create a new array for writing.voidensureShape(String arrayId, long[] minShape)Grow the array so every dimension is at leastminShape; no-op if already big enough.voidflush()Flush any buffered state to durable storage.StringgetDtype(String arrayId)Zarr dtype string of an open array (same form as passed toArrayBackend.createArray(java.lang.String, java.lang.String, long[], int[], int[], java.lang.String, java.lang.String)).long[]getShape(String arrayId)booleanhasArray(String arrayId)voidopenArray(String arrayId, String relPath)Open an existing array for reading (read-only load path).ObjectreadBlock(String arrayId, long[] offset, int[] blockShape)Read a contiguous block of pixels as a primitive array.Map<String,Object>readGroupJson(String relGroupPath)Read a group'sattributesmap, or an empty map if absent.voidwriteBlock(String arrayId, long[] offset, int[] blockShape, Object pixels)Write a contiguous block of pixels.voidwriteGroupJson(String relGroupPath, Map<String,Object> attributes)Write (or overwrite) thezarr.jsonfor a group, atomically.
-
-
-
Constructor Detail
-
ZarrJavaBackend
public ZarrJavaBackend(Path root)
-
-
Method Detail
-
createArray
public void createArray(String arrayId, String relPath, long[] shape, int[] chunkShape, int[] shardShape, String dtype, String compressionId) throws Exception
Description copied from interface:ArrayBackendCreate a new array for writing.- Specified by:
createArrayin interfaceArrayBackend- Parameters:
arrayId- opaque id used in subsequent callsrelPath- path relative to the dataset root (forward-slash separated)shape- initial shapechunkShape- chunk shape (same rank as shape)shardShape- shard shape, or null for no shardingdtype- Zarr dtype string, e.g."uint16"compressionId- codec id ("zstd","blosc-zstd","blosc-lz4", or"none")- Throws:
Exception
-
openArray
public void openArray(String arrayId, String relPath) throws Exception
Description copied from interface:ArrayBackendOpen an existing array for reading (read-only load path).- Specified by:
openArrayin interfaceArrayBackend- Throws:
Exception
-
hasArray
public boolean hasArray(String arrayId)
- Specified by:
hasArrayin interfaceArrayBackend
-
getShape
public long[] getShape(String arrayId)
- Specified by:
getShapein interfaceArrayBackend
-
getDtype
public String getDtype(String arrayId)
Description copied from interface:ArrayBackendZarr dtype string of an open array (same form as passed toArrayBackend.createArray(java.lang.String, java.lang.String, long[], int[], int[], java.lang.String, java.lang.String)).- Specified by:
getDtypein interfaceArrayBackend
-
ensureShape
public void ensureShape(String arrayId, long[] minShape) throws Exception
Description copied from interface:ArrayBackendGrow the array so every dimension is at leastminShape; no-op if already big enough.- Specified by:
ensureShapein interfaceArrayBackend- Throws:
Exception
-
writeBlock
public void writeBlock(String arrayId, long[] offset, int[] blockShape, Object pixels) throws Exception
Description copied from interface:ArrayBackendWrite a contiguous block of pixels.- Specified by:
writeBlockin interfaceArrayBackendoffset- block start offset (full rank)blockShape- block extent (full rank); product must equal the pixel countpixels- primitive array (byte[],short[]orfloat[])- Throws:
Exception
-
readBlock
public Object readBlock(String arrayId, long[] offset, int[] blockShape) throws Exception
Description copied from interface:ArrayBackendRead a contiguous block of pixels as a primitive array.- Specified by:
readBlockin interfaceArrayBackend- Returns:
- a fresh primitive array of
product(blockShape)elements, row-major - Throws:
Exception
-
writeGroupJson
public void writeGroupJson(String relGroupPath, Map<String,Object> attributes) throws Exception
Description copied from interface:ArrayBackendWrite (or overwrite) thezarr.jsonfor a group, atomically.- Specified by:
writeGroupJsonin interfaceArrayBackend- Throws:
Exception
-
readGroupJson
public Map<String,Object> readGroupJson(String relGroupPath) throws Exception
Description copied from interface:ArrayBackendRead a group'sattributesmap, or an empty map if absent.- Specified by:
readGroupJsonin interfaceArrayBackend- Throws:
Exception
-
flush
public void flush()
Description copied from interface:ArrayBackendFlush any buffered state to durable storage.- Specified by:
flushin interfaceArrayBackend
-
close
public void close()
- Specified by:
closein interfaceArrayBackend- Specified by:
closein interfaceAutoCloseable
-
-