tensorstore.TensorStore.read(self, *, order: 'C' | 'F' = 'C', batch: Batch | None = None) Future[ArrayLike]

Reads the data within the current domain.

Example

>>> dataset = await ts.open(
...     {
...         'driver': 'zarr',
...         'kvstore': {
...             'driver': 'memory'
...         }
...     },
...     dtype=ts.uint32,
...     shape=[70, 80],
...     create=True)
>>> await dataset[5:10, 8:12].read()
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]], dtype=uint32)

Tip

Depending on the cache behavior of the driver, the read may be satisfied by the cache and not require any I/O.

When not using a transaction, the read result only reflects committed data; the result never includes uncommitted writes.

When using a transaction, the read result reflects all writes completed (but not yet committed) to the transaction.

Parameters:
order: 'C' | 'F' = 'C'

Contiguous layout order of the returned array:

'C'

Specifies C order, i.e. lexicographic/row-major order.

'F'

Specifies Fortran order, i.e. colexicographic/column-major order.

batch: Batch | None = None

Batch to use for the read operation.

Warning

If specified, the returned Future will not, in general, become ready until the batch is submitted. Therefore, immediately awaiting the returned future will lead to deadlock.

Returns:

A future representing the asynchronous read result.

Tip

Synchronous reads (blocking the current thread) may be performed by calling Future.result on the returned future:

>>> dataset[5:10, 8:12].read().result()
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]], dtype=uint32)

See also