-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathenum.h
More file actions
66 lines (47 loc) · 1.81 KB
/
enum.h
File metadata and controls
66 lines (47 loc) · 1.81 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
#pragma once
#include "column.h"
namespace clickhouse {
template <typename T>
class ColumnEnum : public Column {
public:
using ValueType = T;
ColumnEnum(TypeRef type);
ColumnEnum(TypeRef type, const std::vector<T>& data);
ColumnEnum(TypeRef type, std::vector<T>&& data);
/// Appends one element to the end of column.
void Append(const T& value, bool checkValue = false);
void Append(const std::string& name);
/// Returns element at given row number.
const T& At(size_t n) const;
std::string_view NameAt(size_t n) const;
/// Returns element at given row number.
inline const T& operator[] (size_t n) const { return At(n); }
/// Set element at given row number.
void SetAt(size_t n, const T& value, bool checkValue = false);
void SetNameAt(size_t n, const std::string& name);
public:
/// Appends content of given column to the end of current one.
void Append(ColumnRef column) override;
/// Increase the capacity of the column for large block insertion.
void Reserve(size_t new_cap) override;
size_t Capacity() const override;
/// Loads column data from input stream.
bool LoadBody(InputStream* input, size_t rows) override;
/// Saves column data to output stream.
void SaveBody(OutputStream* output) override;
/// Clear column data.
void Clear() override;
/// Returns count of rows in the column.
size_t Size() const override;
size_t MemoryUsage() const override;
/// Makes slice of the current column.
ColumnRef Slice(size_t begin, size_t len) const override;
ColumnRef CloneEmpty() const override;
void Swap(Column& other) override;
ItemView GetItem(size_t index) const override;
private:
std::vector<T> data_;
};
using ColumnEnum8 = ColumnEnum<int8_t>;
using ColumnEnum16 = ColumnEnum<int16_t>;
}