Class 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 -> metadataJson map is the source of truth for reads and is updated synchronously (via put(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 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.
      • 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 use get(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)
      • get

        public String get​(String axesKey)
        Metadata JSON for the given key, or null if none recorded.
      • has

        public boolean has​(String axesKey)
      • keySet

        public Set<String> keySet()
        Unmodifiable view of every recorded axes key (serialized form).