Awkward Array: include/awkward/Identities.h Source File

Loading...
Searching...
No Matches
Identities.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_IDENTITIES_H_
4#define AWKWARD_IDENTITIES_H_
5
6#include <string>
7#include <vector>
8#include <map>
9#include <memory>
10
11#include "awkward/common.h"
12#include "awkward/Index.h"
13
14namespace awkward {
15 class Identities;
16 using IdentitiesPtr = std::shared_ptr<Identities>;
17
57 class LIBAWKWARD_EXPORT_SYMBOL Identities {
58 public:
60 using Ref = int64_t;
61
63 using FieldLoc = std::vector<std::pair<int64_t, std::string>>;
64
69 static Ref
70 newref();
71
73 static IdentitiesPtr
74 none();
75
89 Identities(const Ref ref,
90 const FieldLoc& fieldloc,
91 int64_t offset,
92 int64_t width,
93 int64_t length);
94
98 virtual ~Identities();
99
101 const Ref
102 ref() const;
103
106 const FieldLoc
107 fieldloc() const;
108
114 const int64_t
115 offset() const;
116
118 const int64_t
119 width() const;
120
122 const int64_t
123 length() const;
124
126 virtual kernel::lib
127 ptr_lib() const = 0;
128
131 virtual const std::string
132 classname() const = 0;
133
135 virtual const std::string
136 identity_at(int64_t where) const = 0;
137
139 virtual const IdentitiesPtr
140 to64() const = 0;
141
148 virtual const std::string
149 tostring_part(const std::string& indent,
150 const std::string& pre,
151 const std::string& post) const = 0;
152
158 virtual const IdentitiesPtr
159 getitem_range_nowrap(int64_t start, int64_t stop) const = 0;
160
170 virtual void
171 nbytes_part(std::map<size_t, int64_t>& largest) const = 0;
172
176 virtual const IdentitiesPtr
177 shallow_copy() const = 0;
178
182 virtual const IdentitiesPtr
183 deep_copy() const = 0;
184
206 virtual const IdentitiesPtr
207 getitem_carry_64(const Index64& carry) const = 0;
208
210 virtual const IdentitiesPtr
211 withfieldloc(const FieldLoc& fieldloc) const = 0;
212
215 virtual int64_t
216 value(int64_t row, int64_t col) const = 0;
217
224 virtual const IdentitiesPtr
225 copy_to(kernel::lib ptr_lib) const = 0;
226
228 const std::string
229 tostring() const;
230
235 virtual bool
236 referentially_equal(const IdentitiesPtr& other) const = 0;
237
238 protected:
240 const Ref ref_;
242 const FieldLoc fieldloc_;
244 int64_t offset_;
246 int64_t width_;
248 int64_t length_;
249 };
250
290 template <typename T>
291 class
292#ifdef AWKWARD_IDENTITIES_NO_EXTERN_TEMPLATE
293 LIBAWKWARD_EXPORT_SYMBOL
294#endif
295 IdentitiesOf: public Identities {
296 public:
311 IdentitiesOf<T>(const Ref ref,
312 const FieldLoc& fieldloc,
313 int64_t offset,
314 int64_t width,
315 int64_t length,
316 const std::shared_ptr<T> ptr,
317 kernel::lib ptr_lib = kernel::lib::cpu);
318
321 IdentitiesOf<T>(const Ref ref,
322 const FieldLoc& fieldloc,
323 int64_t width,
324 int64_t length,
325 kernel::lib ptr_lib = kernel::lib::cpu);
326
328 const std::shared_ptr<T>
329 ptr() const;
330
331 kernel::lib
332 ptr_lib() const override;
333
335 T*
336 data() const;
337
338 const std::string
339 classname() const override;
340
341 const std::string
342 identity_at(int64_t at) const override;
343
344 const IdentitiesPtr
345 to64() const override;
346
347 const std::string
348 tostring_part(const std::string& indent,
349 const std::string& pre,
350 const std::string& post) const override;
351
352 const IdentitiesPtr
353 getitem_range_nowrap(int64_t start, int64_t stop) const override;
354
355 void
356 nbytes_part(std::map<size_t, int64_t>& largest) const override;
357
358 const IdentitiesPtr
359 shallow_copy() const override;
360
361 const IdentitiesPtr
362 deep_copy() const override;
363
364 const IdentitiesPtr
365 getitem_carry_64(const Index64& carry) const override;
366
367 const IdentitiesPtr
368 withfieldloc(const FieldLoc& fieldloc) const override;
369
370 int64_t
371 value(int64_t row, int64_t col) const override;
372
373 const IdentitiesPtr
374 copy_to(kernel::lib ptr_lib) const override;
375
381 const std::vector<T>
382 getitem_at(int64_t at) const;
383
386 const std::vector<T>
387 getitem_at_nowrap(int64_t at) const;
388
400 const IdentitiesPtr
401 getitem_range(int64_t start, int64_t stop) const;
402
403 bool
404 referentially_equal(const IdentitiesPtr& other) const override;
405
406 private:
408 const std::shared_ptr<T> ptr_;
410 const kernel::lib ptr_lib_;
411 };
412
413#ifndef AWKWARD_IDENTITIES_NO_EXTERN_TEMPLATE
414 extern template class IdentitiesOf<int32_t>;
415 extern template class IdentitiesOf<int64_t>;
416#endif
417
418 using Identities32 = IdentitiesOf<int32_t>;
419 using Identities64 = IdentitiesOf<int64_t>;
420}
421
422#endif // AWKWARD_IDENTITIES_H_
Index.h
awkward::IdentitiesOf
A contiguous, two-dimensional array of integers and a list of strings used to represent a path from t...
Definition: Identities.h:295
awkward::IdentitiesOf::deep_copy
const IdentitiesPtr deep_copy() const override
Copies this Identities node and all the data in its buffer.
awkward::IdentitiesOf::withfieldloc
const IdentitiesPtr withfieldloc(const FieldLoc &fieldloc) const override
Returns this Identities node with a different fieldloc.
awkward::IdentitiesOf::data
T * data() const
Raw pointer to the beginning of data (i.e. offset accounted for).
awkward::IdentitiesOf::shallow_copy
const IdentitiesPtr shallow_copy() const override
Copies this Identities node without copying its buffer.
awkward::IdentitiesOf::getitem_at
const std::vector< T > getitem_at(int64_t at) const
Returns the element at a given position in the array, handling negative indexing and bounds-checking ...
awkward::IdentitiesOf::identity_at
const std::string identity_at(int64_t at) const override
Return a string representing an identity tuple at where.
awkward::IdentitiesOf::referentially_equal
bool referentially_equal(const IdentitiesPtr &other) const override
Returns true if this Identities has all the same buffers and parameters as other; false otherwise.
awkward::IdentitiesOf::copy_to
const IdentitiesPtr copy_to(kernel::lib ptr_lib) const override
Moves the identity ptr buffer of the array between devices.
awkward::IdentitiesOf::getitem_range
const IdentitiesPtr getitem_range(int64_t start, int64_t stop) const
Subinterval of this array, handling negative indexing and bounds-checking like Python.
awkward::IdentitiesOf::nbytes_part
void nbytes_part(std::map< size_t, int64_t > &largest) const override
Internal function used to calculate Content::nbytes.
awkward::IdentitiesOf::to64
const IdentitiesPtr to64() const override
Converts this Identities to an Identities64.
awkward::IdentitiesOf::getitem_carry_64
const IdentitiesPtr getitem_carry_64(const Index64 &carry) const override
Returns an Identities array with elements filtered, rearranged, and possibly duplicated by the carry ...
awkward::IdentitiesOf::ptr
const std::shared_ptr< T > ptr() const
Reference-counted pointer to the array buffer.
awkward::IdentitiesOf::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::IdentitiesOf::value
int64_t value(int64_t row, int64_t col) const override
Returns the integer value of the two-dimensional array at row and col.
awkward::IdentitiesOf::getitem_at_nowrap
const std::vector< T > getitem_at_nowrap(int64_t at) const
Returns the element at a given position in the array, without handling negative indexing or bounds-ch...
awkward::IdentitiesOf::getitem_range_nowrap
const IdentitiesPtr getitem_range_nowrap(int64_t start, int64_t stop) const override
Subinterval of this array, without handling negative indexing or bounds-checking.
awkward::IdentitiesOf::ptr_lib
kernel::lib ptr_lib() const override
The Kernel Library that ptr uses.
awkward::IdentitiesOf::classname
const std::string classname() const override
User-friendly name of this class: "Identities32" or "Identities64".
awkward::Identities
A contiguous, two-dimensional array of integers and a list of strings used to represent a path from t...
Definition: Identities.h:57
awkward::Identities::tostring
const std::string tostring() const
Returns a string representation of this array (multi-line XML).
awkward::Identities::Identities
Identities(const Ref ref, const FieldLoc &fieldloc, int64_t offset, int64_t width, int64_t length)
Called by all subclass constructors; assigns ref, fieldloc, offset, width, and length upon constructi...
awkward::Identities::width_
int64_t width_
See width.
Definition: Identities.h:246
awkward::Identities::length
const int64_t length() const
The number of identities in the array.
awkward::Identities::width
const int64_t width() const
The number of integers in each identity tuple.
awkward::Identities::none
static IdentitiesPtr none()
A constant, empty Identities pointer (nullptr).
awkward::Identities::to64
virtual const IdentitiesPtr to64() const =0
Converts this Identities to an Identities64.
awkward::Identities::ptr_lib
virtual kernel::lib ptr_lib() const =0
The Kernel Library that ptr uses.
awkward::Identities::getitem_carry_64
virtual const IdentitiesPtr getitem_carry_64(const Index64 &carry) const =0
Returns an Identities array with elements filtered, rearranged, and possibly duplicated by the carry ...
awkward::Identities::~Identities
virtual ~Identities()
Virtual destructor acts as a first non-inline virtual function that determines a specific translation...
awkward::Identities::Ref
int64_t Ref
Identities reference type (64-bit integer).
Definition: Identities.h:60
awkward::Identities::tostring_part
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.
awkward::Identities::newref
static Ref newref()
Returns a new Identities reference that is globally unique in the current process.
awkward::Identities::copy_to
virtual const IdentitiesPtr copy_to(kernel::lib ptr_lib) const =0
Moves the identity ptr buffer of the array between devices.
awkward::Identities::ref
const Ref ref() const
A globally unique reference to this set of identities.
awkward::Identities::shallow_copy
virtual const IdentitiesPtr shallow_copy() const =0
Copies this Identities node without copying its buffer.
awkward::Identities::offset
const int64_t offset() const
Location of item zero in the buffer, relative to ptr, measured in the number of elements....
awkward::Identities::value
virtual int64_t value(int64_t row, int64_t col) const =0
Returns the integer value of the two-dimensional array at row and col.
awkward::Identities::classname
virtual const std::string classname() const =0
User-friendly name of this class: "Identities32" or "Identities64".
awkward::Identities::fieldloc_
const FieldLoc fieldloc_
See fieldloc.
Definition: Identities.h:242
awkward::Identities::fieldloc
const FieldLoc fieldloc() const
A list of integer-string pairs indicating the positions of all tuple/record field indicators within t...
awkward::Identities::deep_copy
virtual const IdentitiesPtr deep_copy() const =0
Copies this Identities node and all the data in its buffer.
awkward::Identities::nbytes_part
virtual void nbytes_part(std::map< size_t, int64_t > &largest) const =0
Internal function used to calculate Content::nbytes.
awkward::Identities::FieldLoc
std::vector< std::pair< int64_t, std::string > > FieldLoc
Identities field location type (integer-string pairs).
Definition: Identities.h:63
awkward::Identities::offset_
int64_t offset_
See offset.
Definition: Identities.h:244
awkward::Identities::getitem_range_nowrap
virtual const IdentitiesPtr getitem_range_nowrap(int64_t start, int64_t stop) const =0
Subinterval of this array, without handling negative indexing or bounds-checking.
awkward::Identities::identity_at
virtual const std::string identity_at(int64_t where) const =0
Return a string representing an identity tuple at where.
awkward::Identities::ref_
const Ref ref_
See ref.
Definition: Identities.h:240
awkward::Identities::withfieldloc
virtual const IdentitiesPtr withfieldloc(const FieldLoc &fieldloc) const =0
Returns this Identities node with a different fieldloc.
awkward::Identities::referentially_equal
virtual bool referentially_equal(const IdentitiesPtr &other) const =0
Returns true if this Identities has all the same buffers and parameters as other; false otherwise.
awkward::IndexOf
A contiguous, one-dimensional array of integers used to represent data structures,...
Definition: Index.h:82
common.h
LIBAWKWARD_EXPORT_SYMBOL
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
awkward::kernel::lib
lib
Definition: kernel-dispatch.h:20
awkward::kernel::lib::cpu
@ cpu
awkward
Definition: BitMaskedArray.h:15
awkward::IdentitiesPtr
std::shared_ptr< Identities > IdentitiesPtr
Definition: Identities.h:16