#include "tensorstore/tensorstore.h"
template <typename ElementType = void,
         
 DimensionIndex Rank = dynamic_rank,
         
 ReadWriteMode Mode = ReadWriteMode::dynamic>
class tensorstore::TensorStore;

Open handle to an asynchronous multi-dimensional array.

A TensorStore object combines:

  • A shared handle to an underlying TensorStore driver;

  • An index transform applied on top of the TensorStore driver;

  • A ReadWriteMode that constrains the permitted operations.

The free functions Read, Write, Copy, Resize, and ResolveBounds may be used to perform operations on a TensorStore.

Indexing may be performed using the DimExpression facilities. For example:

TensorStore<int32_t, 3> store = ...;
Result<TensorStore<int32_t, 2>> sub_store =
    store | Dims(0).IndexSlice(5);

Typically a TensorStore object is obtained by calling tensorstore::Open.

Template Parameters:
typename ElementType = void

Compile-time element type constraint. May be void to indicate that the element type is determined at run time. Must be unqualified (i.e. must not be const T).

DimensionIndex Rank = dynamic_rank

Compile-time rank constraint. May be dynamic_rank to indicate that the rank is determined at run time.

ReadWriteMode Mode = ReadWriteMode::dynamic

Compile-time read/write mode constraint. May be ReadWriteMode::dynamic to indicate that the read-write mode is determined at run time.

Types

using Element = ElementType;

Element type.

using DataType = dtype_t<Element>;

Static or dynamic data type representation.

using RankType = StaticOrDynamicRank<Rank>;

Static or dynamic rank type representation.

Data members

constexpr const DimensionIndex static_rank = Rank;

Compile-time rank, or dynamic_rank if the rank is determined at run time.

constexpr const ReadWriteMode static_mode = Mode;

Compile-time read-write mode, or ReadWriteMode::dynamic if the mode is determined at run time.

Constructors

TensorStore();

Constructs an invalid TensorStore.

TensorStore(TensorStore<SourceElement, SourceRank, SourceMode> other);

Constructs from a compatible existing TensorStore.

explicit TensorStore(
    
unchecked_t,
    
TensorStore<SourceElement, SourceRank, SourceMode> other);

Unchecked conversion from an existing TensorStore.

Methods

TensorStore&
operator=(TensorStore<SourceElement, SourceRank, SourceMode> other);

Assigns from an existing implicitly compatible TensorStore.

ReadWriteMode read_write_mode() const;

Returns the read-write mode.

bool valid() const noexcept;

Returns true if this is a valid handle to a TensorStore.

DataType dtype() const;

Returns the data type.

RankType rank() const;

Returns the rank.

IndexDomainView<Rank> domain() const;

Returns the domain.

const Transactiontransaction() const;

Returns the associated transaction.

Result<Spec> spec(SpecRequestOptions&options) const;
Result<Spec> spec(Option&&... option) const;

Returns a Spec that may be used to open/recreate this TensorStore.

Result<ChunkLayout> chunk_layout() const;

Returns the storage layout of this TensorStore, which can be used to determine efficient read/write access patterns.

Result<CodecSpec> codec() const;

Returns the codec spec.

Result<SharedArray<const Element>> fill_value() const;

Returns the fill value.

Result<DimensionUnitsVector> dimension_units() const;

Returns the dimension units.

KvStore kvstore() const;

Returns the associated key-value store.

Result<TensorStore<>> base() const;

Returns the underlying TensorStore, if this is an adapter.

Result<Schema> schema() const;

Returns the schema for this TensorStore.

PipelineResultType<const TensorStore&, Func>
operator|(Func&func) const&;
PipelineResultType<TensorStore&&, Func> operator|(Func&func) &&;

“Pipeline” operator.

Friend functions

friend auto ApplyIndexTransform(Expr&exprTensorStore store);

Applies a function that operates on an IndexTransform to a TensorStore.

friend Result<TensorStore>
ApplyTensorStoreTransaction(TensorStore store,
                            
Transaction transaction);

Changes to a new transaction.

enum tensorstore::SourceDataReferenceRestriction;

Specifies restrictions on how references to the source array/source TensorStore may be used by write operations.

enum class tensorstore::ReadWriteMode;

Specifies whether reading and/or writing is permitted.

using tensorstore::TensorReader<Element, Rank> =
   
 TensorStore<Element, Rank, ReadWriteMode::read>;

Read-only TensorStore alias.

using tensorstore::TensorWriter<Element, Rank> =
   
 TensorStore<Element, Rank, ReadWriteMode::write>;

Write-only TensorStore alias.

Result<TensorStore<Element, Rank>>
tensorstore::ModeCast(TensorStore<Element, Rank, ExistingMode> store,
                      
ReadWriteMode new_mode);

Changes the ReadWriteMode of store to the specified new_mode.

WriteFutures tensorstore::Write(SourceArray&source,
                                
Target&target,
                                
WriteOptions options);
WriteFutures tensorstore::Write(SourceArray&source,
                                
Target&target,
                                
Option&&... option);

Copies from a source array to target TensorStore.

WriteFutures tensorstore::Copy(Source&source,
                               
Target&target,
                               
CopyOptions options);
WriteFutures tensorstore::Copy(Source&source,
                               
Target&target,
                               
Option&&... option);

Copies from source TensorStore to target TensorStore.

auto tensorstore::Cast(
    
TensorStore<ElementType, Rank, Mode> store,
    
StaticDataType<TargetElementType> target_dtype = {});
Result<TensorStore<void,
                  
 Rank,
                  
 (Mode == ReadWriteMode::read_write
                       
 ? ReadWriteMode::dynamic
                       
 : Mode)>>
tensorstore::Cast(TensorStore<ElementType, Rank, Mode> store,
                  
DataType target_dtype);

Returns a view of a TensorStore with a converted data type.

Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(Spec specTransactionalOpenOptions&options);
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(Spec specOption&&... option);
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(J json_specOption&&... option);
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(J json_specTransactionalOpenOptions&options);

Opens a TensorStore from a Spec.

I/O

Future<UnwrapResultType<StoreResult>>
tensorstore::ResolveBounds(StoreResult store,
                           
ResolveBoundsOptions options);
Future<UnwrapResultType<StoreResult>>
tensorstore::ResolveBounds(StoreResult storeOption&&... option);

Returns a new TensorStore that is equivalent to store but has implicit bounds resolved if possible, and explicit bounds checked.

Future<UnwrapResultType<StoreResult>> tensorstore::Resize(
    
StoreResult store,
    
span<const Index, UnwrapResultType<StoreResult>::static_rank>
       
 inclusive_min
,
    
span<const Index, UnwrapResultType<StoreResult>::static_rank>
       
 exclusive_max
,
    
ResizeOptions options);
Future<UnwrapResultType<StoreResult>> tensorstore::Resize(
    
StoreResult store,
    
span<const Index, UnwrapResultType<StoreResult>::static_rank>
       
 inclusive_min
,
    
span<const Index, UnwrapResultType<StoreResult>::static_rank>
       
 exclusive_max
,
    
Option&&... option);

Resizes a TensorStore to have the specified inclusive_min and exclusive_max bounds.

Future<void> tensorstore::Read(SourceTensorstore&source,
                               
TargetArray&target,
                               
ReadOptions options);
Future<void> tensorstore::Read(SourceTensorstore&source,
                               
TargetArray&target,
                               
Option&&... option);

Copies from source TensorStore to target array.

Future<
    
SharedArray<typename UnwrapResultType<SourceTensorstore>::Element,
               
 UnwrapResultType<SourceTensorstore>::static_rank,
               
 OriginKind>>
tensorstore::Read(SourceTensorstore&source,
                  
ReadIntoNewArrayOptions options);
Future<
    
SharedArray<typename UnwrapResultType<SourceTensorstore>::Element,
               
 UnwrapResultType<SourceTensorstore>::static_rank,
               
 OriginKind>>
tensorstore::Read(SourceTensorstore&sourceOption&&... option);

Copies from a source TensorStore to a newly-allocated target Array.

Future<ArrayStorageStatistics> tensorstore::GetStorageStatistics(
    
const StoreResultstore,
    
GetArrayStorageStatisticsOptions options);
Future<ArrayStorageStatistics>
tensorstore::GetStorageStatistics(const StoreResultstore,
                                  
Option&&... option);

Retrieves statistics of the data stored within the given array region.