Awkward Array: include/awkward/array/Record.h Source File

Loading...
Searching...
No Matches
Record.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_RECORD_H_
4#define AWKWARD_RECORD_H_
5
6#include "awkward/common.h"
7#include "awkward/array/RecordArray.h"
8
9namespace awkward {
16 class LIBAWKWARD_EXPORT_SYMBOL Record: public Content {
17 public:
24 Record(const std::shared_ptr<const RecordArray> array, int64_t at);
25
28 const std::shared_ptr<const RecordArray>
29 array() const;
30
33 int64_t
34 at() const;
35
41 const ContentPtrVec
42 contents() const;
43
46 const util::RecordLookupPtr
47 recordlookup() const;
48
50 bool
51 istuple() const override;
52
56 bool
57 isscalar() const override;
58
60 const std::string
61 classname() const override;
62
63 const IdentitiesPtr
64 identities() const override;
65
67 void
68 setidentities() override;
69
71 void
72 setidentities(const IdentitiesPtr& identities) override;
73
74 const TypePtr
75 type(const util::TypeStrs& typestrs) const override;
76
77 const FormPtr
78 form(bool materialize) const override;
79
80 kernel::lib
81 kernels() const override;
82
83 void
84 caches(std::vector<ArrayCachePtr>& out) const override;
85
86 const std::string
87 tostring_part(const std::string& indent,
88 const std::string& pre,
89 const std::string& post) const override;
90
91 void
92 tojson_part(ToJson& builder, bool include_beginendlist) const override;
93
94 void
95 nbytes_part(std::map<size_t, int64_t>& largest) const override;
96
97 int64_t
98 length() const override;
99
100 const ContentPtr
101 shallow_copy() const override;
102
103 const ContentPtr
104 deep_copy(bool copyarrays,
105 bool copyindexes,
106 bool copyidentities) const override;
107
108 void
109 check_for_iteration() const override;
110
112 const ContentPtr
113 getitem_nothing() const override;
114
116 const ContentPtr
117 getitem_at(int64_t at) const override;
118
120 const ContentPtr
121 getitem_at_nowrap(int64_t at) const override;
122
124 const ContentPtr
125 getitem_range(int64_t start, int64_t stop) const override;
126
128 const ContentPtr
129 getitem_range_nowrap(int64_t start, int64_t stop) const override;
130
131 const ContentPtr
132 getitem_field(const std::string& key) const override;
133
134 const ContentPtr
135 getitem_field(const std::string& key,
136 const Slice& only_fields) const override;
137
138 const ContentPtr
139 getitem_fields(const std::vector<std::string>& keys) const override;
140
141 const ContentPtr
142 getitem_fields(const std::vector<std::string>& keys,
143 const Slice& only_fields) const override;
144
146 const ContentPtr
147 carry(const Index64& carry, bool allow_lazy) const override;
148
149 bool
150 dimension_optiontype() const override;
151
152 int64_t
153 purelist_depth() const override;
154
155 const std::pair<int64_t, int64_t>
156 minmax_depth() const override;
157
158 const std::pair<bool, int64_t>
159 branch_depth() const override;
160
161 int64_t
162 numfields() const override;
163
164 int64_t
165 fieldindex(const std::string& key) const override;
166
167 const std::string
168 key(int64_t fieldindex) const override;
169
170 bool
171 haskey(const std::string& key) const override;
172
173 const std::vector<std::string>
174 keys() const override;
175
176 // operations
177 const std::string
178 validityerror(const std::string& path) const override;
179
181 const ContentPtr
182 shallow_simplify() const override;
183
184 const int64_t
185 axis_wrap_if_negative(int64_t axis) const;
186
187 const ContentPtr
188 num(int64_t axis, int64_t depth) const override;
189
191 const std::pair<Index64, ContentPtr>
192 offsets_and_flattened(int64_t axis, int64_t depth) const override;
193
195 bool
196 mergeable(const ContentPtr& other, bool mergebool) const override;
197
198 bool
199 referentially_equal(const ContentPtr& other) const override;
200
202 const ContentPtr
203 mergemany(const ContentPtrVec& others) const override;
204
206 const SliceItemPtr
207 asslice() const override;
208
209 const ContentPtr
210 fillna(const ContentPtr& value) const override;
211
213 const ContentPtr
214 rpad(int64_t target, int64_t axis, int64_t depth) const override;
215
217 const ContentPtr
218 rpad_and_clip(int64_t target,
219 int64_t axis,
220 int64_t depth) const override;
221
222 const ContentPtr
223 reduce_next(const Reducer& reducer,
224 int64_t negaxis,
225 const Index64& starts,
226 const Index64& shifts,
227 const Index64& parents,
228 int64_t outlength,
229 bool mask,
230 bool keepdims) const override;
231
232 const ContentPtr
233 sort_next(int64_t negaxis,
234 const Index64& starts,
235 const Index64& parents,
236 int64_t outlength,
237 bool ascending,
238 bool stable) const override;
239
240 const ContentPtr
241 argsort_next(int64_t negaxis,
242 const Index64& starts,
243 const Index64& shifts,
244 const Index64& parents,
245 int64_t outlength,
246 bool ascending,
247 bool stable) const override;
248
249 const ContentPtr
250 localindex(int64_t axis, int64_t depth) const override;
251
252 const ContentPtr
253 combinations(int64_t n,
254 bool replacement,
255 const util::RecordLookupPtr& recordlookup,
256 const util::Parameters& parameters,
257 int64_t axis,
258 int64_t depth) const override;
259
263 const ContentPtr
264 field(int64_t fieldindex) const;
265
269 const ContentPtr
270 field(const std::string& key) const;
271
275 const ContentPtrVec
276 fields() const;
277
279 const std::vector<std::pair<std::string, ContentPtr>>
280 fielditems() const;
281
284 const std::shared_ptr<Record>
285 astuple() const;
286
287 const ContentPtr
288 getitem(const Slice& where) const override;
289
291 const ContentPtr
292 getitem_next(const SliceAt& at,
293 const Slice& tail,
294 const Index64& advanced) const override;
295
297 const ContentPtr
298 getitem_next(const SliceRange& range,
299 const Slice& tail,
300 const Index64& advanced) const override;
301
303 const ContentPtr
304 getitem_next(const SliceArray64& array,
305 const Slice& tail,
306 const Index64& advanced) const override;
307
309 const ContentPtr
310 getitem_next(const SliceField& field,
311 const Slice& tail,
312 const Index64& advanced) const override;
313
315 const ContentPtr
316 getitem_next(const SliceFields& fields,
317 const Slice& tail,
318 const Index64& advanced) const override;
319
321 const ContentPtr
322 getitem_next(const SliceJagged64& jagged,
323 const Slice& tail,
324 const Index64& advanced) const override;
325
327 const ContentPtr
328 getitem_next_jagged(const Index64& slicestarts,
329 const Index64& slicestops,
330 const SliceArray64& slicecontent,
331 const Slice& tail) const override;
332
334 const ContentPtr
335 getitem_next_jagged(const Index64& slicestarts,
336 const Index64& slicestops,
337 const SliceMissing64& slicecontent,
338 const Slice& tail) const override;
339
341 const ContentPtr
342 getitem_next_jagged(const Index64& slicestarts,
343 const Index64& slicestops,
344 const SliceJagged64& slicecontent,
345 const Slice& tail) const override;
346
347 const ContentPtr
348 copy_to(kernel::lib ptr_lib) const override;
349
350 const ContentPtr
351 numbers_to_type(const std::string& name) const override;
352
354 bool
355 is_unique() const override;
356
358 const ContentPtr
359 unique() const override;
360
362 bool
363 is_subrange_equal(const Index64& start, const Index64& stop) const override;
364
365 private:
367 const std::shared_ptr<const RecordArray> array_;
369 int64_t at_;
370 };
371}
372
373#endif // AWKWARD_RECORD_H_
RecordArray.h
awkward::Content
Abstract superclass of all array node types (flat hierarchy). Any Content can be nested within any ot...
Definition: Content.h:276
awkward::IndexOf
A contiguous, one-dimensional array of integers used to represent data structures,...
Definition: Index.h:82
awkward::Record
Represents a tuple or record, a scalar value from RecordArray.
Definition: Record.h:16
awkward::Record::purelist_depth
int64_t purelist_depth() const override
The list-depth of this array, not counting any contained within a RecordArray.
awkward::Record::argsort_next
const ContentPtr argsort_next(int64_t negaxis, const Index64 &starts, const Index64 &shifts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const override
This array sorted indices.
awkward::Record::caches
void caches(std::vector< ArrayCachePtr > &out) const override
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
awkward::Record::getitem_fields
const ContentPtr getitem_fields(const std::vector< std::string > &keys) const override
This array with the first nested RecordArray replaced by a RecordArray of a given subset of keys.
awkward::Record::getitem_next_jagged
const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceArray64 &slicecontent, const Slice &tail) const override
awkward::Record::getitem_at
const ContentPtr getitem_at(int64_t at) const override
awkward::Record::setidentities
void setidentities() override
awkward::Record::getitem_field
const ContentPtr getitem_field(const std::string &key, const Slice &only_fields) const override
awkward::Record::getitem_next
const ContentPtr getitem_next(const SliceArray64 &array, const Slice &tail, const Index64 &advanced) const override
awkward::Record::unique
const ContentPtr unique() const override
Returns an array where all components are unique.
awkward::Record::sort_next
const ContentPtr sort_next(int64_t negaxis, const Index64 &starts, const Index64 &parents, int64_t outlength, bool ascending, bool stable) const override
This array sorted.
awkward::Record::tojson_part
void tojson_part(ToJson &builder, bool include_beginendlist) const override
Internal function to produce a JSON representation one node at a time.
awkward::Record::getitem_fields
const ContentPtr getitem_fields(const std::vector< std::string > &keys, const Slice &only_fields) const override
awkward::Record::astuple
const std::shared_ptr< Record > astuple() const
Returns this Record without recordlookup, converting any records into tuples.
awkward::Record::length
int64_t length() const override
The number of elements in the array.
awkward::Record::deep_copy
const ContentPtr deep_copy(bool copyarrays, bool copyindexes, bool copyidentities) const override
Copies this node and all nodes hierarchically nested within it, optionally copying the associated arr...
awkward::Record::validityerror
const std::string validityerror(const std::string &path) const override
Returns an error message if this array is invalid; otherwise, returns an empty string.
awkward::Record::getitem_next
const ContentPtr getitem_next(const SliceAt &at, const Slice &tail, const Index64 &advanced) const override
awkward::Record::axis_wrap_if_negative
const int64_t axis_wrap_if_negative(int64_t axis) const
awkward::Record::istuple
bool istuple() const override
Returns true if recordlookup is nullptr; false otherwise.
awkward::Record::getitem_next
const ContentPtr getitem_next(const SliceField &field, const Slice &tail, const Index64 &advanced) const override
awkward::Record::getitem_nothing
const ContentPtr getitem_nothing() const override
awkward::Record::kernels
kernel::lib kernels() const override
Returns the kernel library enum for all nested ptr_lib within the array's tree structure....
awkward::Record::fields
const ContentPtrVec fields() const
Returns all fields.
awkward::Record::carry
const ContentPtr carry(const Index64 &carry, bool allow_lazy) const override
awkward::Record::combinations
const ContentPtr combinations(int64_t n, bool replacement, const util::RecordLookupPtr &recordlookup, const util::Parameters &parameters, int64_t axis, int64_t depth) const override
Tuples or records of all n-tuple combinations of list items at some axis depth.
awkward::Record::setidentities
void setidentities(const IdentitiesPtr &identities) override
awkward::Record::isscalar
bool isscalar() const override
Returns true if the data represented by this node is scalar, not a true array.
awkward::Record::localindex
const ContentPtr localindex(int64_t axis, int64_t depth) const override
A (possibly nested) array of integers indicating the positions of elements within each nested list.
awkward::Record::getitem_range_nowrap
const ContentPtr getitem_range_nowrap(int64_t start, int64_t stop) const override
awkward::Record::recordlookup
const util::RecordLookupPtr recordlookup() const
The array's RecordArray::recordlookup.
awkward::Record::at
int64_t at() const
The position in the array where this tuple/record resides.
awkward::Record::offsets_and_flattened
const std::pair< Index64, ContentPtr > offsets_and_flattened(int64_t axis, int64_t depth) const override
awkward::Record::getitem
const ContentPtr getitem(const Slice &where) const override
Entry point for general slicing: Slice represents a tuple of SliceItem nodes applying to each level o...
awkward::Record::fieldindex
int64_t fieldindex(const std::string &key) const override
The position of a tuple or record key name if this array contains a RecordArray.
awkward::Record::check_for_iteration
void check_for_iteration() const override
Performs up-front validity checks on an array so that they don't have to be checked in getitem_at_now...
awkward::Record::field
const ContentPtr field(int64_t fieldindex) const
Returns the field at a given index.
awkward::Record::identities
const IdentitiesPtr identities() const override
Optional Identities for each element of the array (may be nullptr).
awkward::Record::array
const std::shared_ptr< const RecordArray > array() const
A reference to the array in which this tuple/record resides (not a copy, shares reference count).
awkward::Record::keys
const std::vector< std::string > keys() const override
A list of RecordArray keys or an empty list if this array does not contain a RecordArray.
awkward::Record::Record
Record(const std::shared_ptr< const RecordArray > array, int64_t at)
Creates a Record from a full set of parameters.
awkward::Record::getitem_field
const ContentPtr getitem_field(const std::string &key) const override
This array with the first nested RecordArray replaced by the field at key.
awkward::Record::branch_depth
const std::pair< bool, int64_t > branch_depth() const override
Returns (a) whether the list-depth of this array "branches," or differs when followed through differe...
awkward::Record::rpad
const ContentPtr rpad(int64_t target, int64_t axis, int64_t depth) const override
awkward::Record::getitem_at_nowrap
const ContentPtr getitem_at_nowrap(int64_t at) const override
awkward::Record::field
const ContentPtr field(const std::string &key) const
Returns the field at a given key name.
awkward::Record::nbytes_part
void nbytes_part(std::map< size_t, int64_t > &largest) const override
Internal function used to calculate nbytes.
awkward::Record::mergemany
const ContentPtr mergemany(const ContentPtrVec &others) const override
awkward::Record::key
const std::string key(int64_t fieldindex) const override
The record name associated with a given field index or the tuple index as a string (e....
awkward::Record::shallow_copy
const ContentPtr shallow_copy() const override
Copies this node without copying any nodes hierarchically nested within it or any array/index/identit...
awkward::Record::minmax_depth
const std::pair< int64_t, int64_t > minmax_depth() const override
Returns (a) the minimum list-depth and (b) the maximum list-depth of the array, which can differ if t...
awkward::Record::is_unique
bool is_unique() const override
Returns 'true' if all components of the array are unique.
awkward::Record::form
const FormPtr form(bool materialize) const override
Low-level Form describing all the features of this array except the actual data buffers (Index,...
awkward::Record::asslice
const SliceItemPtr asslice() const override
awkward::Record::tostring_part
const std::string tostring_part(const std::string &indent, const std::string &pre, const std::string &post) const override
Internal function to build an output string for tostring.
awkward::Record::rpad_and_clip
const ContentPtr rpad_and_clip(int64_t target, int64_t axis, int64_t depth) const override
awkward::Record::getitem_next
const ContentPtr getitem_next(const SliceJagged64 &jagged, const Slice &tail, const Index64 &advanced) const override
awkward::Record::getitem_range
const ContentPtr getitem_range(int64_t start, int64_t stop) const override
awkward::Record::is_subrange_equal
bool is_subrange_equal(const Index64 &start, const Index64 &stop) const override
Returns 'true' if subranges are equal.
awkward::Record::fillna
const ContentPtr fillna(const ContentPtr &value) const override
Returns this array with None values replaced by a given value.
awkward::Record::numfields
int64_t numfields() const override
The number of fields in the first nested tuple or records or -1 if this array does not contain a Reco...
awkward::Record::referentially_equal
bool referentially_equal(const ContentPtr &other) const override
Returns true if this array has all the same buffers and parameters as other; false otherwise.
awkward::Record::type
const TypePtr type(const util::TypeStrs &typestrs) const override
High-level Type describing this array.
awkward::Record::num
const ContentPtr num(int64_t axis, int64_t depth) const override
The length of this array (as a NumpyArray scalar) if axis = 0 or the lengths of subarrays (as an arra...
awkward::Record::getitem_next
const ContentPtr getitem_next(const SliceFields &fields, const Slice &tail, const Index64 &advanced) const override
awkward::Record::mergeable
bool mergeable(const ContentPtr &other, bool mergebool) const override
awkward::Record::haskey
bool haskey(const std::string &key) const override
Returns true if the array contains a RecordArray with the specified key; false otherwise.
awkward::Record::getitem_next_jagged
const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceJagged64 &slicecontent, const Slice &tail) const override
awkward::Record::getitem_next_jagged
const ContentPtr getitem_next_jagged(const Index64 &slicestarts, const Index64 &slicestops, const SliceMissing64 &slicecontent, const Slice &tail) const override
awkward::Record::getitem_next
const ContentPtr getitem_next(const SliceRange &range, const Slice &tail, const Index64 &advanced) const override
awkward::Record::shallow_simplify
const ContentPtr shallow_simplify() const override
For Record, this method returns shallow_copy (pass-through).
awkward::Record::reduce_next
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 override
This array with one axis removed by applying a Reducer (e.g. "sum", "max", "any", "all).
awkward::Record::contents
const ContentPtrVec contents() const
Returns a std::vector<std::shared_ptr<Content>> of each field at this record position (at).
awkward::Record::numbers_to_type
const ContentPtr numbers_to_type(const std::string &name) const override
Change the leaf types to 'totype'.
awkward::Record::classname
const std::string classname() const override
User-friendly name of this class: "Record".
awkward::Record::dimension_optiontype
bool dimension_optiontype() const override
Returns true if this dimension has option-type; false otherwise.
awkward::Record::copy_to
const ContentPtr copy_to(kernel::lib ptr_lib) const override
Recursively copies components of the array from main memory to a GPU (if ptr_lib == kernel::lib::cuda...
awkward::Record::fielditems
const std::vector< std::pair< std::string, ContentPtr > > fielditems() const
Returns key, field pairs for all fields.
awkward::Reducer
Abstract class for all reducer algorithms.
Definition: Reducer.h:20
awkward::SliceArrayOf
Represents an array of integers in a slice (possibly converted from an array of booleans).
Definition: Slice.h:229
awkward::SliceAt
Represents an integer in a tuple of slices passed to __getitem__ in Python.
Definition: Slice.h:58
awkward::SliceField
Represents a single string in a slice tuple, indicating that a RecordArray should be replaced by one ...
Definition: Slice.h:340
awkward::SliceFields
Definition: Slice.h:384
awkward::SliceJaggedOf
Represents an array of nested lists, where the content may be SliceArrayOf, SliceMissingOf,...
Definition: Slice.h:515
awkward::SliceMissingOf
Represents a SliceArrayOf, SliceMissingOf, or SliceJaggedOf with missing values: None (no equivalent ...
Definition: Slice.h:435
awkward::SliceRange
Represents a Python slice object (usual syntax: array[start:stop:step]).
Definition: Slice.h:93
awkward::Slice
A sequence of SliceItem objects representing a tuple passed to Python's __getitem__.
Definition: Slice.h:585
awkward::ToJson
Definition: json.h:21
common.h
LIBAWKWARD_EXPORT_SYMBOL
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
awkward::kernel::lib
lib
Definition: kernel-dispatch.h:20
awkward::util::Parameters
std::map< std::string, std::string > Parameters
Definition: util.h:165
awkward::util::RecordLookupPtr
std::shared_ptr< RecordLookup > RecordLookupPtr
Definition: util.h:130
awkward::util::TypeStrs
std::map< std::string, std::string > TypeStrs
Definition: util.h:215
awkward
Definition: BitMaskedArray.h:15
awkward::ContentPtrVec
std::vector< std::shared_ptr< Content > > ContentPtrVec
Definition: Content.h:16
awkward::SliceItemPtr
std::shared_ptr< SliceItem > SliceItemPtr
Definition: Slice.h:15
awkward::ContentPtr
std::shared_ptr< Content > ContentPtr
Definition: Content.h:15
awkward::FormPtr
std::shared_ptr< Form > FormPtr
Definition: Content.h:18
awkward::TypePtr
std::shared_ptr< Type > TypePtr
Definition: Content.h:23
awkward::IdentitiesPtr
std::shared_ptr< Identities > IdentitiesPtr
Definition: Identities.h:16