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 
10 namespace 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
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 
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:
145  const Slice slice_;
146  };
147 }
148 
149 #endif // AWKWARD_ARRAYGENERATOR_H_
const FormPtr form_
Definition: ArrayGenerator.h:95
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
Definition: BitMaskedArray.h:15
const Slice slice_
Definition: ArrayGenerator.h:145
Generator for lazy slicing. Used to avoid materializing a VirtualArray before its content is needed (...
Definition: ArrayGenerator.h:107
int64_t length_
Definition: ArrayGenerator.h:97
std::shared_ptr< Form > FormPtr
Definition: Content.h:18
const ContentPtr content_
Definition: ArrayGenerator.h:144
Abstract superclass to generate arrays for VirtualArray, defining the interface.
Definition: ArrayGenerator.h:24
A sequence of SliceItem objects representing a tuple passed to Python&#39;s __getitem__.
Definition: Slice.h:585
std::shared_ptr< ArrayGenerator > ArrayGeneratorPtr
Definition: ArrayGenerator.h:14
std::shared_ptr< Content > ContentPtr
Definition: Content.h:15