Abstract superclass of all PartitionedArray node types. PartitionedArrays contain a list of Content, but Content cannot contain PartitionedArrays. More...
#include <PartitionedArray.h>
Public Member Functions | |
PartitionedArray (const ContentPtrVec &partitions) | |
virtual | ~PartitionedArray () |
Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted. More... | |
const ContentPtrVec | partitions () const |
The partitions as a std::vector<std::shared_ptr<Content>> . More... | |
int64_t | numpartitions () const |
The number of partitions in this array. More... | |
const ContentPtr | partition (int64_t partitionid) const |
Returns a single partition as a std::shared_ptr<Content> . More... | |
virtual int64_t | start (int64_t partitionid) const =0 |
Logical starting index for a given partitionid. More... | |
virtual int64_t | stop (int64_t partitionid) const =0 |
Logical stopping index for a given partitionid. More... | |
virtual void | partitionid_index_at (int64_t at, int64_t &partitionid, int64_t &index) const =0 |
Gets the partitionid and index for a given logical position in the full array, without handling negative indexing or bounds-checking. More... | |
virtual PartitionedArrayPtr | repartition (const std::vector< int64_t > &stops) const =0 |
Returns this array with a specified (irregular) partitioning. More... | |
virtual const std::string | classname () const =0 |
User-friendly name of this class. More... | |
virtual const std::string | tostring () const =0 |
Returns a string representation of this array (multi-line XML). More... | |
const std::string | tojson (bool pretty, int64_t maxdecimals) const |
Returns a JSON representation of this array. More... | |
void | tojson (FILE *destination, bool pretty, int64_t maxdecimals, int64_t buffersize) const |
Writes a JSON representation of this array to a destination file. More... | |
virtual int64_t | length () const =0 |
The length of the full array, summed over all partitions. More... | |
virtual const PartitionedArrayPtr | shallow_copy () const =0 |
Copies this node without copying any nodes hierarchically nested within it or any array/index/identity buffers. More... | |
const ContentPtr | getitem_at (int64_t at) const |
Returns the element at a given position in the array, handling negative indexing and bounds-checking like Python. More... | |
const ContentPtr | getitem_at_nowrap (int64_t at) const |
Returns the element at a given position in the array, without handling negative indexing or bounds-checking. More... | |
const PartitionedArrayPtr | getitem_range (int64_t start, int64_t stop, int64_t step) const |
Subinterval of this array, handling negative indexing and bounds-checking like Python. More... | |
const PartitionedArrayPtr | getitem_range_nowrap (int64_t start, int64_t stop, int64_t step) const |
Subinterval of this array, without handling negative indexing or bounds-checking. More... | |
virtual const PartitionedArrayPtr | copy_to (kernel::lib ptr_lib) const =0 |
Recursively copies components of the array from main memory to a GPU (if ptr_lib == kernel::lib::cuda ) or to main memory (if ptr_lib == kernel::lib::cpu ) if those components are not already there. More... | |
Protected Attributes | |
const ContentPtrVec | partitions_ |
Abstract superclass of all PartitionedArray node types. PartitionedArrays contain a list of Content, but Content cannot contain PartitionedArrays.
PartitionedArray | ( | const ContentPtrVec & | partitions | ) |
|
virtual |
Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted.
|
pure virtual |
User-friendly name of this class.
Implemented in IrregularlyPartitionedArray.
|
pure virtual |
Recursively copies components of the array from main memory to a GPU (if ptr_lib == kernel::lib::cuda
) or to main memory (if ptr_lib == kernel::lib::cpu
) if those components are not already there.
Implemented in IrregularlyPartitionedArray.
const ContentPtr getitem_at | ( | int64_t | at | ) | const |
Returns the element at a given position in the array, handling negative indexing and bounds-checking like Python.
The first item in the array is at 0
, the second at 1
, the last at -1
, the penultimate at -2
, etc.
const ContentPtr getitem_at_nowrap | ( | int64_t | at | ) | const |
Returns the element at a given position in the array, without handling negative indexing or bounds-checking.
If the array has Identities, the identity bounds are checked.
const PartitionedArrayPtr getitem_range | ( | int64_t | start, |
int64_t | stop, | ||
int64_t | step | ||
) | const |
Subinterval of this array, handling negative indexing and bounds-checking like Python.
The first item in the array is at 0
, the second at 1
, the last at -1
, the penultimate at -2
, etc.
Ranges beyond the array are not an error; they are trimmed to start = 0
on the left and stop = length() - 1
on the right.
This operation only affects the node metadata; its calculation time does not scale with the size of the array.
const PartitionedArrayPtr getitem_range_nowrap | ( | int64_t | start, |
int64_t | stop, | ||
int64_t | step | ||
) | const |
Subinterval of this array, without handling negative indexing or bounds-checking.
If the array has Identities, the identity bounds are checked.
This operation only affects the node metadata; its calculation time does not scale with the size of the array.
|
pure virtual |
The length of the full array, summed over all partitions.
Implemented in IrregularlyPartitionedArray.
int64_t numpartitions | ( | ) | const |
The number of partitions in this array.
const ContentPtr partition | ( | int64_t | partitionid | ) | const |
Returns a single partition as a std::shared_ptr<Content>
.
|
pure virtual |
Gets the partitionid and index for a given logical position in the full array, without handling negative indexing or bounds-checking.
Implemented in IrregularlyPartitionedArray.
const ContentPtrVec partitions | ( | ) | const |
The partitions as a std::vector<std::shared_ptr<Content>>
.
|
pure virtual |
Returns this array with a specified (irregular) partitioning.
Implemented in IrregularlyPartitionedArray.
|
pure virtual |
Copies this node without copying any nodes hierarchically nested within it or any array/index/identity buffers.
See also #deep_copy.
Implemented in IrregularlyPartitionedArray.
|
pure virtual |
Logical starting index for a given partitionid.
Implemented in IrregularlyPartitionedArray.
|
pure virtual |
Logical stopping index for a given partitionid.
Implemented in IrregularlyPartitionedArray.
const std::string tojson | ( | bool | pretty, |
int64_t | maxdecimals | ||
) | const |
Returns a JSON representation of this array.
pretty | If true , add spacing to make the JSON human-readable. If false , return a compact representation. |
maxdecimals | Maximum number of decimals for floating-point numbers or -1 for no limit. |
Although the JSON output contains all of the data from the array (and therefore might not be safe to print to the screen), it does not preserve the type information of an array. In particular, the distinction between ListType and RegularType is lost.
void tojson | ( | FILE * | destination, |
bool | pretty, | ||
int64_t | maxdecimals, | ||
int64_t | buffersize | ||
) | const |
Writes a JSON representation of this array to a destination
file.
destination | The file to write into. |
pretty | If true , add spacing to make the JSON human-readable. If false , return a compact representation. |
maxdecimals | Maximum number of decimals for floating-point numbers or -1 for no limit. |
buffersize | Size of a temporary buffer in bytes. |
Although the JSON output contains all of the data from the array (and therefore might not be safe to print to the screen), it does not preserve the type information of an array. In particular, the distinction between ListType and RegularType is lost.
|
pure virtual |
Returns a string representation of this array (multi-line XML).
Although this XML string has detail about every node in the tree, it does not show all elements in the array buffers and therefore does not scale with the size of the dataset (i.e. it is safe to print to the screen).
Thus, it's also not a storage format: see tojson.
Implemented in IrregularlyPartitionedArray.
|
protected |