package zarr-lwt

  1. Overview
  2. Docs

An in-memory storage backend for Zarr V3 hierarchy.

include Zarr.Storage.STORE with type 'a Deferred.t = 'a Lwt.t
module Deferred : Zarr.Types.Deferred with type 'a t = 'a Lwt.t
type t

The storage type.

val create_group : ?attrs:Yojson.Safe.t -> t -> Zarr.Node.GroupNode.t -> unit Deferred.t

create_group ?attrs t node creates a group node in store t containing attributes attrs. This is a no-op if node is already a member of this store.

val create_array : ?sep:[< `Dot | `Slash Slash ] -> ?dimension_names:string option list -> ?attributes:Yojson.Safe.t -> codecs:Zarr.Codecs.codec_chain -> shape:int array -> chunks:int array -> 'a Zarr.Ndarray.dtype -> 'a -> Zarr.Node.ArrayNode.t -> t -> unit Deferred.t

create_array ~sep ~dimension_names ~attributes ~codecs ~shape ~chunks kind fill node t creates an array node in store t where:

  • Separator sep is used in the array's chunk key encoding.
  • Dimension names dimension_names and user attributes attributes are included in it's metadata document.
  • A codec chain defined by codecs.
  • The array has shape shape and chunk shape chunks.
  • The array has data kind kind and fill value fv.
  • raises Codecs.Bytes_to_bytes_invariant

    if codecs contains more than one bytes->bytes codec.

  • raises Codecs.Invalid_transpose_order

    if codecs contains a transpose codec with invalid order array.

  • raises Codecs.Invalid_sharding_chunk_shape

    if codecs contains a shardingindexed codec with an incorrect inner chunk shape.

array_metadata node t returns the metadata of array node node.

  • raises Key_not_found

    if node is not a member of store t.

group_metadata node t returns the metadata of group node node.

  • raises Key_not_found

    if node is not a member of store t.

find_child_nodes t n returns a tuple of child nodes of group node n. This operation returns a pair of empty lists if node n has no children or is not a member of store t.

  • raises Parse_error

    if any child node has invalid node_type metadata.

val find_all_nodes : t -> (Zarr.Node.ArrayNode.t list * Zarr.Node.GroupNode.t list) Deferred.t

find_all_nodes t returns Some p where p is a pair of lists representing all nodes in store t. The first element of the pair is a list of all array nodes, and the second element is a list of all group nodes. This operation returns a pair of empty lists if store t is empty.

  • raises Parse_error

    if any node has invalid node_type metadata.

val erase_group_node : t -> Zarr.Node.GroupNode.t -> unit Deferred.t

erase_group_node t n erases group node n from store t. This also erases all child nodes of n. If node n is not a member of store t then this is a no-op.

val erase_array_node : t -> Zarr.Node.ArrayNode.t -> unit Deferred.t

erase_array_node t n erases group node n from store t. This also erases all child nodes of n. If node n is not a member of store t then this is a no-op.

val erase_all_nodes : t -> unit Deferred.t

erase_all_nodes t clears the store t by deleting all nodes. If the store is already empty, this is a no-op.

val group_exists : t -> Zarr.Node.GroupNode.t -> bool Deferred.t

group_exists t n returns true if group node n is a member of store t and false otherwise.

val array_exists : t -> Zarr.Node.ArrayNode.t -> bool Deferred.t

array_exists t n returns true if array node n is a member of store t and false otherwise.

write_array t n s x writes n-dimensional array x to the slice s of array node n in store t.

  • raises Invalid_array_slice

    if the ndarray x size does not equal slice s.

  • raises Invalid_data_type

    if the kind of x is not compatible with node n's data type as described in its metadata document.

read_array t n s k reads an n-dimensional array of size determined by slice s from array node n.

  • raises Invalid_data_type

    if kind k is not compatible with node n's data type as described in its metadata document.

  • raises Invalid_array_slice

    if the slice s is not a valid slice of array node n.

val reshape : t -> Zarr.Node.ArrayNode.t -> int array -> unit Deferred.t

reshape t n shape resizes array node n of store t into new size shape.

  • raises Invalid_resize_shape

    if shape does not have the same dimensions as n's shape.

  • raises Key_not_found

    if node n is not a member of store t.

val create : unit -> t

create () returns a new In-memory Zarr store type.

OCaml

Innovation. Community. Security.