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 
14 namespace awkward {
15  class Identities;
16  using IdentitiesPtr = std::shared_ptr<Identities>;
17 
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_;
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
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 
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 
420 }
421 
422 #endif // AWKWARD_IDENTITIES_H_
A contiguous, two-dimensional array of integers and a list of strings used to represent a path from t...
Definition: Identities.h:57
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
int64_t offset_
See offset.
Definition: Identities.h:244
int64_t length_
See length.
Definition: Identities.h:248
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
const ContentPtr none
A constant value with type None.
const FieldLoc fieldloc_
See fieldloc.
Definition: Identities.h:242
std::vector< std::pair< int64_t, std::string > > FieldLoc
Identities field location type (integer-string pairs).
Definition: Identities.h:63
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 ...
Mapping::value_type::value_type value(Mapping a, const std::string &name)
Definition: datetime_util.h:49
A contiguous, two-dimensional array of integers and a list of strings used to represent a path from t...
Definition: Identities.h:291
const Ref ref_
See ref.
Definition: Identities.h:240
std::shared_ptr< Identities > IdentitiesPtr
Definition: Identities.h:16
int64_t width_
See width.
Definition: Identities.h:246
int64_t Ref
Identities reference type (64-bit integer).
Definition: Identities.h:60
lib
Definition: kernel-dispatch.h:20