Awkward Array: include/awkward/virtual/ArrayGenerator.h Source File

Loading...
Searching...
No Matches
ArrayGenerator.h
Go to the documentation of this file.
1// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
2
3#ifndef AWKWARD_ARRAYGENERATOR_H_
4#define AWKWARD_ARRAYGENERATOR_H_
5
6#include "awkward/Slice.h"
7#include "awkward/Content.h"
8#include "awkward/virtual/ArrayCache.h"
9
10namespace awkward {
12
13 class ArrayGenerator;
14 using ArrayGeneratorPtr = std::shared_ptr<ArrayGenerator>;
15
24 class LIBAWKWARD_EXPORT_SYMBOL ArrayGenerator {
25 public:
35 ArrayGenerator(const FormPtr& form, int64_t length);
36
40 virtual ~ArrayGenerator();
41
44 const FormPtr
45 form() const;
46
49 int64_t
50 length() const;
51
53 virtual const ContentPtr
54 generate() const = 0;
55
59 const ContentPtr
60 generate_and_check();
61
64 virtual void
65 caches(std::vector<ArrayCachePtr>& out) const = 0;
66
68 virtual const std::string
69 tostring_part(const std::string& indent,
70 const std::string& pre,
71 const std::string& post) const = 0;
72
74 virtual const std::shared_ptr<ArrayGenerator>
75 shallow_copy() const = 0;
76
79 virtual const std::shared_ptr<ArrayGenerator>
80 with_form(const FormPtr& form) const = 0;
81
84 virtual const std::shared_ptr<ArrayGenerator>
85 with_length(int64_t length) const = 0;
86
91 virtual bool
92 referentially_equal(const ArrayGeneratorPtr& other) const = 0;
93
94 protected:
95 const FormPtr form_;
96 FormPtr inferred_form_{nullptr};
97 int64_t length_;
98 };
99
101
107 class LIBAWKWARD_EXPORT_SYMBOL SliceGenerator: public ArrayGenerator {
108 public:
109 SliceGenerator(const FormPtr& form,
110 int64_t length,
111 const ContentPtr& content,
112 const Slice& slice);
113
114 const ContentPtr
115 content() const;
116
117 const Slice
118 slice() const;
119
120 const ContentPtr
121 generate() const override;
122
123 void
124 caches(std::vector<ArrayCachePtr>& out) const override;
125
126 const std::string
127 tostring_part(const std::string& indent,
128 const std::string& pre,
129 const std::string& post) const override;
130
131 const std::shared_ptr<ArrayGenerator>
132 shallow_copy() const override;
133
134 const std::shared_ptr<ArrayGenerator>
135 with_form(const FormPtr& form) const override;
136
137 const std::shared_ptr<ArrayGenerator>
138 with_length(int64_t length) const override;
139
140 virtual bool
141 referentially_equal(const ArrayGeneratorPtr& other) const override;
142
143 protected:
144 const ContentPtr content_;
145 const Slice slice_;
146 };
147}
148
149#endif // AWKWARD_ARRAYGENERATOR_H_
ArrayCache.h
Content.h
Slice.h
awkward::ArrayGenerator
Abstract superclass to generate arrays for VirtualArray, defining the interface.
Definition: ArrayGenerator.h:24
awkward::ArrayGenerator::with_form
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 hav...
awkward::ArrayGenerator::with_length
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,...
awkward::ArrayGenerator::form_
const FormPtr form_
Definition: ArrayGenerator.h:95
awkward::ArrayGenerator::ArrayGenerator
ArrayGenerator(const FormPtr &form, int64_t length)
Called by subclasses to set the form of an ArrayGenerator.
awkward::ArrayGenerator::length_
int64_t length_
Definition: ArrayGenerator.h:97
awkward::ArrayGenerator::caches
virtual void caches(std::vector< ArrayCachePtr > &out) const =0
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
awkward::ArrayGenerator::tostring_part
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.
awkward::ArrayGenerator::generate
virtual const ContentPtr generate() const =0
Creates an array but does not check it against the form.
awkward::ArrayGenerator::form
const FormPtr form() const
The Form the generated array is expected to take; may be nullptr.
awkward::ArrayGenerator::~ArrayGenerator
virtual ~ArrayGenerator()
Virtual destructor acts as a first non-inline virtual function that determines a specific translation...
awkward::ArrayGenerator::length
int64_t length() const
The length the generated array is expected to have; may be negative to indicate that the length is un...
awkward::ArrayGenerator::shallow_copy
virtual const std::shared_ptr< ArrayGenerator > shallow_copy() const =0
Copies this ArrayGenerator, referencing any contents.
awkward::ArrayGenerator::generate_and_check
const ContentPtr generate_and_check()
Creates an array and checks it against the form. If form was not available initially,...
awkward::ArrayGenerator::referentially_equal
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.
awkward::SliceGenerator
Generator for lazy slicing. Used to avoid materializing a VirtualArray before its content is needed (...
Definition: ArrayGenerator.h:107
awkward::SliceGenerator::caches
void caches(std::vector< ArrayCachePtr > &out) const override
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
awkward::SliceGenerator::with_form
const std::shared_ptr< ArrayGenerator > with_form(const FormPtr &form) const override
Return a copy of this ArrayGenerator with a different form (or a now-known form, whereas it might hav...
awkward::SliceGenerator::slice_
const Slice slice_
Definition: ArrayGenerator.h:145
awkward::SliceGenerator::referentially_equal
virtual bool referentially_equal(const ArrayGeneratorPtr &other) const override
Returns true if this generator has all the same buffers and parameters as other; false otherwise.
awkward::SliceGenerator::SliceGenerator
SliceGenerator(const FormPtr &form, int64_t length, const ContentPtr &content, const Slice &slice)
awkward::SliceGenerator::content_
const ContentPtr content_
Definition: ArrayGenerator.h:144
awkward::SliceGenerator::tostring_part
const std::string tostring_part(const std::string &indent, const std::string &pre, const std::string &post) const override
Returns a string representation of this ArrayGenerator.
awkward::SliceGenerator::generate
const ContentPtr generate() const override
Creates an array but does not check it against the form.
awkward::SliceGenerator::with_length
const std::shared_ptr< ArrayGenerator > with_length(int64_t length) const override
Return a copy of this ArrayGenerator with a different length (or a now-known length,...
awkward::SliceGenerator::slice
const Slice slice() const
awkward::SliceGenerator::content
const ContentPtr content() const
awkward::SliceGenerator::shallow_copy
const std::shared_ptr< ArrayGenerator > shallow_copy() const override
Copies this ArrayGenerator, referencing any contents.
awkward::Slice
A sequence of SliceItem objects representing a tuple passed to Python's __getitem__.
Definition: Slice.h:585
LIBAWKWARD_EXPORT_SYMBOL
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
awkward
Definition: BitMaskedArray.h:15
awkward::ArrayGeneratorPtr
std::shared_ptr< ArrayGenerator > ArrayGeneratorPtr
Definition: ArrayGenerator.h:14
awkward::ContentPtr
std::shared_ptr< Content > ContentPtr
Definition: Content.h:15
awkward::FormPtr
std::shared_ptr< Form > FormPtr
Definition: Content.h:18