Awkward Array: ArrayGenerator Class Reference

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
ArrayGenerator Class Referenceabstract

Abstract superclass to generate arrays for VirtualArray, defining the interface. More...

`#include <ArrayGenerator.h>`

Inheritance diagram for ArrayGenerator:

## Public Member Functions
| ArrayGenerator (const FormPtr &form, int64_t length)
| Called by subclasses to set the form of an ArrayGenerator. More...
virtual | ~ArrayGenerator ()
| Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted. More...
const FormPtr | form () const
| The Form the generated array is expected to take; may be `nullptr`. More...
int64_t | length () const
| The length the generated array is expected to have; may be negative to indicate that the length is unknown. More...
virtual const ContentPtr | generate () const =0
| Creates an array but does not check it against the form. More...
const ContentPtr | generate_and_check ()
| Creates an array and checks it against the form. If form was not available initially, no check is made and the form inferred from the result is saved in case it is useful later. More...
virtual void | caches (std::vector< ArrayCachePtr > &out) const =0
| Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determined by pointer value.) More...
virtual const std::string | tostring_part (const std::string &indent, const std::string &pre, const std::string &post) const =0
| Returns a string representation of this ArrayGenerator. More...
virtual const std::shared_ptr< ArrayGenerator > | shallow_copy () const =0
| Copies this ArrayGenerator, referencing any contents. More...
virtual const std::shared_ptr< ArrayGenerator > | with_form (const FormPtr &form) const =0
| Return a copy of this ArrayGenerator with a different form (or a now-known form, whereas it might have been unknown before). More...
virtual const std::shared_ptr< ArrayGenerator > | with_length (int64_t length) const =0
| Return a copy of this ArrayGenerator with a different length (or a now-known length, whereas it might have been unknown before). More...
virtual bool | referentially_equal (const ArrayGeneratorPtr &other) const =0
| Returns `true` if this generator has all the same buffers and parameters as `other`; `false` otherwise. More...

## Protected Attributes
const FormPtr | form_
FormPtr | inferred_form_ {nullptr}
int64_t | length_

## Detailed Description

Abstract superclass to generate arrays for VirtualArray, defining the interface.

The main implementation, PyArrayGenerator, is passed through pybind11 to Python to work with Python functions and lambdas, but in principle, pure C++ generators could be written.

## Constructor & Destructor Documentation

## ◆ ArrayGenerator()

ArrayGenerator | ( | const FormPtr & | form,
|  | int64_t | length
| ) |  |

Called by subclasses to set the form of an ArrayGenerator.

The form can be `nullptr`, in which case the generated array can have any Form and any Type, but doing so would cause VirtualArray to materialize in more circumstances, undermining its usefulness.

Similarly, the length can be specified to avoid materializing a VirtualArray when its length must be known. Any negative value, such as -1, is interpreted as "unknown."

## ◆ ~ArrayGenerator()

virtual ~ArrayGenerator | ( |  | ) |
| 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

## ◆ caches()

virtual void caches | ( | std::vector< ArrayCachePtr > & | out | ) | const
| pure virtual

Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determined by pointer value.)

Implemented in PyArrayGenerator, and SliceGenerator.

## ◆ form()

const FormPtr form | ( |  | ) | const

The Form the generated array is expected to take; may be `nullptr`.

## ◆ generate()

virtual const ContentPtr generate | ( |  | ) | const
| pure virtual

Creates an array but does not check it against the form.

Implemented in PyArrayGenerator, and SliceGenerator.

## ◆ generate_and_check()

const ContentPtr generate_and_check | ( |  | ) |

Creates an array and checks it against the form. If form was not available initially, no check is made and the form inferred from the result is saved in case it is useful later.

## ◆ length()

int64_t length | ( |  | ) | const

The length the generated array is expected to have; may be negative to indicate that the length is unknown.

## ◆ referentially_equal()

virtual bool referentially_equal | ( | const ArrayGeneratorPtr & | other | ) | const
| pure virtual

Returns `true` if this generator has all the same buffers and parameters as `other`; `false` otherwise.

Parameters

  other | The generator to compare this with.

Implemented in PyArrayGenerator, and SliceGenerator.

## ◆ shallow_copy()

virtual const std::shared_ptr< ArrayGenerator > shallow_copy | ( |  | ) | const
| pure virtual

Copies this ArrayGenerator, referencing any contents.

Implemented in PyArrayGenerator, and SliceGenerator.

## ◆ tostring_part()

virtual const std::string tostring_part | ( | const std::string & | indent,
|  | const std::string & | pre,
|  | const std::string & | post
| ) |  | const
| pure virtual

Returns a string representation of this ArrayGenerator.

Implemented in PyArrayGenerator, and SliceGenerator.

## ◆ with_form()

virtual const std::shared_ptr< ArrayGenerator > with_form | ( | const FormPtr & | form | ) | const
| pure virtual

Return a copy of this ArrayGenerator with a different form (or a now-known form, whereas it might have been unknown before).

Implemented in PyArrayGenerator, and SliceGenerator.

## ◆ with_length()

virtual const std::shared_ptr< ArrayGenerator > with_length | ( | int64_t | length | ) | const
| pure virtual

Return a copy of this ArrayGenerator with a different length (or a now-known length, whereas it might have been unknown before).

Implemented in PyArrayGenerator, and SliceGenerator.

## Member Data Documentation

## ◆ form_

const FormPtr form_
| protected

## ◆ inferred_form_

FormPtr inferred_form_ {nullptr}
| protected

## ◆ length_

int64_t length_
| protected

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

- include/awkward/virtual/ArrayGenerator.h