MCPcopy Create free account
hub / github.com/activeloopai/deeplake / array

Class array

cpp/nd/array.hpp:51–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49constexpr std::size_t s_array_bytes = 39;
50
51class array
52{
53private:
54 enum class mode_t : uint8_t
55 {
56 null,
57 scalar_inplace,
58 holder_inplace,
59 holder_pointer
60 };
61
62 using void_ptr = void*;
63
64 template <std::size_t s>
65 using byte_t = std::array<char, s>;
66
67 struct holder_
68 {
69
70 virtual void copy_to(void_ptr) const = 0;
71 virtual void move_to(void_ptr) = 0;
72
73 virtual ~holder_() = default;
74
75 virtual icm::shape shape() const = 0;
76 virtual std::span<const uint8_t> data() const = 0;
77
78 virtual byte_t<1> byte_1_value(int64_t) const = 0;
79 virtual byte_t<2> byte_2_value(int64_t) const = 0;
80 virtual byte_t<4> byte_4_value(int64_t) const = 0;
81 virtual byte_t<8> byte_8_value(int64_t) const = 0;
82 virtual dict dict_value(int64_t) const = 0;
83
84 virtual iterator begin() const = 0;
85 virtual iterator end() const = 0;
86 virtual array get(int64_t) const = 0;
87 virtual array get_range(int64_t, int64_t) const = 0;
88 virtual array eval() const = 0;
89 virtual void copy_data(std::span<uint8_t>) const = 0;
90
91 virtual array stride(icm::index_mapping_t<int64_t>&& source_shape) const = 0;
92 virtual array stride(icm::index_mapping_t<int>&& source_shape) const = 0;
93 virtual void nonzero(icm::bit_vector_view) const = 0;
94 };
95 using holder_ptr = std::shared_ptr<holder_>;
96
97 template <typename I>
98 struct concrete_holder_ final : public holder_
99 {
100 static_assert(impl::has_data_member_function_v<I> || impl::has_get_member_function_v<I>,
101 "Array adaptors should implement at least one of the following functions:\n"
102 "\tstd::span<const uint8_t> data() const;\n"
103 "\tnd::array get(int64_t index) const;\n");
104
105 static constexpr int value_funcs_count = static_cast<int>(impl::has_value_member_function_v<I, bool>) +
106 static_cast<int>(impl::has_value_member_function_v<I, char>) +
107 static_cast<int>(impl::has_value_member_function_v<I, uint8_t>) +
108 static_cast<int>(impl::has_value_member_function_v<I, int8_t>) +

Callers 3

rangeMethod · 0.70
getMethod · 0.70
get_rangeMethod · 0.70

Calls 5

copy_toMethod · 0.80
get_rawMethod · 0.80
get_allocatedMethod · 0.80
move_toMethod · 0.80
holderMethod · 0.45

Tested by

no test coverage detected