forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_vector_array.hpp
More file actions
68 lines (52 loc) · 1.15 KB
/
Copy pathstring_vector_array.hpp
File metadata and controls
68 lines (52 loc) · 1.15 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 "dynamic_array.hpp"
#include "std_span_array.hpp"
#include <base/span_cast.hpp>
#include <icm/shape.hpp>
#include <cstdint>
#include <span>
#include <vector>
#include <iostream>
namespace nd::impl {
class string_vector_array
{
public:
using value_type = std::vector<std::string>;
struct holder_t
{
explicit holder_t(value_type&& d)
: data(std::move(d))
, shape(data.size())
{}
value_type data;
icm::shape shape;
};
explicit string_vector_array(value_type&& value)
: value_(std::make_shared<holder_t>(std::move(value)))
{}
enum dtype dtype() const
{
return dtype::string;
}
uint8_t dimensions() const
{
return 1;
}
nd::array get(int64_t index) const
{
return nd::array(string_array(std::string(value_->data[index])));
}
const icm::shape& shape() const
{
return value_->shape;
}
constexpr bool is_dynamic() const noexcept
{
return true;
}
private:
const std::shared_ptr<holder_t> value_;
};
}