tensorstore.KvStore.experimental_copy_range_to(self, target: KvStore, source_range: KvStore.KeyRange | None = None, source_staleness_bound: float | None = None) Future[None]

Copies a range of keys.

Warning

This API is experimental and subject to change.

Example

>>> store = await ts.KvStore.open({
...     'driver': 'ocdbt',
...     'base': 'memory://'
... })
>>> await store.write(b'x/a', b'value')
>>> await store.write(b'x/b', b'value')
>>> await store.list()
[b'x/a', b'x/b']
>>> await (store / "x/").experimental_copy_range_to(store / "y/")
>>> await store.list()
[b'x/a', b'x/b', b'y/a', b'y/b']

Note

Depending on the kvstore implementation, this operation may be able to perform the copy without actually re-writing the data.

Parameters:
target: KvStore

Target key-value store.

Warning

This may refer to the same kvstore as self, but the target key range must not overlap with self. If this requirement is violated, the behavior is unspecified.

source_range: KvStore.KeyRange | None = None

Key range to include. This is relative to the existing path, if any. If not specified, all keys under path are copied.

source_staleness_bound: float | None = None

Specifies a time in (fractional) seconds since the Unix epoch. If specified, data that is cached internally by the kvstore implementation may be used without validation if not older than the source_staleness_bound. Cached data older than source_staleness_bound must be validated before being returned. A value of float('inf') indicates that the result must be current as of the time the read request was made, i.e. it is equivalent to specifying a value of time.time(). A value of float('-inf') indicates that cached data may be returned without validation irrespective of its age.

Returns:

  • If no transaction is specified for target, returns a Future that becomes ready when the copy operation has completed and durability is guaranteed (to the extent supported by the driver).

  • If a transaction is specified for target, returns a Future that becomes ready when the copy operation is recorded in the transaction. The copy operation is not actually performed until the transaction is committed.