TileDB integrates very well with dask.array
. We demonstrate with an example below where attribute attr
stores an int32
value per cell:
You can add any TileDB configuration parameter in storage_options
. Moreover, storage_options
accepts an additional key
option, where you can pass an encryption key if your array is encrypted (see Encryption).
You can also set array chunking similar to Dask's chunking. For example, you can do the following:
You can also write a Dask array into TileDB as follows:
Note that the TileDB array does not need to exist. The above function call will create it if it does not by inferring the schema from the Dask array. To write to an existing array, you should open the array for writing as follows, which will create new fragment(s):
Using an existing Array
object allows extra customization of the array schema beyond what is possible with the automatic array creation shown earlier. For example, to create an array with a compression filter applied to the attribute, create the schema and array first, then write to the open Array
:
dask.delayed
is a powerful feature of Dask that allows you to create arbitrary task graphs and submit them to Dask's scheduler for execution. You can be truly creative with that functionality and implement sophisticated out-of-core computations (i.e., on larger than RAM datasets) and handle highly distributed workloads.
There is no special integration needed with TileDB, as dask.delayed
is quite generic and can work with any user-defined task. We just point out here that you can use TileDB array slicing in a delayed task, which allows you to process truly large TileDB arrays on your laptop or on a large cluster.
We include a very simple example below, stressing though that one can implement much more complex algorithms on arbitrarily large TileDB arrays.
is a great library for parallel computing in Python. It can work on your laptop with multiple threads and processes, or on a large cluster. We will take advantage of two very appealing Dask features:
Dynamic task scheduling. We can create arbitrarily complex task graphs using dask.delayed
and let Dask execute them in parallel in our cluster.
Parallel arrays and dataframes. dask.array
and dask.dataframe
work similar to numpy arrays and Pandas dataframes, respectively, but they are extended to work for datasets larger than the main memory and perform computations in a distributed manner by multiple processes and machines.
TileDB currently integrates only with Dask arrays, but we are working on adding support for Dask dataframes. See our for updates.
Our examples focus only on a single machine, but will work on an arbitrary Dask cluster. Describing how to deploy a Dask cluster though is out of the scope of these docs.
You can install TileDB and Dask as follows: