A contiguous, two-dimensional array of integers and a list of strings used to represent a path from the root of an array structure to each item in an array. More...
#include <Identities.h>
Public Member Functions | |
IdentitiesOf (const Ref ref, const FieldLoc &fieldloc, int64_t offset, int64_t width, int64_t length, const std::shared_ptr< T > ptr, kernel::lib ptr_lib=kernel::lib::cpu) | |
Creates an IdentitiesOf from a full set of parameters. | |
IdentitiesOf (const Ref ref, const FieldLoc &fieldloc, int64_t width, int64_t length, kernel::lib ptr_lib=kernel::lib::cpu) | |
Allocates a new array buffer with a given ref, fieldloc, length and width. | |
const std::shared_ptr< T > | ptr () const |
Reference-counted pointer to the array buffer. | |
kernel::lib | ptr_lib () const override |
The Kernel Library that ptr uses. | |
T * | data () const |
Raw pointer to the beginning of data (i.e. offset accounted for). | |
const std::string | classname () const override |
User-friendly name of this class: "Identities32" or "Identities64" . | |
const std::string | identity_at (int64_t at) const override |
Return a string representing an identity tuple at where . | |
const IdentitiesPtr | to64 () const override |
Converts this Identities to an Identities64 . | |
const std::string | tostring_part (const std::string &indent, const std::string &pre, const std::string &post) const override |
Internal function to build an output string for tostring. | |
const IdentitiesPtr | getitem_range_nowrap (int64_t start, int64_t stop) const override |
Subinterval of this array, without handling negative indexing or bounds-checking. | |
void | nbytes_part (std::map< size_t, int64_t > &largest) const override |
Internal function used to calculate Content::nbytes. | |
const IdentitiesPtr | shallow_copy () const override |
Copies this Identities node without copying its buffer. | |
const IdentitiesPtr | deep_copy () const override |
Copies this Identities node and all the data in its buffer. | |
const IdentitiesPtr | getitem_carry_64 (const Index64 &carry) const override |
Returns an Identities array with elements filtered, rearranged, and possibly duplicated by the carry array of integers. | |
const IdentitiesPtr | withfieldloc (const FieldLoc &fieldloc) const override |
Returns this Identities node with a different fieldloc. | |
int64_t | value (int64_t row, int64_t col) const override |
Returns the integer value of the two-dimensional array at row and col . | |
const IdentitiesPtr | copy_to (kernel::lib ptr_lib) const override |
Moves the identity ptr buffer of the array between devices. | |
const std::vector< T > | 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 std::vector< T > | 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 IdentitiesPtr | getitem_range (int64_t start, int64_t stop) const |
Subinterval of this array, handling negative indexing and bounds-checking like Python. | |
bool | referentially_equal (const IdentitiesPtr &other) const override |
Returns true if this Identities has all the same buffers and parameters as other ; false otherwise. | |
![]() | |
Identities (const Ref ref, const FieldLoc &fieldloc, int64_t offset, int64_t width, int64_t length) | |
Called by all subclass constructors; assigns ref, fieldloc, offset, width, and length upon construction. | |
virtual | ~Identities () |
Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted. | |
const Ref | ref () const |
A globally unique reference to this set of identities. | |
const FieldLoc | fieldloc () const |
A list of integer-string pairs indicating the positions of all tuple/record field indicators within the identity tuple. | |
const int64_t | offset () const |
Location of item zero in the buffer, relative to ptr , measured in the number of elements. We keep this information in two parameters (ptr and offset ) rather than moving ptr so that ptr can be reference counted among all arrays that use the same buffer. | |
const int64_t | width () const |
The number of integers in each identity tuple. | |
const int64_t | length () const |
The number of identities in the array. | |
virtual kernel::lib | ptr_lib () const =0 |
The Kernel Library that ptr uses. | |
virtual const std::string | classname () const =0 |
User-friendly name of this class: "Identities32" or "Identities64" . | |
virtual const std::string | identity_at (int64_t where) const =0 |
Return a string representing an identity tuple at where . | |
virtual const IdentitiesPtr | to64 () const =0 |
Converts this Identities to an Identities64 . | |
virtual const std::string | tostring_part (const std::string &indent, const std::string &pre, const std::string &post) const =0 |
Internal function to build an output string for tostring. | |
virtual const IdentitiesPtr | getitem_range_nowrap (int64_t start, int64_t stop) const =0 |
Subinterval of this array, without handling negative indexing or bounds-checking. | |
virtual void | nbytes_part (std::map< size_t, int64_t > &largest) const =0 |
Internal function used to calculate Content::nbytes. | |
virtual const IdentitiesPtr | shallow_copy () const =0 |
Copies this Identities node without copying its buffer. | |
virtual const IdentitiesPtr | deep_copy () const =0 |
Copies this Identities node and all the data in its buffer. | |
virtual const IdentitiesPtr | getitem_carry_64 (const Index64 &carry) const =0 |
Returns an Identities array with elements filtered, rearranged, and possibly duplicated by the carry array of integers. | |
virtual const IdentitiesPtr | withfieldloc (const FieldLoc &fieldloc) const =0 |
Returns this Identities node with a different fieldloc. | |
virtual int64_t | value (int64_t row, int64_t col) const =0 |
Returns the integer value of the two-dimensional array at row and col . | |
virtual const IdentitiesPtr | copy_to (kernel::lib ptr_lib) const =0 |
Moves the identity ptr buffer of the array between devices. | |
const std::string | tostring () const |
Returns a string representation of this array (multi-line XML). | |
virtual bool | referentially_equal (const IdentitiesPtr &other) const =0 |
Returns true if this Identities has all the same buffers and parameters as other ; false otherwise. | |
Additional Inherited Members | |
![]() | |
using | Ref = int64_t |
Identities reference type (64-bit integer). | |
using | FieldLoc = std::vector< std::pair< int64_t, std::string > > |
Identities field location type (integer-string pairs). | |
![]() | |
static Ref | newref () |
Returns a new Identities reference that is globally unique in the current process. | |
static IdentitiesPtr | none () |
A constant, empty Identities pointer (nullptr ). | |
![]() | |
const Ref | ref_ |
See ref. | |
const FieldLoc | fieldloc_ |
See fieldloc. | |
int64_t | offset_ |
See offset. | |
int64_t | width_ |
See width. | |
int64_t | length_ |
See length. | |
A contiguous, two-dimensional array of integers and a list of strings used to represent a path from the root of an array structure to each item in an array.
A single value's identity is equivalent to a tuple of integers and strings:
which corresponds to the "getitem" path from the root of the array to that value:
The fieldloc is a set of integer-string pairs, such as
in the above example. The identities array is two-dimensional so that a single value can be an array, such as
in the above example.
The Identities superclass abstracts over templated specializations:
Identities32
, which is IdentitiesOf<int32_t>
Identities64
, which is IdentitiesOf<int64_t>
IdentitiesOf | ( | const Ref | ref, |
const FieldLoc & | fieldloc, | ||
int64_t | offset, | ||
int64_t | width, | ||
int64_t | length, | ||
const std::shared_ptr< T > | ptr, | ||
kernel::lib | ptr_lib = kernel::lib::cpu |
||
) |
Creates an IdentitiesOf from a full set of parameters.
ref | A globally unique reference to this set of identities. |
fieldloc | A list of integer-string pairs indicating the positions of all tuple/record field indicators within the identity tuple. |
offset | Location of item zero in the buffer, relative to ptr , measured in the number of elements. We keep this information in two parameters (ptr and offset ) rather than moving ptr so that ptr can be reference counted among all arrays that use the same buffer. |
width | The number of integers in each identity tuple. |
length | The number of identities in the array. |
ptr | Reference-counted pointer to the array buffer. |
Choose | the Kernel Library for this array, default:= cpu_kernels. |
IdentitiesOf | ( | const Ref | ref, |
const FieldLoc & | fieldloc, | ||
int64_t | width, | ||
int64_t | length, | ||
kernel::lib | ptr_lib = kernel::lib::cpu |
||
) |
|
overridevirtual |
User-friendly name of this class: "Identities32"
or "Identities64"
.
Implements Identities.
|
overridevirtual |
Moves the identity ptr buffer of the array between devices.
Returns a std::shared_ptr<IdentitiesOf> which is, by default, allocated on the first device(device [0])
Implements Identities.
T * data | ( | ) | const |
Raw pointer to the beginning of data (i.e. offset accounted for).
|
overridevirtual |
Copies this Identities node and all the data in its buffer.
See also shallow_copy.
Implements Identities.
const std::vector< T > 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 std::vector< T > getitem_at_nowrap | ( | int64_t | at | ) | const |
Returns the element at a given position in the array, without handling negative indexing or bounds-checking.
|
overridevirtual |
Returns an Identities array with elements filtered, rearranged, and possibly duplicated by the carry
array of integers.
The output has the same length as the carry
index, not the array
that is being manipulated. For each item i
in carry
, the output is array[index[i]]
.
This operation is called take in NumPy and Arrow, although this carry is a low-level function that does not handle negative indexes and is not exposed to the Python layer. It is used by many operations to pass filters/rearrangements/duplications from one typed array node to another without knowing the latter's type.
Taking getitem_at_nowrap
as a function from integers to the array's item type, A: [0, len(a)) → T
, and the carry
array's Index64::getitem_at_nowrap
as a function C: [0, len(c)) → [0, len(a))
, this method represents function composition, A ∘ C: [0, len(c)) → T
.
Implements Identities.
const IdentitiesPtr getitem_range | ( | int64_t | start, |
int64_t | stop | ||
) | 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.
|
overridevirtual |
Subinterval of this array, without handling negative indexing or bounds-checking.
This operation only affects the node metadata; its calculation time does not scale with the size of the array.
Implements Identities.
|
overridevirtual |
Return a string representing an identity tuple at where
.
Implements Identities.
|
overridevirtual |
Internal function used to calculate Content::nbytes.
largest | The largest range of bytes used in each reference-counted pointer (size_t ). |
Implements Identities.
const std::shared_ptr< T > ptr | ( | ) | const |
Reference-counted pointer to the array buffer.
|
overridevirtual |
The Kernel Library that ptr uses.
Implements Identities.
|
overridevirtual |
Returns true
if this Identities has all the same buffers and parameters as other
; false
otherwise.
other | The Identities to compare this with. |
Implements Identities.
|
overridevirtual |
|
overridevirtual |
Converts this Identities to an Identities64
.
Implements Identities.
|
overridevirtual |
Internal function to build an output string for tostring.
indent | Indentation depth as a string of spaces. |
pre | Prefix string, usually an opening XML tag. |
post | Postfix string, usually a closing XML tag and carriage return. |
Implements Identities.
|
overridevirtual |
Returns the integer value of the two-dimensional array at row
and col
.
Implements Identities.
|
overridevirtual |
Returns this Identities node with a different fieldloc.
Implements Identities.