Skip to content

Commit

Permalink
Use polymorphic variants for chunk key encoding separator.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoj613 committed Jul 3, 2024
1 parent 5fe23ef commit ff0b659
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
6 changes: 2 additions & 4 deletions lib/extensions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,15 @@ 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]
type key_encoding = config Util.ExtPoint.t [@@deriving yojson]
type t = {encoding : encoding; sep : string}

let create = function
| Dot -> {encoding = Default; sep = "."}
| Slash -> {encoding = Default; sep = "/"}
| `Dot -> {encoding = Default; sep = "."}

Check warning on line 57 in lib/extensions.ml

View check run for this annotation

Codecov / codecov/patch

lib/extensions.ml#L57

Added line #L57 was not covered by tests
| `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 =
Expand Down
7 changes: 1 addition & 6 deletions lib/extensions.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/metadata.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/metadata.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/storage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/storage_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit ff0b659

Please sign in to comment.