#include "tensorstore/open.h"
template <typename Element = void,
         
 DimensionIndex Rank = dynamic_rank,
         
 ReadWriteMode Mode = ReadWriteMode::dynamic>
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(Spec specTransactionalOpenOptions&options);
template <typename Element = void,
         
 DimensionIndex Rank = dynamic_rank,
         
 ReadWriteMode Mode = ReadWriteMode::dynamic,
         
 typename... Option>
  
requires IsCompatibleOptionSequence<TransactionalOpenOptions,
                                     
 Option...>
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(Spec specOption&&... option);
template <typename Element = void,
         
 DimensionIndex Rank = dynamic_rank,
         
 ReadWriteMode Mode = ReadWriteMode::dynamic,
         
 typename J = ::nlohmann::json,
         
 typename... Option>
  
requires IsCompatibleOptionSequence<TransactionalOpenOptions,
                                     
 Option...> &&
          
 std::is_same_v<J, ::nlohmann::json>
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(J json_specOption&&... option);
template <typename Element = void,
         
 DimensionIndex Rank = dynamic_rank,
         
 ReadWriteMode Mode = ReadWriteMode::dynamic,
         
 typename J = ::nlohmann::json>
  
requires std::is_same_v<J, ::nlohmann::json>
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(J json_specTransactionalOpenOptions&options);

Opens a TensorStore from a Spec.

Options are specified in any order after spec. The meaning of the option is determined by its type.

Supported option types include:

  • Context: Shared resource context to use. Defaults to Context::Default().

  • Transaction: Transaction to use for opening. Defaults to no_transaction.

  • Batch: Batch to use for read operations performed when opening. Defaults to no/implicit batching.

  • ReadWriteMode: specifies whether reading and/or writing is supported. Defaults to Mode. Specifying multiple modes as separate options is equivalent to ORing them together.

  • OpenMode: specifies the open mode (overriding any open mode set on spec). Specifying multiple modes as separate options is equivalent to ORing them together.

  • RecheckCached, RecheckCachedData, RecheckCachedMetadata: specifies cache staleness bounds, overriding the corresponding bound or default from spec.

  • kvstore::Spec: specifies the underlying storage, if applicable.

For option types other than ReadWriteMode and OpenMode (for which multiple modes are ORed together), if the same option type is specified more than once, the later value takes precedence; however, for the sake of readability, it is not recommended to rely on this override behavior.

Example usage:

tensorstore::Context context = ...;
TENSORSTORE_ASSIGN_OR_RETURN(auto store,
    tensorstore::Open({{"driver", "zarr"},
                       {"kvstore", {{"driver", "file"},
                                    {"path", "/tmp/data"}}}},
                      context,
                      tensorstore::OpenMode::open,
                      tensorstore::RecheckCached{false},
                      tensorstore::ReadWriteMode::read).result());
Template Parameters:
typename Element = void

Constrains data type at compile time, defaults to void (no constraint).

DimensionIndex Rank = dynamic_rank

Constrains rank at compile time, defaults to dynamic_rank.

ReadWriteMode Mode = ReadWriteMode::dynamic

Constrains read-write mode at compile-time, defaults to ReadWriteMode::dynamic.

Parameters:
Spec spec

The Spec to open.

Option&&... option

Any option compatible with TransactionalOpenOptions.