Loading...
Searching...
No Matches
Content.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_CONTENT_H_
4#define AWKWARD_CONTENT_H_
5
6#include <map>
7
8#include "awkward/common.h"
10#include "awkward/Slice.h"
11#include "awkward/Index.h"
12
13namespace awkward {
14 class Content;
15 using ContentPtr = std::shared_ptr<Content>;
16 using ContentPtrVec = std::vector<std::shared_ptr<Content>>;
17 class Form;
18 using FormPtr = std::shared_ptr<Form>;
19 using FormKey = std::shared_ptr<std::string>;
20 class ArrayCache;
21 using ArrayCachePtr = std::shared_ptr<ArrayCache>;
22 class Type;
23 using TypePtr = std::shared_ptr<Type>;
24 class Reducer;
25 class ToJson;
27 class ToJsonString;
28 class ToJsonPrettyFile;
29 class ToJsonFile;
30
40 public:
41 static FormPtr
42 fromnumpy(char kind,
43 int64_t itemsize,
44 const std::vector<int64_t>& inner_shape);
45 static FormPtr
46 fromjson(const std::string& data);
47
50 Form(bool has_identities,
51 const util::Parameters& parameters,
52 const FormKey& form_key);
53
55 virtual ~Form() { }
56
61 virtual const TypePtr
62 type(const util::TypeStrs& typestrs) const = 0;
63
66 virtual void
67 tojson_part(ToJson& builder, bool verbose) const = 0;
68
71 virtual const FormPtr
72 shallow_copy() const = 0;
73
75 virtual const FormPtr
76 with_form_key(const FormKey& form_key) const = 0;
77
91 virtual bool
92 equal(const FormPtr& other,
93 bool check_identities,
94 bool check_parameters,
95 bool check_form_key,
96 bool compatibility_check) const = 0;
97
99 bool
100 form_key_equals(const FormKey& other_form_key) const;
101
105 virtual const std::string
106 purelist_parameter(const std::string& key) const = 0;
107
118 bool
119 parameter_equals(const std::string& key, const std::string& value) const;
120
123 virtual bool
125
131 virtual int64_t
132 purelist_depth() const = 0;
133
136 virtual bool
138
141 const FormKey
142 form_key() const;
143
148 virtual const std::pair<int64_t, int64_t>
149 minmax_depth() const = 0;
150
157 virtual const std::pair<bool, int64_t>
158 branch_depth() const = 0;
159
162 virtual int64_t
163 numfields() const = 0;
164
167 virtual int64_t
168 fieldindex(const std::string& key) const = 0;
169
174 virtual const std::string
175 key(int64_t fieldindex) const = 0;
176
179 virtual bool
180 haskey(const std::string& key) const = 0;
181
184 virtual const std::vector<std::string>
185 keys() const = 0;
186
188 virtual bool
189 istuple() const = 0;
190
193 virtual const std::string
194 tostring() const;
195
200 virtual const std::string
201 tojson(bool pretty, bool verbose) const;
202
205 bool
207
214 const util::Parameters
215 parameters() const;
216
224 const std::string
225 parameter(const std::string& key) const;
226
230 void
231 identities_tojson(ToJson& builder, bool verbose) const;
232
236 void
237 parameters_tojson(ToJson& builder, bool verbose) const;
238
242 void
243 form_key_tojson(ToJson& builder, bool verbose) const;
244
248 virtual const FormPtr
250
254 virtual const FormPtr
255 getitem_field(const std::string& key) const = 0;
256
260 virtual const FormPtr
261 getitem_fields(const std::vector<std::string>& keys) const = 0;
262
263 protected:
270 };
271
277 public:
280 Content(const IdentitiesPtr& identities,
281 const util::Parameters& parameters);
282
284 virtual ~Content() { }
285
306 virtual bool
307 isscalar() const;
308
311 virtual const std::string
312 classname() const = 0;
313
316 virtual const IdentitiesPtr
317 identities() const;
318
327 virtual void
329
338 virtual void
339 setidentities(const IdentitiesPtr& identities) = 0;
340
345 virtual const TypePtr
346 type(const util::TypeStrs& typestrs) const = 0;
347
356 virtual const FormPtr
357 form(bool materialize) const = 0;
358
363 virtual kernel::lib
364 kernels() const = 0;
365
368 virtual void
369 caches(std::vector<ArrayCachePtr>& out) const = 0;
370
377 virtual const std::string
378 tostring_part(const std::string& indent,
379 const std::string& pre,
380 const std::string& post) const = 0;
381
384 virtual void
385 tojson_part(ToJson& builder, bool include_beginendlist) const = 0;
386
396 virtual void
397 nbytes_part(std::map<size_t, int64_t>& largest) const = 0;
398
400 virtual int64_t
401 length() const = 0;
402
407 virtual const ContentPtr
408 shallow_copy() const = 0;
409
423 virtual const ContentPtr
424 deep_copy(bool copyarrays,
425 bool copyindexes,
426 bool copyidentities) const = 0;
427
430 virtual void
432
435 virtual const ContentPtr
436 getitem_nothing() const = 0;
437
443 virtual const ContentPtr
444 getitem_at(int64_t at) const = 0;
445
450 virtual const ContentPtr
451 getitem_at_nowrap(int64_t at) const = 0;
452
464 virtual const ContentPtr
465 getitem_range(int64_t start, int64_t stop) const = 0;
466
474 virtual const ContentPtr
475 getitem_range_nowrap(int64_t start, int64_t stop) const = 0;
476
479 virtual const ContentPtr
480 getitem_field(const std::string& key) const = 0;
481
482 virtual const ContentPtr
483 getitem_field(const std::string& key,
484 const Slice& only_fields) const = 0;
485
488 virtual const ContentPtr
489 getitem_fields(const std::vector<std::string>& keys) const = 0;
490
491 virtual const ContentPtr
492 getitem_fields(const std::vector<std::string>& keys,
493 const Slice& only_fields) const = 0;
494
497 virtual const ContentPtr
498 getitem(const Slice& where) const;
499
512 virtual const ContentPtr
514 const Slice& tail,
515 const Index64& advanced) const;
516
526 virtual const ContentPtr
527 getitem_next_jagged(const Index64& slicestarts,
528 const Index64& slicestops,
529 const SliceItemPtr& slicecontent,
530 const Slice& tail) const;
531
557 virtual const ContentPtr
558 carry(const Index64& carry, bool allow_lazy) const = 0;
559
563 virtual const std::string
564 purelist_parameter(const std::string& key) const;
565
568 bool
570
573 virtual bool
575
584 virtual int64_t
585 purelist_depth() const = 0;
586
591 virtual const std::pair<int64_t, int64_t>
592 minmax_depth() const = 0;
593
600 virtual const std::pair<bool, int64_t>
601 branch_depth() const = 0;
602
605 virtual int64_t
606 numfields() const = 0;
607
610 virtual int64_t
611 fieldindex(const std::string& key) const = 0;
612
617 virtual const std::string
618 key(int64_t fieldindex) const = 0;
619
622 virtual bool
623 haskey(const std::string& key) const = 0;
624
627 virtual const std::vector<std::string>
628 keys() const = 0;
629
631 virtual bool
632 istuple() const = 0;
633
636 virtual const std::string
637 validityerror(const std::string& path) const = 0;
638
646 virtual const ContentPtr
647 shallow_simplify() const = 0;
648
660 virtual const ContentPtr
661 num(int64_t axis, int64_t depth) const = 0;
662
676 virtual const std::pair<Index64, ContentPtr>
677 offsets_and_flattened(int64_t axis, int64_t depth) const = 0;
678
688 virtual bool
689 mergeable(const ContentPtr& other, bool mergebool) const = 0;
690
695 virtual bool
696 referentially_equal(const ContentPtr& other) const = 0;
697
719 virtual const std::pair<ContentPtrVec, ContentPtrVec>
720 merging_strategy(const ContentPtrVec& others) const;
721
727 virtual const ContentPtr
728 reverse_merge(const ContentPtr& other) const;
729
732 const ContentPtr
733 merge(const ContentPtr& other) const;
734
737 virtual const ContentPtr
738 mergemany(const ContentPtrVec& others) const = 0;
739
742 virtual const SliceItemPtr
743 asslice() const = 0;
744
750 virtual const ContentPtr
751 fillna(const ContentPtr& value) const = 0;
752
766 virtual const ContentPtr
767 rpad(int64_t target, int64_t axis, int64_t depth) const = 0;
768
782 virtual const ContentPtr
783 rpad_and_clip(int64_t target, int64_t axis, int64_t depth) const = 0;
784
814 virtual const ContentPtr
815 reduce_next(const Reducer& reducer,
816 int64_t negaxis,
817 const Index64& starts,
818 const Index64& shifts,
819 const Index64& parents,
820 int64_t outlength,
821 bool mask,
822 bool keepdims) const = 0;
823
843 virtual const ContentPtr
844 sort_next(int64_t negaxis,
845 const Index64& starts,
846 const Index64& parents,
847 int64_t outlength,
848 bool ascending,
849 bool stable) const = 0;
850
873 virtual const ContentPtr
874 argsort_next(int64_t negaxis,
875 const Index64& starts,
876 const Index64& shifts,
877 const Index64& parents,
878 int64_t outlength,
879 bool ascending,
880 bool stable) const = 0;
881
896 virtual const ContentPtr
897 localindex(int64_t axis, int64_t depth) const = 0;
898
964 virtual const ContentPtr
965 combinations(int64_t n,
966 bool replacement,
967 const util::RecordLookupPtr& recordlookup,
968 const util::Parameters& parameters,
969 int64_t axis,
970 int64_t depth) const = 0;
971
980 const std::string
981 tostring() const;
982
1000 const std::string
1001 tojson(bool pretty, int64_t maxdecimals,
1002 const char* nan_string = nullptr,
1003 const char* infinity_string = nullptr,
1004 const char* minus_infinity_string = nullptr,
1005 const char* complex_real_string = nullptr,
1006 const char* complex_imag_string = nullptr) const;
1007
1028 void
1029 tojson(FILE* destination,
1030 bool pretty,
1031 int64_t maxdecimals,
1032 int64_t buffersize,
1033 const char* nan_string = nullptr,
1034 const char* infinity_string = nullptr,
1035 const char* minus_infinity_string = nullptr,
1036 const char* complex_real_string = nullptr,
1037 const char* complex_imag_string = nullptr) const;
1038
1042 int64_t
1043 nbytes() const;
1044
1061 const ContentPtr
1062 reduce(const Reducer& reducer,
1063 int64_t axis,
1064 bool mask,
1065 bool keepdims) const;
1066
1079 const ContentPtr
1080 sort(int64_t axis, bool ascending, bool stable) const;
1081
1095 const ContentPtr
1096 argsort(int64_t axis, bool ascending, bool stable) const;
1097
1104 const util::Parameters
1105 parameters() const;
1106
1117 void
1119
1127 const std::string
1128 parameter(const std::string& key) const;
1129
1140 void
1141 setparameter(const std::string& key, const std::string& value);
1142
1153 bool
1154 parameter_equals(const std::string& key, const std::string& value) const;
1155
1169 bool
1170 parameters_equal(const util::Parameters& other, bool check_all) const;
1171
1174 bool
1175 parameter_isstring(const std::string& key) const;
1176
1179 bool
1180 parameter_isname(const std::string& key) const;
1181
1184 const std::string
1185 parameter_asstring(const std::string& key) const;
1186
1191 const ContentPtr
1192 merge_as_union(const ContentPtr& other) const;
1193
1203 const ContentPtr
1204 rpad_axis0(int64_t target, bool clip) const;
1205
1210 const ContentPtr
1212
1234 const ContentPtr
1236 bool replacement,
1237 const util::RecordLookupPtr& recordlookup,
1238 const util::Parameters& parameters) const;
1239
1244 virtual const ContentPtr
1246 const Slice& tail,
1247 const Index64& advanced) const = 0;
1248
1253 virtual const ContentPtr
1255 const Slice& tail,
1256 const Index64& advanced) const = 0;
1257
1262 virtual const ContentPtr
1264 const Slice& tail,
1265 const Index64& advanced) const;
1266
1271 virtual const ContentPtr
1273 const Slice& tail,
1274 const Index64& advanced) const;
1275
1280 virtual const ContentPtr
1282 const Slice& tail,
1283 const Index64& advanced) const = 0;
1284
1289 virtual const ContentPtr
1291 const Slice& tail,
1292 const Index64& advanced) const;
1293
1298 virtual const ContentPtr
1300 const Slice& tail,
1301 const Index64& advanced) const;
1302
1307 virtual const ContentPtr
1309 const Slice& tail,
1310 const Index64& advanced) const;
1311
1316 virtual const ContentPtr
1318 const Slice& tail,
1319 const Index64& advanced) const = 0;
1320
1325 virtual const ContentPtr
1326 getitem_next_jagged(const Index64& slicestarts,
1327 const Index64& slicestops,
1328 const SliceArray64& slicecontent,
1329 const Slice& tail) const = 0;
1330
1335 virtual const ContentPtr
1336 getitem_next_jagged(const Index64& slicestarts,
1337 const Index64& slicestops,
1338 const SliceMissing64& slicecontent,
1339 const Slice& tail) const = 0;
1340
1345 virtual const ContentPtr
1346 getitem_next_jagged(const Index64& slicestarts,
1347 const Index64& slicestops,
1348 const SliceJagged64& slicecontent,
1349 const Slice& tail) const = 0;
1350
1365 const int64_t
1366 axis_wrap_if_negative(int64_t axis) const;
1367
1371 virtual const ContentPtr
1372 copy_to(kernel::lib ptr_lib) const = 0;
1373
1375 virtual const ContentPtr
1376 numbers_to_type(const std::string& name) const = 0;
1377
1379 virtual bool
1380 is_unique() const = 0;
1381
1384 virtual const ContentPtr
1385 unique() const = 0;
1386
1388 virtual bool
1389 is_subrange_equal(const Index64& start, const Index64& stop) const = 0;
1390
1391 protected:
1394 const std::string
1395 validityerror_parameters(const std::string& path) const;
1396
1402 const ContentPtr
1404 const std::vector<int64_t>& shape) const;
1405
1413 const std::string
1414 parameters_tostring(const std::string& indent,
1415 const std::string& pre,
1416 const std::string& post) const;
1417
1420 kernels_compare(kernel::lib from_index, const ContentPtr& content) const;
1421
1422 protected:
1427 };
1428}
1429
1430#endif // AWKWARD_CONTENT_H_
Abstract superclass of cache for VirtualArray, defining the interface.
Definition: ArrayCache.h:17
Abstract superclass of all array node types (flat hierarchy). Any Content can be nested within any ot...
Definition: Content.h:276
Content(const IdentitiesPtr &identities, const util::Parameters &parameters)
Called by all subclass constructors; assigns identities and parameters upon construction.
const ContentPtr rpad_axis0(int64_t target, bool clip) const
Internal function to handle the axis = 0 case of rpad and rpad_and_clip.
bool parameter_isstring(const std::string &key) const
Returns true if the parameter associated with key is a string; false otherwise.
virtual bool dimension_optiontype() const
Returns true if this dimension has option-type; false otherwise.
util::Parameters parameters_
See parameters.
Definition: Content.h:1426
bool parameter_equals(const std::string &key, const std::string &value) const
Returns true if the parameter associated with key exists and is equal to value; false otherwise.
virtual bool istuple() const =0
Returns true if the outermost RecordArray is a tuple.
virtual ~Content()
Empty destructor; required for some C++ reason.
Definition: Content.h:284
virtual const ContentPtr carry(const Index64 &carry, bool allow_lazy) const =0
Returns an array of the same type with elements filtered, rearranged, and possibly duplicated by the ...
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceArray64 &slicecontent, const Slice &tail) const =0
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
kernel::lib kernels_compare(kernel::lib from_index, const ContentPtr &content) const
Internal function to support most of the logic in kernels.
virtual const ContentPtr combinations(int64_t n, bool replacement, const util::RecordLookupPtr &recordlookup, const util::Parameters &parameters, int64_t axis, int64_t depth) const =0
Tuples or records of all n-tuple combinations of list items at some axis depth.
const std::string parameter(const std::string &key) const
Get one parameter from this array node.
virtual void setidentities()=0
Assign a surrogate index of Identities to this array (in-place).
virtual const ContentPtr sort_next(int64_t negaxis, const Index64 &starts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const =0
This array sorted.
const std::string tostring() const
Returns a string representation of this array (multi-line XML).
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceJagged64 &slicecontent, const Slice &tail) const =0
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
const std::string tojson(bool pretty, int64_t maxdecimals, const char *nan_string=nullptr, const char *infinity_string=nullptr, const char *minus_infinity_string=nullptr, const char *complex_real_string=nullptr, const char *complex_imag_string=nullptr) const
Returns a JSON representation of this array.
virtual const ContentPtr deep_copy(bool copyarrays, bool copyindexes, bool copyidentities) const =0
Copies this node and all nodes hierarchically nested within it, optionally copying the associated arr...
virtual const ContentPtr getitem_fields(const std::vector< std::string > &keys, const Slice &only_fields) const =0
virtual const std::pair< int64_t, int64_t > minmax_depth() const =0
Returns (a) the minimum list-depth and (b) the maximum list-depth of the array, which can differ if t...
virtual const std::string key(int64_t fieldindex) const =0
The record name associated with a given field index or the tuple index as a string (e....
int64_t nbytes() const
The number of bytes contained in all array buffers, Index buffers, and Identities buffers,...
virtual const ContentPtr getitem_next(const SliceItemPtr &head, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr getitem_next(const SliceField &field, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const ContentPtr combinations_axis0(int64_t n, bool replacement, const util::RecordLookupPtr &recordlookup, const util::Parameters &parameters) const
Internal function to handle the axis = 0 case of combinations.
virtual const ContentPtr getitem_nothing() const =0
Internal function to get an empty slice (with the correct type).
virtual const ContentPtr numbers_to_type(const std::string &name) const =0
Change the leaf types to 'totype'.
const int64_t axis_wrap_if_negative(int64_t axis) const
Internal function defining the negative axis handling for many operations.
virtual const ContentPtr rpad(int64_t target, int64_t axis, int64_t depth) const =0
If axis = 0, returns a view of this array padded on the right with None values to have a minimum leng...
bool purelist_isregular() const
Returns true if all nested lists down to the first RecordArray are RegularArray nodes; false otherwis...
virtual const ContentPtr getitem_range(int64_t start, int64_t stop) const =0
Subinterval of this array, handling negative indexing and bounds-checking like Python.
virtual bool mergeable(const ContentPtr &other, bool mergebool) const =0
Returns true if this array can be merged with the other; false otherwise.
virtual void tojson_part(ToJson &builder, bool include_beginendlist) const =0
Internal function to produce a JSON representation one node at a time.
virtual const ContentPtr copy_to(kernel::lib ptr_lib) const =0
Recursively copies components of the array from main memory to a GPU (if ptr_lib == kernel::lib::cuda...
virtual const ContentPtr num(int64_t axis, int64_t depth) const =0
The length of this array (as a NumpyArray scalar) if axis = 0 or the lengths of subarrays (as an arra...
virtual const ContentPtr getitem_fields(const std::vector< std::string > &keys) const =0
This array with the first nested RecordArray replaced by a RecordArray of a given subset of keys.
virtual const std::pair< ContentPtrVec, ContentPtrVec > merging_strategy(const ContentPtrVec &others) const
Partitions this array plus a list of others into a head sequence and a tail sequence:
virtual void check_for_iteration() const =0
Performs up-front validity checks on an array so that they don't have to be checked in getitem_at_now...
virtual const ContentPtr localindex(int64_t axis, int64_t depth) const =0
A (possibly nested) array of integers indicating the positions of elements within each nested list.
virtual bool is_unique() const =0
Returns 'true' if all components of the array are unique.
virtual const ContentPtr getitem_at_nowrap(int64_t at) const =0
Returns the element at a given position in the array, without handling negative indexing or bounds-ch...
virtual const ContentPtr shallow_copy() const =0
Copies this node without copying any nodes hierarchically nested within it or any array/index/identit...
IdentitiesPtr identities_
See identities.
Definition: Content.h:1424
virtual void caches(std::vector< ArrayCachePtr > &out) const =0
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
virtual const ContentPtr getitem_at(int64_t at) const =0
Returns the element at a given position in the array, handling negative indexing and bounds-checking ...
virtual kernel::lib kernels() const =0
Returns the kernel library enum for all nested ptr_lib within the array's tree structure....
virtual int64_t purelist_depth() const =0
The list-depth of this array, not counting any contained within a RecordArray.
virtual const ContentPtr mergemany(const ContentPtrVec &others) const =0
Returns an array with this and the others concatenated (in order, this first, others last).
virtual const std::string purelist_parameter(const std::string &key) const
The parameter associated with key at the first level that has a non-null value, descending only as de...
virtual const ContentPtr getitem_field(const std::string &key) const =0
This array with the first nested RecordArray replaced by the field at key.
const ContentPtr merge_as_union(const ContentPtr &other) const
Concatenates this array with other by creating a UnionArray instead of actually merging the data....
virtual bool referentially_equal(const ContentPtr &other) const =0
Returns true if this array has all the same buffers and parameters as other; false otherwise.
const ContentPtr reduce(const Reducer &reducer, int64_t axis, bool mask, bool keepdims) const
This array with one axis removed by applying a Reducer (e.g. "sum", "max", "any", "all).
virtual const std::string tostring_part(const std::string &indent, const std::string &pre, const std::string &post) const =0
Internal function to build an output string for tostring.
virtual const ContentPtr getitem_next(const SliceArray64 &array, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr unique() const =0
Returns sorted unique values.
virtual const ContentPtr getitem_next(const SliceRange &range, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual int64_t numfields() const =0
The number of fields in the first nested tuple or records or -1 if this array does not contain a Reco...
virtual const ContentPtr getitem_next(const SliceJagged64 &jagged, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr getitem_range_nowrap(int64_t start, int64_t stop) const =0
Subinterval of this array, without handling negative indexing or bounds-checking.
virtual bool isscalar() const
Returns true if the data represented by this node is scalar, not a true array.
virtual const IdentitiesPtr identities() const
Optional Identities for each element of the array (may be nullptr).
bool parameters_equal(const util::Parameters &other, bool check_all) const
Returns true if all parameters of this array node are equal to the other parameters.
virtual const ContentPtr getitem_field(const std::string &key, const Slice &only_fields) const =0
virtual const ContentPtr getitem_next(const SliceMissing64 &missing, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const TypePtr type(const util::TypeStrs &typestrs) const =0
High-level Type describing this array.
virtual const ContentPtr reduce_next(const Reducer &reducer, int64_t negaxis, const Index64 &starts, const Index64 &shifts, const Index64 &parents, int64_t outlength, bool mask, bool keepdims) const =0
This array with one axis removed by applying a Reducer (e.g. "sum", "max", "any", "all).
const std::string validityerror_parameters(const std::string &path) const
Internal function to determine if a particular set of parameters are allowed on a particular node (ce...
virtual int64_t fieldindex(const std::string &key) const =0
The position of a tuple or record key name if this array contains a RecordArray.
const std::string parameter_asstring(const std::string &key) const
Returns the parameter associated with key as a string if parameter_isstring; raises an error otherwis...
const ContentPtr localindex_axis0() const
Internal function to handle the axis = 0 case of localindex.
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceMissing64 &slicecontent, const Slice &tail) const =0
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
virtual const ContentPtr shallow_simplify() const =0
Returns an equivalent array simplified at one level only using simplify_optiontype if an option-type ...
void setparameter(const std::string &key, const std::string &value)
Assign one parameter for this array node (in-place).
virtual const std::string classname() const =0
User-friendly name of this class, including integer-type specialization.
void setparameters(const util::Parameters &parameters)
Assign all the parameters for this array node (in-place).
bool parameter_isname(const std::string &key) const
Returns true if the parameter associated with key is a string that matches [A-Za-z_][A-Za-z_0-9]*; fa...
const ContentPtr getitem_next_array_wrap(const ContentPtr &outcontent, const std::vector< int64_t > &shape) const
Internal function to wrap putative getitem output with enough RegularArray nodes to satisfy a given s...
virtual void setidentities(const IdentitiesPtr &identities)=0
Assign a specified set of Identities to this array (in-place).
virtual const ContentPtr getitem_next(const SliceFields &fields, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const ContentPtr argsort_next(int64_t negaxis, const Index64 &starts, const Index64 &shifts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const =0
This array sorted indices.
void tojson(FILE *destination, bool pretty, int64_t maxdecimals, int64_t buffersize, const char *nan_string=nullptr, const char *infinity_string=nullptr, const char *minus_infinity_string=nullptr, const char *complex_real_string=nullptr, const char *complex_imag_string=nullptr) const
Writes a JSON representation of this array to a destination file.
virtual const std::vector< std::string > keys() const =0
A list of RecordArray keys or an empty list if this array does not contain a RecordArray.
const ContentPtr argsort(int64_t axis, bool ascending, bool stable) const
This array indices with one axis sorted by applying a sorting algorithm.
virtual void nbytes_part(std::map< size_t, int64_t > &largest) const =0
Internal function used to calculate nbytes.
virtual const ContentPtr rpad_and_clip(int64_t target, int64_t axis, int64_t depth) const =0
If axis = 0, returns a view of this array padded on the right.
virtual const ContentPtr fillna(const ContentPtr &value) const =0
Returns this array with None values replaced by a given value.
virtual const ContentPtr getitem_next(const SliceEllipsis &ellipsis, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual const std::string validityerror(const std::string &path) const =0
Returns an error message if this array is invalid; otherwise, returns an empty string.
virtual const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceItemPtr &slicecontent, const Slice &tail) const
Internal function that propagates a jagged array (array with irregular-length dimensions) slice throu...
virtual bool is_subrange_equal(const Index64 &start, const Index64 &stop) const =0
Returns 'true' if subranges are equal.
virtual const std::pair< bool, int64_t > branch_depth() const =0
Returns (a) whether the list-depth of this array "branches," or differs when followed through differe...
const ContentPtr merge(const ContentPtr &other) const
An array with this and the other concatenated (this first, other last).
const ContentPtr sort(int64_t axis, bool ascending, bool stable) const
This array with one axis sorted by applying a sorting algorithm.
const std::string parameters_tostring(const std::string &indent, const std::string &pre, const std::string &post) const
Internal function to convert parameters into a string fragment for tostring.
virtual const FormPtr form(bool materialize) const =0
Low-level Form describing all the features of this array except the actual data buffers (Index,...
virtual const std::pair< Index64, ContentPtr > offsets_and_flattened(int64_t axis, int64_t depth) const =0
Returns (a) an offsets Index and (b) a flattened version of the array at some axis depth.
virtual const SliceItemPtr asslice() const =0
Converts this array into a SliceItem that can be used in getitem.
virtual const ContentPtr getitem_next(const SliceNewAxis &newaxis, const Slice &tail, const Index64 &advanced) const
Internal function that propagates a generic getitem request through one axis (including advanced inde...
const util::Parameters parameters() const
String-to-JSON map that augments the meaning of this array.
virtual int64_t length() const =0
The number of elements in the array.
virtual const ContentPtr getitem_next(const SliceAt &at, const Slice &tail, const Index64 &advanced) const =0
Internal function that propagates a generic getitem request through one axis (including advanced inde...
virtual bool haskey(const std::string &key) const =0
Returns true if the array contains a RecordArray with the specified key; false otherwise.
virtual const ContentPtr reverse_merge(const ContentPtr &other) const
Merges a single other with this array in reverse order: other first, this last.
virtual const ContentPtr getitem(const Slice &where) const
Entry point for general slicing: Slice represents a tuple of SliceItem nodes applying to each level o...
Abstract superclass of all array node forms, which expresses the nesting structure without any large ...
Definition: Content.h:39
virtual const std::string purelist_parameter(const std::string &key) const =0
The parameter associated with key at the first level that has a non-null value, descending only as de...
util::Parameters parameters_
See parameters.
Definition: Content.h:267
bool has_identities_
See has_identities.
Definition: Content.h:265
bool parameter_equals(const std::string &key, const std::string &value) const
Returns true if the parameter associated with key exists and is equal to value; false otherwise.
virtual bool istuple() const =0
Returns true if the outermost RecordArray is a tuple.
void identities_tojson(ToJson &builder, bool verbose) const
Internal function for adding identities in tojson.
const std::string parameter(const std::string &key) const
Get one parameter from this Form.
virtual bool dimension_optiontype() const =0
Returns true if this dimension has option-type; false otherwise.
void form_key_tojson(ToJson &builder, bool verbose) const
Internal function for adding form_key in tojson.
Form(bool has_identities, const util::Parameters &parameters, const FormKey &form_key)
Called by subclass constructors; assigns has_identities, parameters, and form_key upon construction.
static FormPtr fromnumpy(char kind, int64_t itemsize, const std::vector< int64_t > &inner_shape)
bool form_key_equals(const FormKey &other_form_key) const
Returns true if this Form has the same form_key as the other.
virtual const std::pair< int64_t, int64_t > minmax_depth() const =0
Returns (a) the minimum list-depth and (b) the maximum list-depth of the array, which can differ if t...
virtual const std::string key(int64_t fieldindex) const =0
The record name associated with a given field index or the tuple index as a string (e....
virtual bool purelist_isregular() const =0
Returns true if all nested lists down to the first RecordForm are RegularForm nodes; false otherwise.
const FormKey form_key() const
An optional string associated with this Form, usually specifying where an array may be fetched.
virtual const FormPtr getitem_fields(const std::vector< std::string > &keys) const =0
Returns the Form that would result from a fields-slice.
virtual const FormPtr shallow_copy() const =0
Copies this node without copying any nodes hierarchically nested within it.
static FormPtr fromjson(const std::string &data)
virtual int64_t purelist_depth() const =0
The list-depth of this array, not counting any contained within a RecordForm.
virtual const FormPtr getitem_range() const
Returns the Form that would result from a range-slice.
virtual const FormPtr with_form_key(const FormKey &form_key) const =0
Copies this node, adding or replacing a form_key.
virtual int64_t numfields() const =0
The number of fields in the first nested tuple or records or -1 if this array does not contain a Reco...
virtual const std::string tojson(bool pretty, bool verbose) const
Returns a JSON representation of this array.
virtual const TypePtr type(const util::TypeStrs &typestrs) const =0
High-level Type describing this Form.
virtual const std::string tostring() const
Returns a string representation of this Form (tojson with pretty = true and verbose = false).
virtual int64_t fieldindex(const std::string &key) const =0
The position of a tuple or record key name if this array contains a RecordForm.
virtual bool equal(const FormPtr &other, bool check_identities, bool check_parameters, bool check_form_key, bool compatibility_check) const =0
Returns true if this Form is equal to the other Form; false otherwise.
virtual const std::vector< std::string > keys() const =0
A list of RecordArray keys or an empty list if this array does not contain a RecordArray.
virtual const FormPtr getitem_field(const std::string &key) const =0
Returns the Form that would result from a field-slice.
void parameters_tojson(ToJson &builder, bool verbose) const
Internal function for adding parameters in tojson.
virtual ~Form()
Empty destructor; required for some C++ reason.
Definition: Content.h:55
virtual const std::pair< bool, int64_t > branch_depth() const =0
Returns (a) whether the list-depth of this array "branches," or differs when followed through differe...
FormKey form_key_
See form_key.
Definition: Content.h:269
virtual void tojson_part(ToJson &builder, bool verbose) const =0
Internal function to produce a JSON representation one node at a time.
bool has_identities() const
Returns true if the corresponding array has associated Identities.
const util::Parameters parameters() const
String-to-JSON map that augments the meaning of this Form.
virtual bool haskey(const std::string &key) const =0
Returns true if the array contains a RecordForm with the specified key; false otherwise.
A contiguous, one-dimensional array of integers used to represent data structures,...
Definition: Index.h:82
Abstract class for all reducer algorithms.
Definition: Reducer.h:20
Represents an array of integers in a slice (possibly converted from an array of booleans).
Definition: Slice.h:229
Represents an integer in a tuple of slices passed to __getitem__ in Python.
Definition: Slice.h:58
Represents a Python Ellipsis object (usual syntax: array[...]).
Definition: Slice.h:169
Represents a single string in a slice tuple, indicating that a RecordArray should be replaced by one ...
Definition: Slice.h:340
Definition: Slice.h:384
Represents an array of nested lists, where the content may be SliceArrayOf, SliceMissingOf,...
Definition: Slice.h:515
Represents a SliceArrayOf, SliceMissingOf, or SliceJaggedOf with missing values: None (no equivalent ...
Definition: Slice.h:435
Represents NumPy's newaxis marker (a.k.a. None), which prompts __getitem__ to insert a length-1 regul...
Definition: Slice.h:197
Represents a Python slice object (usual syntax: array[start:stop:step]).
Definition: Slice.h:93
A sequence of SliceItem objects representing a tuple passed to Python's __getitem__.
Definition: Slice.h:585
Produces a JSON-formatted file.
Definition: json.h:203
Produces a pretty JSON-formatted file.
Definition: json.h:268
Produces a pretty JSON-formatted string.
Definition: json.h:139
Produces a JSON-formatted string.
Definition: json.h:75
Definition: json.h:21
Abstract superclass of all high level types (flat hierarchy).
Definition: Type.h:23
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
lib
Definition: kernel-dispatch.h:20
std::map< std::string, std::string > Parameters
Definition: util.h:165
std::shared_ptr< RecordLookup > RecordLookupPtr
Definition: util.h:130
std::map< std::string, std::string > TypeStrs
Definition: util.h:215
Definition: BitMaskedArray.h:15
std::shared_ptr< std::string > FormKey
Definition: Content.h:19
std::vector< std::shared_ptr< Content > > ContentPtrVec
Definition: Content.h:16
std::shared_ptr< SliceItem > SliceItemPtr
Definition: Slice.h:15
std::shared_ptr< Content > ContentPtr
Definition: Content.h:15
std::shared_ptr< Form > FormPtr
Definition: Content.h:18
std::shared_ptr< Type > TypePtr
Definition: Content.h:23
std::shared_ptr< ArrayCache > ArrayCachePtr
Definition: Content.h:21
std::shared_ptr< Identities > IdentitiesPtr
Definition: Identities.h:16