77 Stored Arrays
88=============
99
10+ File arrays
11+ -----------
12+
1013Arrays can be stored on a file system using ``xfile_array ``, enabling
1114persistence of data. This type of array is a file-backed cached ``xarray ``,
1215meaning that you can use it as a normal array, and it will be flushed to the
@@ -16,7 +19,7 @@ file system or Google Cloud Storage, and data can be stored in various formats,
1619e.g. GZip or Blosc.
1720
1821File Mode
19- ---------
22+ ^^^^^^^^^
2023
2124A file array can be created using one of the three following file modes:
2225
@@ -30,9 +33,35 @@ A file array can be created using one of the three following file modes:
3033
3134The default mode is ``load ``.
3235
33- Example : on-disk file array
34- ----------------------------
36+ IO handler
37+ ^^^^^^^^^^
38+
39+ Stored arrays can be read and written to various file systems using an IO
40+ handler, which is a template parameter of ``xfile_array ``. The following IO
41+ handlers are currently supported:
42+
43+ - ``xio_disk_handler ``: for accessing the local file system.
44+ - ``xio_gcs_handler ``: for accessing Google Cloud Storage.
45+
46+ The IO handler is itself templated by a file format.
47+
48+ File format
49+ ^^^^^^^^^^^
3550
51+ An array is stored in a file system using a file format, which usually performs
52+ some kind of compression. A file format has the ability to store the data, and
53+ optionally the shape of the array. It can also optionally be configured. The
54+ following file formats are currently supported:
55+
56+ - ``xio_binary_config ``: raw binary format.
57+ - ``xio_gzip_config ``: GZip format.
58+ - ``xio_blosc_config ``: Blosc format.
59+
60+ These formats currently only store the data, not the shape. GZip and Blosc
61+ formats are configurable, but not the binary format.
62+
63+ Example : on-disk file array
64+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3665
3766.. code :: cpp
3867
@@ -64,13 +93,13 @@ Example : on-disk file array
6493 a2.resize(shape);
6594
6695 // a1 and a2 are equal
67- assert(xt:all(xt::equal(a1, a2)));
96+ assert(xt:: all(xt::equal(a1, a2)));
6897
6998 return 0;
7099 }
71100
72- Stored Chunked Arrays
73- ---------------------
101+ Chunked File Arrays
102+ -------------------
74103
75104As for a "normal" array, a chunked array can be stored on a file system. Under
76105the hood, it will use ``xfile_array `` to store the chunks. But rather than
@@ -79,7 +108,10 @@ only a limited number of file arrays are used at the same time in a chunk pool.
79108The container which is responsible for managing the chunk pool (i.e. map
80109logical chunks in the array to physical chunks in the pool) is the
81110``xchunk_store_manager ``, but you should not use it directly. Instead, we
82- provide factory functions to create a stored chunked array, as shown below:
111+ provide factory functions to create a chunked file array, as shown below:
112+
113+ Example : on-disk chunked file array
114+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
83115
84116.. code-block :: cpp
85117
@@ -105,5 +137,6 @@ provide factory functions to create a stored chunked array, as shown below:
105137 a1(0, 0) = 5.6; // because the pool is full, this saves chunk (1, 0) to disk
106138 // and assigns to chunk (0, 0) in memory
107139 // when a1 is destroyed, all the modified chunks are saved to disk
108- // this can be forced with a1.chunks().flush()
140+ // here, only chunks (0, 1) and (0, 0) are saved, since chunk (1, 0) was not changed
141+ // flushing can be triggered manually by calling a1.chunks().flush()
109142 }
0 commit comments