Context framework

Configuration options for TensorStore drivers are specified using a context framework, which allows resources such as cache pools, concurrent execution pools, and authentication credentials to be specified using JSON in a way that allows sharing of resources by multiple TensorStore drivers.

json Context : object

A context JSON object is a mapping of resource identifiers to ContextResource specifications.

Optional members:
<resource-type> : ContextResource

Overrides the default resource for the given <resource-type>, which must be a supported resource type.

<resource-type>#<id> : ContextResource

Defines a resource with identifier <id> of the given <resource-type>. The resource specification must be compatible with <resource-type>.


  "cache_pool": {"total_bytes_limit": 10000000},
  "cache_pool#remote": {"total_bytes_limit": 100000000},
  "data_copy_concurrency": {"limit": 8}
json ContextResource : object | boolean | number | string | null

Specifies a context resource of a particular <resource-type>.

One of:
object | boolean | number

Specifies the resource directly. Any constraints on the value are determined by the particular <resource-type>.


References another resource of the same type in the current or parent context using the syntax "<resource-type>" or "<resource-type>#<id>", where <resource-type> matches the type of this resource.


Specifies a new instance of the default resource of the given <resource-type>. Only valid within a Context specification.

json Context.cache_pool : object

Specifies the size of an in-memory Least Recently Used (LRU) cache. Each cache_pool resource specifies a separate memory pool.

Optional members:
total_bytes_limit : integer[0, +∞) = 0

Soft limit on the total number of bytes in the cache. The least-recently used data that is not in use is evicted from the cache when this limit is reached.

json Context.data_copy_concurrency : object

Specifies a limit on the number of CPU cores used concurrently for data copying/encoding/decoding.

Optional members:
limit : integer[1, +∞) | "shared" = "shared"

The maximum number of CPU cores that may be used. If the special value of "shared" is specified, a shared global limit equal to the number of CPU cores/threads available applies.