Skip to content

Commit e4d93f7

Browse files
committed
Update Picos FSStore example.
1 parent 141cc5c commit e4d93f7

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

examples/picos_fs_store.ml

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
(* this module implements a local filesystem zarr store that is backed by
22
the Picos library for concurrent reads/writes. The main requirements
3-
is to implement the signature of Zarr.Types.IO. Here we use
4-
Zarr_sync's Deferred module to implement Zarr.Types.Deferred.
3+
is to implement the signature of Zarr.Types.Store.
54
65
To compile & run this example execute the command
76
dune exec -- examples/picos_fs_store.exe
87
in your shell at the root of this project. *)
98

109
module PU = Picos_io.Unix
11-
module D = Zarr_sync.Storage.Deferred
10+
module IO = Zarr_sync.Storage.IO
1211

1312
module PicosFSStore : sig
14-
include Zarr.Storage.STORE with module Deferred = D
13+
include Zarr.Storage.S with type 'a io := 'a
1514
val create : ?perm:Unix.file_perm -> string -> t
1615
end = struct
1716

18-
module IO = struct
19-
module Deferred = D
20-
17+
module Store = struct
2118
type t = {dirname : string; perm : PU.file_perm}
19+
type 'a io = 'a IO.t
2220

2321
let fspath_to_key t path =
2422
let pos = String.length t.dirname + 1 in
@@ -128,12 +126,12 @@ end = struct
128126
let rename t k k' = PU.rename (key_to_fspath t k) (key_to_fspath t k')
129127
end
130128

129+
include Zarr.Storage.Make(IO)(Store)
130+
131131
let create ?(perm=0o700) dirname =
132132
Zarr.Util.create_parent_dir dirname perm;
133133
Sys.mkdir dirname perm;
134-
IO.{dirname = Zarr.Util.sanitize_dir dirname; perm}
135-
136-
include Zarr.Storage.Make(IO)
134+
Store.{dirname = Zarr.Util.sanitize_dir dirname; perm}
137135
end
138136

139137
let _ =
@@ -148,16 +146,16 @@ let _ =
148146
PicosFSStore.Group.create store gnode;
149147
let anode = Node.Array.(gnode / "name") in
150148
let config =
151-
{chunk_shape = [|5; 3; 5|]
149+
{chunk_shape = [5; 3; 5]
152150
;codecs = [`Bytes LE; `Gzip L5]
153151
;index_codecs = [`Bytes BE; `Crc32c]
154152
;index_location = Start} in
155153
PicosFSStore.Array.create
156154
~codecs:[`ShardingIndexed config]
157-
~shape:[|100; 100; 50|]
158-
~chunks:[|10; 15; 20|]
155+
~shape:[100; 100; 50]
156+
~chunks:[10; 15; 20]
159157
Char '?' anode store;
160-
let slice = [|R [|0; 20|]; I 10; R [||]|] in
158+
let slice = [R (0, 20); I 10; F] in
161159
let x = PicosFSStore.Array.read store anode slice Char in
162160
let x' = Zarr.Ndarray.map (fun _ -> Random.int 256 |> Char.chr) x in
163161
PicosFSStore.Array.write store anode slice x';

0 commit comments

Comments
 (0)