From 901264a858a93985cd79a35a879c9aa7d851909e Mon Sep 17 00:00:00 2001 From: Zolisa Bleki Date: Wed, 3 Jul 2024 19:27:08 +0200 Subject: [PATCH] Use polymorphic variants for chunk key encoding separator. --- lib/extensions.ml | 6 ++---- lib/extensions.mli | 7 +------ lib/metadata.ml | 2 +- lib/metadata.mli | 2 +- lib/storage/storage.ml | 2 +- lib/storage/storage_intf.ml | 2 +- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/extensions.ml b/lib/extensions.ml index 05c46060..ab50eb76 100644 --- a/lib/extensions.ml +++ b/lib/extensions.ml @@ -47,8 +47,6 @@ module RegularGrid = struct Ok y.configuration.chunk_shape end -type separator = Dot | Slash - module ChunkKeyEncoding = struct type encoding = Default | V2 type config = {separator : string} [@@deriving yojson] @@ -56,8 +54,8 @@ module ChunkKeyEncoding = struct type t = {encoding : encoding; sep : string} let create = function - | Dot -> {encoding = Default; sep = "."} - | Slash -> {encoding = Default; sep = "/"} + | `Dot -> {encoding = Default; sep = "."} + | `Slash -> {encoding = Default; sep = "/"} (* map a chunk coordinate index to a key. E.g, (2,3,1) maps to c/2/3/1 *) let encode t index = diff --git a/lib/extensions.mli b/lib/extensions.mli index 97d9ad0e..b4a275dc 100644 --- a/lib/extensions.mli +++ b/lib/extensions.mli @@ -10,14 +10,9 @@ module RegularGrid : sig val to_yojson : t -> Yojson.Safe.t end -type separator = Dot | Slash -(** A type representing the separator in an array chunk's key encoding. - For example, [Dot] is "/", and is used to encode the chunk index - [(0, 3, 5)] as [0/3/5]. *) - module ChunkKeyEncoding : sig type t - val create : separator -> t + val create : [< `Slash | `Dot > `Slash ] -> t val encode : t -> int array -> string val equal : t -> t -> bool val of_yojson : Yojson.Safe.t -> (t, string) result diff --git a/lib/metadata.ml b/lib/metadata.ml index 6b07f6de..49d3a4c6 100644 --- a/lib/metadata.ml +++ b/lib/metadata.ml @@ -117,7 +117,7 @@ module ArrayMetadata = struct [@@deriving yojson, eq] let create - ?(sep=Extensions.Slash) + ?(sep=`Slash) ?(codecs=Codecs.Chain.default) ?(dimension_names=[]) ?(attributes=`Null) diff --git a/lib/metadata.mli b/lib/metadata.mli index e9f5bfd6..882a66cd 100644 --- a/lib/metadata.mli +++ b/lib/metadata.mli @@ -34,7 +34,7 @@ module ArrayMetadata : sig (** A type representing a parsed array metadata document. *) val create : - ?sep:Extensions.separator -> + ?sep:[< `Dot | `Slash > `Slash ] -> ?codecs:Codecs.Chain.t -> ?dimension_names:string option list -> ?attributes:Yojson.Safe.t -> diff --git a/lib/storage/storage.ml b/lib/storage/storage.ml index 78a4cac5..8c298604 100644 --- a/lib/storage/storage.ml +++ b/lib/storage/storage.ml @@ -27,7 +27,7 @@ module Make (M : STORE) : S with type t = M.t = struct | Some n -> create_group t n let create_array - ?(sep=Extensions.Slash) + ?(sep=`Slash) ?(dimension_names=[]) ?(attributes=`Null) ?codecs diff --git a/lib/storage/storage_intf.ml b/lib/storage/storage_intf.ml index 8b2eccdd..546965b0 100644 --- a/lib/storage/storage_intf.ml +++ b/lib/storage/storage_intf.ml @@ -54,7 +54,7 @@ module type S = sig is already a member of this store. *) val create_array - : ?sep:Extensions.separator -> + : ?sep:[< `Dot | `Slash > `Slash ] -> ?dimension_names:string option list -> ?attributes:Yojson.Safe.t -> ?codecs:Codecs.chain ->