1
1
(* this module implements a local filesystem zarr store that is backed by
2
2
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.
5
4
6
5
To compile & run this example execute the command
7
6
dune exec -- examples/picos_fs_store.exe
8
7
in your shell at the root of this project. *)
9
8
10
9
module PU = Picos_io. Unix
11
- module D = Zarr_sync.Storage. Deferred
10
+ module IO = Zarr_sync.Storage. IO
12
11
13
12
module PicosFSStore : sig
14
- include Zarr.Storage. STORE with module Deferred = D
13
+ include Zarr.Storage. S with type 'a io := 'a
15
14
val create : ?perm : Unix .file_perm -> string -> t
16
15
end = struct
17
16
18
- module IO = struct
19
- module Deferred = D
20
-
17
+ module Store = struct
21
18
type t = {dirname : string ; perm : PU .file_perm }
19
+ type 'a io = 'a IO .t
22
20
23
21
let fspath_to_key t path =
24
22
let pos = String. length t.dirname + 1 in
@@ -128,12 +126,12 @@ end = struct
128
126
let rename t k k' = PU. rename (key_to_fspath t k) (key_to_fspath t k')
129
127
end
130
128
129
+ include Zarr.Storage. Make (IO )(Store )
130
+
131
131
let create ?(perm =0o700 ) dirname =
132
132
Zarr.Util. create_parent_dir dirname perm;
133
133
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}
137
135
end
138
136
139
137
let _ =
@@ -148,16 +146,16 @@ let _ =
148
146
PicosFSStore.Group. create store gnode;
149
147
let anode = Node.Array. (gnode / " name" ) in
150
148
let config =
151
- {chunk_shape = [| 5 ; 3 ; 5 | ]
149
+ {chunk_shape = [5 ; 3 ; 5 ]
152
150
;codecs = [`Bytes LE ; `Gzip L5 ]
153
151
;index_codecs = [`Bytes BE ; `Crc32c ]
154
152
;index_location = Start } in
155
153
PicosFSStore.Array. create
156
154
~codecs: [`ShardingIndexed config]
157
- ~shape: [| 100 ; 100 ; 50 | ]
158
- ~chunks: [| 10 ; 15 ; 20 | ]
155
+ ~shape: [100 ; 100 ; 50 ]
156
+ ~chunks: [10 ; 15 ; 20 ]
159
157
Char '?' anode store;
160
- let slice = [| R [| 0 ; 20 |] ; I 10 ; R [||]| ] in
158
+ let slice = [R ( 0 , 20 ) ; I 10 ; F ] in
161
159
let x = PicosFSStore.Array. read store anode slice Char in
162
160
let x' = Zarr.Ndarray. map (fun _ -> Random. int 256 |> Char. chr) x in
163
161
PicosFSStore.Array. write store anode slice x';
0 commit comments