Index.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_INDEX_H_
4 #define AWKWARD_INDEX_H_
5 
6 #include <string>
7 #include <map>
8 #include <memory>
9 
10 #include "awkward/common.h"
11 #include "awkward/util.h"
13 
14 namespace awkward {
15  template <typename T>
16  class IndexOf;
17 
32  public:
34  enum class Form {i8, u8, i32, u32, i64, kNumIndexForm};
35 
37  static Form
38  str2form(const std::string& str);
39 
41  static const std::string
42  form2str(Form form);
43 
47  virtual ~Index();
48 
52  virtual const std::shared_ptr<Index>
53  shallow_copy() const = 0;
54 
56  virtual IndexOf<int64_t>
57  to64() const = 0;
58 
60  virtual bool
61  iscontiguous() const = 0;
62  };
63 
77  template <typename T>
78  class
79 #ifdef AWKWARD_INDEX_NO_EXTERN_TEMPLATE
81 #endif
82  IndexOf: public Index {
83  public:
94  IndexOf<T>(const std::shared_ptr<T>& ptr,
95  int64_t offset,
96  int64_t length,
97  kernel::lib ptr_lib);
98 
100  IndexOf<T>(int64_t length, kernel::lib ptr_lib = kernel::lib::cpu);
101 
103  static IndexOf<T>
104  empty_advanced();
105 
107  bool
108  is_empty_advanced() const;
109 
111  const std::shared_ptr<T>
112  ptr() const;
113 
116  ptr_lib() const;
117 
119  T*
120  data() const;
121 
128  int64_t
129  offset() const;
130 
132  int64_t
133  length() const;
134 
137  const std::string
138  classname() const;
139 
141  const std::string
142  tostring() const;
143 
150  const std::string
151  tostring_part(const std::string& indent,
152  const std::string& pre,
153  const std::string& post) const;
154 
156  Form
157  form() const;
158 
164  T
165  getitem_at(int64_t at) const;
166 
169  T
170  getitem_at_nowrap(int64_t at) const;
171 
175  void
176  setitem_at_nowrap(int64_t at, T value) const;
177 
189  IndexOf<T>
190  getitem_range(int64_t start, int64_t stop) const;
191 
199  IndexOf<T>
200  getitem_range_nowrap(int64_t start, int64_t stop) const;
201 
211  void
212  nbytes_part(std::map<size_t, int64_t>& largest) const;
213 
214  const std::shared_ptr<Index>
215  shallow_copy() const override;
216 
218  to64() const override;
219 
220  bool
221  iscontiguous() const override;
222 
226  const IndexOf<T>
227  deep_copy() const;
228 
229  const IndexOf<T>
230  copy_to(kernel::lib ptr_lib) const;
231 
232  bool
233  referentially_equal(const IndexOf<T>& other) const;
234 
235  private:
237  const std::shared_ptr<T> ptr_;
239  const kernel::lib ptr_lib_;
241  const int64_t offset_;
243  const int64_t length_;
244  bool is_empty_advanced_;
245  };
246 
247 #ifndef AWKWARD_INDEX_NO_EXTERN_TEMPLATE
248  extern template class IndexOf<int8_t>;
249  extern template class IndexOf<uint8_t>;
250  extern template class IndexOf<int32_t>;
251  extern template class IndexOf<uint32_t>;
252  extern template class IndexOf<int64_t>;
253 #endif
254 
260 }
261 
262 #endif // AWKWARD_INDEX_H_
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
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
Form
Integer type of an Index, used by ListForm, IndexedForm, etc.
Definition: Index.h:34
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, one-dimensional array of integers used to represent data structures, rather than numerical data in the arrays themselves.
Definition: Index.h:31
lib
Definition: kernel-dispatch.h:20