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"
9
10namespace awkward {
12
13 class ArrayGenerator;
14 using ArrayGeneratorPtr = std::shared_ptr<ArrayGenerator>;
15
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
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:
96 FormPtr inferred_form_{nullptr};
97 int64_t length_;
98 };
99
101
108 public:
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:
146 };
147}
148
149#endif // AWKWARD_ARRAYGENERATOR_H_
Abstract superclass to generate arrays for VirtualArray, defining the interface.
Definition: ArrayGenerator.h:24
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...
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,...
const FormPtr form_
Definition: ArrayGenerator.h:95
ArrayGenerator(const FormPtr &form, int64_t length)
Called by subclasses to set the form of an ArrayGenerator.
int64_t length_
Definition: ArrayGenerator.h:97
virtual void caches(std::vector< ArrayCachePtr > &out) const =0
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
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.
virtual const ContentPtr generate() const =0
Creates an array but does not check it against the form.
const FormPtr form() const
The Form the generated array is expected to take; may be nullptr.
virtual ~ArrayGenerator()
Virtual destructor acts as a first non-inline virtual function that determines a specific translation...
int64_t length() const
The length the generated array is expected to have; may be negative to indicate that the length is un...
virtual const std::shared_ptr< ArrayGenerator > shallow_copy() const =0
Copies this ArrayGenerator, referencing any contents.
const ContentPtr generate_and_check()
Creates an array and checks it against the form. If form was not available initially,...
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.
Generator for lazy slicing. Used to avoid materializing a VirtualArray before its content is needed (...
Definition: ArrayGenerator.h:107
void caches(std::vector< ArrayCachePtr > &out) const override
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
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...
const Slice slice_
Definition: ArrayGenerator.h:145
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.
SliceGenerator(const FormPtr &form, int64_t length, const ContentPtr &content, const Slice &slice)
const ContentPtr content_
Definition: ArrayGenerator.h:144
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.
const ContentPtr generate() const override
Creates an array but does not check it against the form.
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,...
const Slice slice() const
const ContentPtr content() const
const std::shared_ptr< ArrayGenerator > shallow_copy() const override
Copies this ArrayGenerator, referencing any contents.
A sequence of SliceItem objects representing a tuple passed to Python's __getitem__.
Definition: Slice.h:585
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
Definition: BitMaskedArray.h:15
std::shared_ptr< ArrayGenerator > ArrayGeneratorPtr
Definition: ArrayGenerator.h:14
std::shared_ptr< Content > ContentPtr
Definition: Content.h:15
std::shared_ptr< Form > FormPtr
Definition: Content.h:18