Interface ArrayBackend
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
ZarrJavaBackend
public interface ArrayBackend extends AutoCloseable
Storage-engine abstraction: creates, grows, writes and reads N-dimensional arrays and writes group metadata, without any knowledge of OME-NGFF semantics. This is the seam that letsOMEZarrStoragetarget a different engine (e.g. a future native/tensorstore backend) than the defaultZarrJavaBackend.Arrays are identified by an opaque string id chosen by the caller. Each id maps to a relative on-disk path (an OME-Zarr array such as
posName/0).Implementations must be safe for a single writer thread with concurrent readers: read methods may be called from other threads while writes proceed.
-
-
Method Summary
All Methods Instance Methods Abstract 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 tocreateArray(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.
-
-
-
Method Detail
-
createArray
void createArray(String arrayId, String relPath, long[] shape, int[] chunkShape, int[] shardShape, String dtype, String compressionId) throws Exception
Create a new array for writing.- 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
void openArray(String arrayId, String relPath) throws Exception
Open an existing array for reading (read-only load path).- Throws:
Exception
-
hasArray
boolean hasArray(String arrayId)
-
getShape
long[] getShape(String arrayId)
-
getDtype
String getDtype(String arrayId)
Zarr dtype string of an open array (same form as passed tocreateArray(java.lang.String, java.lang.String, long[], int[], int[], java.lang.String, java.lang.String)).
-
ensureShape
void ensureShape(String arrayId, long[] minShape) throws Exception
Grow the array so every dimension is at leastminShape; no-op if already big enough.- Throws:
Exception
-
writeBlock
void writeBlock(String arrayId, long[] offset, int[] blockShape, Object pixels) throws Exception
Write a contiguous block of pixels.- Parameters:
offset- block start offset (full rank)blockShape- block extent (full rank); product must equal the pixel countpixels- primitive array (byte[],short[]orfloat[])- Throws:
Exception
-
readBlock
Object readBlock(String arrayId, long[] offset, int[] blockShape) throws Exception
Read a contiguous block of pixels as a primitive array.- Returns:
- a fresh primitive array of
product(blockShape)elements, row-major - Throws:
Exception
-
writeGroupJson
void writeGroupJson(String relGroupPath, Map<String,Object> attributes) throws Exception
Write (or overwrite) thezarr.jsonfor a group, atomically.- Throws:
Exception
-
readGroupJson
Map<String,Object> readGroupJson(String relGroupPath) throws Exception
Read a group'sattributesmap, or an empty map if absent.- Throws:
Exception
-
close
void close()
- Specified by:
closein interfaceAutoCloseable
-
-