forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_array.hpp
More file actions
68 lines (53 loc) · 1.07 KB
/
Copy pathjson_array.hpp
File metadata and controls
68 lines (53 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include "../dtype.hpp"
#include "../exceptions.hpp"
#include "../type.hpp"
#include <base/memory_buffer.hpp>
#include <icm/shape.hpp>
#include <icm/const_json.hpp>
#include <cstdint>
#include <span>
#include <vector>
namespace nd::impl {
class json_array
{
public:
struct holder_t
{
explicit holder_t(const icm::const_json& d)
: data(d)
{
ASSERT(data.is_array());
}
icm::const_json data;
};
public:
explicit json_array(const icm::const_json& value)
: value_(std::make_shared<holder_t>(value))
{
}
public:
enum dtype dtype() const
{
return dtype::object;
}
nd::array get(int64_t index) const
{
return adapt(value_->data.at(index));
}
icm::shape shape() const
{
return icm::shape(value_->data.size());
}
uint8_t dimensions() const
{
return nd::type::unknown_dimensions;
}
constexpr bool is_dynamic() const noexcept
{
return true;
}
private:
std::shared_ptr<holder_t> value_;
};
}