-
#include "tensorstore/chunk_layout.h"
-
template <Usage U>
absl::Status
tensorstore::ChunkLayout::Set(const GridViewFor<U>& value); Sets the grid constraints for the specified usage.
- If
value
is of typeWriteChunk
,ReadChunk
, orCodecChunk
, the constraints are set for the corresponding usage indicated by the type.
- If
If
value
is of typeChunk
(i.e.U == kUnspecifiedUsage
), then the constraints are set for the usage indicated by the run-time valuevalue.usage()
. Ifvalue.usage() == kUnspecifiedUsage
, then theGridView::shape
andGridView::elements
apply to write and read chunks, and theGridView::aspect_ratio
applies to write, read, and codec chunks.
For example, to specify constraints on write chunks:
tensorstore::ChunkLayout constraints; TENSORSTORE_RETURN_IF_ERROR(constraints.Set( tensorstore::ChunkLayout::WriteChunk( tensorstore::ChunkLayout::ChunkShape({100, 200}))));
Equivalently, specifying the usage at run time:
TENSORSTORE_RETURN_IF_ERROR(constraints.Set( tensorstore::ChunkLayout::Chunk( tensorstore::ChunkLayout::ChunkShapeBase({100, 200}), tensorstore::ChunkLayout::kWrite)));
To specify common constraints for write, read, and codec chunks:
TENSORSTORE_RETURN_IF_ERROR(constraints.Set( tensorstore::ChunkLayout::Chunk( tensorstore::ChunkLayout::ChunkAspectRatio({1, 2}), tensorstore::ChunkLayout::ChunkElements(5000000))));
Note that the aspect ratio of
{1, 2}
applies to write, read, and codec chunks, but a target number of elements of 5000000 is set only for write and read chunks.