Class PerImageMetadataStore
- java.lang.Object
-
- org.micromanager.mmomezarr.metadata.PerImageMetadataStore
-
- All Implemented Interfaces:
AutoCloseable
public final class PerImageMetadataStore extends Object implements AutoCloseable
Per-image metadata stored as an append-only NDJSON sidecar (ome-metadata.ndjson): one line{"axes":{...},"meta":<json>}per image.An in-memory
axesKey -> metadataJsonmap is the source of truth for reads and is updated synchronously (viaput(java.lang.String, java.lang.String)) as images are recorded, so metadata is readable the instant an image is queued (mirroring NDTiffStorage's separate index sidecar). The file append (append(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String)) is done separately — on the storage's writer thread — so JSON validation and the flushed disk write never add latency to the acquisition thread. The file is append-only, which keeps it crash-tolerant and safe to tail while writing.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(Map<String,Object> axes, String metadataJson)Append one NDJSON line to the sidecar.voidclose()static PerImageMetadataStorecreateWritable(Path datasetRoot)Open for writing (creates/appends the sidecar).Stringget(String axesKey)Metadata JSON for the given key, or null if none recorded.booleanhas(String axesKey)Set<String>keySet()Unmodifiable view of every recorded axes key (serialized form).static PerImageMetadataStoreopenReadOnly(Path datasetRoot)Open for reading; loads any existing sidecar into the in-memory index.voidput(String axesKey, String metadataJson)Record per-image metadata in the in-memory index (readable immediately).
-
-
-
Method Detail
-
createWritable
public static PerImageMetadataStore createWritable(Path datasetRoot)
Open for writing (creates/appends the sidecar).
-
openReadOnly
public static PerImageMetadataStore openReadOnly(Path datasetRoot)
Open for reading; loads any existing sidecar into the in-memory index.
-
put
public void put(String axesKey, String metadataJson)
Record per-image metadata in the in-memory index (readable immediately). Callappend(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String)afterwards — typically from the writer thread — to persist it.- Parameters:
axesKey- canonical serialized axes keymetadataJson- per-image metadata JSON (may be null)
-
append
public void append(Map<String,Object> axes, String metadataJson)
Append one NDJSON line to the sidecar. Safe to call from a single writer thread while readers useget(java.lang.String); no-op in read-only mode.- Parameters:
axes- the axes map (stored for round-trip)metadataJson- per-image metadata JSON (may be null)
-
has
public boolean has(String axesKey)
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-