-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathnumeric.cpp
More file actions
110 lines (87 loc) · 2.56 KB
/
numeric.cpp
File metadata and controls
110 lines (87 loc) · 2.56 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "numeric.h"
#include "utils.h"
#include "../types/int128.h"
namespace clickhouse {
template <typename T>
ColumnVector<T>::ColumnVector()
: Column(Type::CreateSimple<T>())
{
}
template <typename T>
ColumnVector<T>::ColumnVector(const std::vector<T> & data)
: Column(Type::CreateSimple<T>())
, data_(data)
{
}
template <typename T>
ColumnVector<T>::ColumnVector(std::vector<T> && data)
: Column(Type::CreateSimple<T>())
, data_(std::move(data))
{
}
template <typename T>
void ColumnVector<T>::Append(const T& value) {
data_.push_back(value);
}
template <typename T>
void ColumnVector<T>::Erase(size_t pos, size_t count) {
const auto begin = std::min(pos, data_.size());
const auto last = begin + std::min(data_.size() - begin, count);
data_.erase(data_.begin() + begin, data_.begin() + last);
}
template <typename T>
void ColumnVector<T>::Clear() {
data_.clear();
}
template <typename T>
const T& ColumnVector<T>::At(size_t n) const {
return data_.at(n);
}
template <typename T>
const T& ColumnVector<T>::operator [] (size_t n) const {
return data_[n];
}
template <typename T>
void ColumnVector<T>::Append(ColumnRef column) {
if (auto col = column->As<ColumnVector<T>>()) {
data_.insert(data_.end(), col->data_.begin(), col->data_.end());
}
}
template <typename T>
bool ColumnVector<T>::Load(CodedInputStream* input, size_t rows) {
data_.resize(rows);
return input->ReadRaw(data_.data(), data_.size() * sizeof(T));
}
template <typename T>
void ColumnVector<T>::Save(CodedOutputStream* output) {
output->WriteRaw(data_.data(), data_.size() * sizeof(T));
}
template <typename T>
size_t ColumnVector<T>::Size() const {
return data_.size();
}
template <typename T>
ColumnRef ColumnVector<T>::Slice(size_t begin, size_t len) const {
return std::make_shared<ColumnVector<T>>(SliceVector(data_, begin, len));
}
template <typename T>
void ColumnVector<T>::Swap(Column& other) {
auto & col = dynamic_cast<ColumnVector<T> &>(other);
data_.swap(col.data_);
}
template <typename T>
ItemView ColumnVector<T>::GetItem(size_t index) const {
return ItemView{type_->GetCode(), data_[index]};
}
template class ColumnVector<int8_t>;
template class ColumnVector<int16_t>;
template class ColumnVector<int32_t>;
template class ColumnVector<int64_t>;
template class ColumnVector<uint8_t>;
template class ColumnVector<uint16_t>;
template class ColumnVector<uint32_t>;
template class ColumnVector<uint64_t>;
template class ColumnVector<Int128>;
template class ColumnVector<float>;
template class ColumnVector<double>;
}