RegularArray.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_REGULARARRAY_H_
4 #define AWKWARD_REGULARARRAY_H_
5 
6 #include <string>
7 #include <memory>
8 #include <vector>
9 
10 #include "awkward/common.h"
11 #include "awkward/Slice.h"
12 #include "awkward/Content.h"
13 
14 namespace awkward {
19  public:
21  RegularForm(bool has_identities,
22  const util::Parameters& parameters,
23  const FormKey& form_key,
24  const FormPtr& content,
25  int64_t size);
26 
27  const FormPtr
28  content() const;
29 
30  int64_t
31  size() const;
32 
33  const TypePtr
34  type(const util::TypeStrs& typestrs) const override;
35 
36  void
37  tojson_part(ToJson& builder, bool verbose) const override;
38 
39  const FormPtr
40  shallow_copy() const override;
41 
42  const FormPtr
43  with_form_key(const FormKey& form_key) const override;
44 
45  const std::string
46  purelist_parameter(const std::string& key) const override;
47 
48  bool
49  purelist_isregular() const override;
50 
51  int64_t
52  purelist_depth() const override;
53 
54  bool
55  dimension_optiontype() const override;
56 
57  const std::pair<int64_t, int64_t>
58  minmax_depth() const override;
59 
60  const std::pair<bool, int64_t>
61  branch_depth() const override;
62 
63  int64_t
64  numfields() const override;
65 
66  int64_t
67  fieldindex(const std::string& key) const override;
68 
69  const std::string
70  key(int64_t fieldindex) const override;
71 
72  bool
73  haskey(const std::string& key) const override;
74 
75  const std::vector<std::string>
76  keys() const override;
77 
78  bool
79  istuple() const override;
80 
81  bool
82  equal(const FormPtr& other,
83  bool check_identities,
84  bool check_parameters,
85  bool check_form_key,
86  bool compatibility_check) const override;
87 
88  const FormPtr
89  getitem_field(const std::string& key) const override;
90 
91  const FormPtr
92  getitem_fields(const std::vector<std::string>& keys) const override;
93 
94  private:
95  const FormPtr content_;
96  int64_t size_;
97  };
98 
109  public:
123  RegularArray(const IdentitiesPtr& identities,
124  const util::Parameters& parameters,
125  const ContentPtr& content,
126  int64_t size,
127  int64_t zeros_length);
128 
130  RegularArray(const IdentitiesPtr& identities,
131  const util::Parameters& parameters,
132  const ContentPtr& content,
133  int64_t size);
134 
139  const ContentPtr
140  content() const;
141 
143  int64_t
144  size() const;
145 
152  Index64
153  compact_offsets64(bool start_at_zero) const;
154 
160  const ContentPtr
161  broadcast_tooffsets64(const Index64& offsets) const;
162 
167  const ContentPtr
168  toRegularArray() const;
169 
177  const ContentPtr
178  toListOffsetArray64(bool start_at_zero) const;
179 
181  const std::string
182  classname() const override;
183 
184  void
185  setidentities() override;
186 
187  void
188  setidentities(const IdentitiesPtr& identities) override;
189 
190  const TypePtr
191  type(const util::TypeStrs& typestrs) const override;
192 
193  const FormPtr
194  form(bool materialize) const override;
195 
197  kernels() const override;
198 
199  void
200  caches(std::vector<ArrayCachePtr>& out) const override;
201 
202  const std::string
203  tostring_part(const std::string& indent,
204  const std::string& pre,
205  const std::string& post) const override;
206 
207  void
208  tojson_part(ToJson& builder, bool include_beginendlist) const override;
209 
210  void
211  nbytes_part(std::map<size_t, int64_t>& largest) const override;
212 
216  int64_t
217  length() const override;
218 
219  const ContentPtr
220  shallow_copy() const override;
221 
222  const ContentPtr
223  deep_copy(bool copyarrays,
224  bool copyindexes,
225  bool copyidentities) const override;
226 
227  void
228  check_for_iteration() const override;
229 
230  const ContentPtr
231  getitem_nothing() const override;
232 
233  const ContentPtr
234  getitem_at(int64_t at) const override;
235 
236  const ContentPtr
237  getitem_at_nowrap(int64_t at) const override;
238 
239  const ContentPtr
240  getitem_range(int64_t start, int64_t stop) const override;
241 
242  const ContentPtr
243  getitem_range_nowrap(int64_t start, int64_t stop) const override;
244 
245  const ContentPtr
246  getitem_field(const std::string& key) const override;
247 
248  const ContentPtr
249  getitem_field(const std::string& key,
250  const Slice& only_fields) const override;
251 
252  const ContentPtr
253  getitem_fields(const std::vector<std::string>& keys) const override;
254 
255  const ContentPtr
256  getitem_fields(const std::vector<std::string>& keys,
257  const Slice& only_fields) const override;
258 
259  const ContentPtr
260  carry(const Index64& carry, bool allow_lazy) const override;
261 
262  int64_t
263  purelist_depth() const override;
264 
265  const std::pair<int64_t, int64_t>
266  minmax_depth() const override;
267 
268  const std::pair<bool, int64_t>
269  branch_depth() const override;
270 
271  int64_t
272  numfields() const override;
273 
274  int64_t
275  fieldindex(const std::string& key) const override;
276 
277  const std::string
278  key(int64_t fieldindex) const override;
279 
280  bool
281  haskey(const std::string& key) const override;
282 
283  const std::vector<std::string>
284  keys() const override;
285 
286  bool
287  istuple() const override;
288 
289  // operations
290  const std::string
291  validityerror(const std::string& path) const override;
292 
296  const ContentPtr
297  shallow_simplify() const override;
298 
299  const ContentPtr
300  num(int64_t axis, int64_t depth) const override;
301 
302  const std::pair<Index64, ContentPtr>
303  offsets_and_flattened(int64_t axis, int64_t depth) const override;
304 
305  bool
306  mergeable(const ContentPtr& other, bool mergebool) const override;
307 
308  bool
309  referentially_equal(const ContentPtr& other) const override;
310 
311  const ContentPtr
312  mergemany(const ContentPtrVec& others) const override;
313 
314  const SliceItemPtr
315  asslice() const override;
316 
317  const ContentPtr
318  fillna(const ContentPtr& value) const override;
319 
320  const ContentPtr
321  rpad(int64_t target, int64_t axis, int64_t depth) const override;
322 
323  const ContentPtr
324  rpad_and_clip(int64_t target,
325  int64_t axis,
326  int64_t depth) const override;
327 
328  const ContentPtr
329  reduce_next(const Reducer& reducer,
330  int64_t negaxis,
331  const Index64& starts,
332  const Index64& shifts,
333  const Index64& parents,
334  int64_t outlength,
335  bool mask,
336  bool keepdims) const override;
337 
338  const ContentPtr
339  sort_next(int64_t negaxis,
340  const Index64& starts,
341  const Index64& parents,
342  int64_t outlength,
343  bool ascending,
344  bool stable) const override;
345 
346  const ContentPtr
347  argsort_next(int64_t negaxis,
348  const Index64& starts,
349  const Index64& shifts,
350  const Index64& parents,
351  int64_t outlength,
352  bool ascending,
353  bool stable) const override;
354 
355  const ContentPtr
356  localindex(int64_t axis, int64_t depth) const override;
357 
358  const ContentPtr
359  combinations(int64_t n,
360  bool replacement,
361  const util::RecordLookupPtr& recordlookup,
362  const util::Parameters& parameters,
363  int64_t axis,
364  int64_t depth) const override;
365 
366  const ContentPtr
367  getitem_next(const SliceAt& at,
368  const Slice& tail,
369  const Index64& advanced) const override;
370 
371  const ContentPtr
372  getitem_next(const SliceRange& range,
373  const Slice& tail,
374  const Index64& advanced) const override;
375 
376  const ContentPtr
377  getitem_next(const SliceArray64& array,
378  const Slice& tail,
379  const Index64& advanced) const override;
380 
381  const ContentPtr
382  getitem_next(const SliceJagged64& jagged,
383  const Slice& tail,
384  const Index64& advanced) const override;
385 
386  const ContentPtr
387  getitem_next_jagged(const Index64& slicestarts,
388  const Index64& slicestops,
389  const SliceArray64& slicecontent,
390  const Slice& tail) const override;
391 
392  const ContentPtr
393  getitem_next_jagged(const Index64& slicestarts,
394  const Index64& slicestops,
395  const SliceMissing64& slicecontent,
396  const Slice& tail) const override;
397 
398  const ContentPtr
399  getitem_next_jagged(const Index64& slicestarts,
400  const Index64& slicestops,
401  const SliceJagged64& slicecontent,
402  const Slice& tail) const override;
403 
404  const ContentPtr
405  copy_to(kernel::lib ptr_lib) const override;
406 
407  const ContentPtr
408  numbers_to_type(const std::string& name) const override;
409 
411  bool
412  is_unique() const override;
413 
415  const ContentPtr
416  unique() const override;
417 
419  bool
420  is_subrange_equal(const Index64& start, const Index64& stop) const override;
421 
422  private:
423  const ContentPtr content_;
424  int64_t size_;
425  int64_t length_;
426  };
427 }
428 
429 #endif // AWKWARD_REGULARARRAY_H_
Represents a Python slice object (usual syntax: array[start:stop:step]).
Definition: Slice.h:93
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
const std::string key(const RecordLookupPtr &recordlookup, int64_t fieldindex, int64_t numfields)
Returns the key associated with a field index, given a RecordLookup and a number of fields...
Abstract superclass of all array node types (flat hierarchy). Any Content can be nested within any ot...
Definition: Content.h:276
Definition: json.h:19
Definition: BitMaskedArray.h:15
A contiguous, one-dimensional array of integers used to represent data structures, rather than numerical data in the arrays themselves.
Definition: Index.h:16
std::string name(Mapping a, V value)
Definition: datetime_util.h:39
Represents a SliceArrayOf, SliceMissingOf, or SliceJaggedOf with missing values: None (no equivalent ...
Definition: Slice.h:431
Abstract class for all reducer algorithms.
Definition: Reducer.h:20
Form describing RegularArray.
Definition: RegularArray.h:18
ERROR combinations(kernel::lib ptr_lib, T *toindex, int64_t n, bool replacement, int64_t singlelen)
const std::vector< std::string > keys(const RecordLookupPtr &recordlookup, int64_t numfields)
Returns a given RecordLookup as keys or generate anonymous ones form a number of fields.
std::shared_ptr< std::string > FormKey
Definition: Content.h:19
ERROR unique(kernel::lib ptr_lib, T *toptr, int64_t length, int64_t *tolength)
Represents an array of integers in a slice (possibly converted from an array of booleans).
Definition: Slice.h:225
std::map< std::string, std::string > Parameters
Definition: util.h:165
ERROR copy_to(kernel::lib to_lib, kernel::lib from_lib, void *to_ptr, void *from_ptr, int64_t bytelength)
Internal Function an array buffer from library FROM to library TO, usually between main memory and a ...
std::shared_ptr< Form > FormPtr
Definition: Content.h:18
int64_t fieldindex(const RecordLookupPtr &recordlookup, const std::string &key, int64_t numfields)
Returns the field index associated with a key, given a RecordLookup and a number of fields...
Represents an array of nested lists, where the content may be SliceArrayOf, SliceMissingOf, or SliceJaggedOf (no equivalent in NumPy).
Definition: Slice.h:511
std::vector< std::shared_ptr< Content > > ContentPtrVec
Definition: Content.h:16
Mapping::value_type::value_type value(Mapping a, const std::string &name)
Definition: datetime_util.h:49
A sequence of SliceItem objects representing a tuple passed to Python&#39;s __getitem__.
Definition: Slice.h:585
bool haskey(const RecordLookupPtr &recordlookup, const std::string &key, int64_t numfields)
Returns true if a RecordLookup has a given key; false otherwise.
std::shared_ptr< Type > TypePtr
Definition: Content.h:23
std::shared_ptr< RecordLookup > RecordLookupPtr
Definition: util.h:130
Represents an array of nested lists that all have the same length using a scalar size, rather than an index.
Definition: RegularArray.h:108
Represents an integer in a tuple of slices passed to __getitem__ in Python.
Definition: Slice.h:58
std::map< std::string, std::string > TypeStrs
Definition: util.h:215
Abstract superclass of all array node forms, which expresses the nesting structure without any large ...
Definition: Content.h:39
std::shared_ptr< Identities > IdentitiesPtr
Definition: Identities.h:16
std::shared_ptr< Content > ContentPtr
Definition: ArrayBuilder.h:16
std::shared_ptr< SliceItem > SliceItemPtr
Definition: Slice.h:15
lib
Definition: kernel-dispatch.h:20