Loading...
Searching...
No Matches
PartitionedArray Class Referenceabstract

Abstract superclass of all PartitionedArray node types. PartitionedArrays contain a list of Content, but Content cannot contain PartitionedArrays. More...

#include <PartitionedArray.h>

Inheritance diagram for PartitionedArray:
IrregularlyPartitionedArray

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.
 
const ContentPtrVec partitions () const
 The partitions as a std::vector<std::shared_ptr<Content>>.
 
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>.
 
virtual int64_t start (int64_t partitionid) const =0
 Logical starting index for a given partitionid.
 
virtual int64_t stop (int64_t partitionid) const =0
 Logical stopping index for a given partitionid.
 
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.
 
virtual PartitionedArrayPtr repartition (const std::vector< int64_t > &stops) const =0
 Returns this array with a specified (irregular) partitioning.
 
virtual const std::string classname () const =0
 User-friendly name of this class.
 
virtual const std::string tostring () const =0
 Returns a string representation of this array (multi-line XML).
 
const std::string tojson (bool pretty, int64_t maxdecimals) const
 Returns a JSON representation of this array.
 
void tojson (FILE *destination, bool pretty, int64_t maxdecimals, int64_t buffersize) const
 Writes a JSON representation of this array to a destination file.
 
virtual int64_t length () const =0
 The length of the full array, summed over all partitions.
 
virtual const PartitionedArrayPtr shallow_copy () const =0
 Copies this node without copying any nodes hierarchically nested within it or any array/index/identity buffers.
 
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.
 
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.
 
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.
 
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.
 
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.
 

Protected Attributes

const ContentPtrVec partitions_
 

Detailed Description

Abstract superclass of all PartitionedArray node types. PartitionedArrays contain a list of Content, but Content cannot contain PartitionedArrays.

Constructor & Destructor Documentation

◆ PartitionedArray()

PartitionedArray ( const ContentPtrVec partitions)

◆ ~PartitionedArray()

virtual ~PartitionedArray ( )
virtual

Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted.

Member Function Documentation

◆ classname()

virtual const std::string classname ( ) const
pure virtual

User-friendly name of this class.

Implemented in IrregularlyPartitionedArray.

◆ copy_to()

virtual const PartitionedArrayPtr copy_to ( kernel::lib  ptr_lib) const
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.

◆ getitem_at()

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.

◆ getitem_at_nowrap()

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.

◆ getitem_range()

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.

◆ getitem_range_nowrap()

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.

◆ length()

virtual int64_t length ( ) const
pure virtual

The length of the full array, summed over all partitions.

Implemented in IrregularlyPartitionedArray.

◆ numpartitions()

int64_t numpartitions ( ) const

The number of partitions in this array.

◆ partition()

const ContentPtr partition ( int64_t  partitionid) const

Returns a single partition as a std::shared_ptr<Content>.

◆ partitionid_index_at()

virtual void partitionid_index_at ( int64_t  at,
int64_t &  partitionid,
int64_t &  index 
) const
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.

◆ partitions()

const ContentPtrVec partitions ( ) const

The partitions as a std::vector<std::shared_ptr<Content>>.

◆ repartition()

virtual PartitionedArrayPtr repartition ( const std::vector< int64_t > &  stops) const
pure virtual

Returns this array with a specified (irregular) partitioning.

Implemented in IrregularlyPartitionedArray.

◆ shallow_copy()

virtual const PartitionedArrayPtr shallow_copy ( ) const
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.

◆ start()

virtual int64_t start ( int64_t  partitionid) const
pure virtual

Logical starting index for a given partitionid.

Implemented in IrregularlyPartitionedArray.

◆ stop()

virtual int64_t stop ( int64_t  partitionid) const
pure virtual

Logical stopping index for a given partitionid.

Implemented in IrregularlyPartitionedArray.

◆ tojson() [1/2]

const std::string tojson ( bool  pretty,
int64_t  maxdecimals 
) const

Returns a JSON representation of this array.

Parameters
prettyIf true, add spacing to make the JSON human-readable. If false, return a compact representation.
maxdecimalsMaximum 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.

◆ tojson() [2/2]

void tojson ( FILE *  destination,
bool  pretty,
int64_t  maxdecimals,
int64_t  buffersize 
) const

Writes a JSON representation of this array to a destination file.

Parameters
destinationThe file to write into.
prettyIf true, add spacing to make the JSON human-readable. If false, return a compact representation.
maxdecimalsMaximum number of decimals for floating-point numbers or -1 for no limit.
buffersizeSize 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.

◆ tostring()

virtual const std::string tostring ( ) const
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.

Member Data Documentation

◆ partitions_

const ContentPtrVec partitions_
protected

The documentation for this class was generated from the following file: