-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathdecimal.h
45 lines (35 loc) · 1.16 KB
/
decimal.h
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
#pragma once
#include "column.h"
#include "numeric.h"
namespace clickhouse {
/**
* Represents a column of decimal type.
*/
class ColumnDecimal : public Column {
public:
ColumnDecimal(size_t precision, size_t scale);
void Append(Int64 value); /// When Int128 is not supported by\not available to users.
void Append(const Int128& value);
void Append(const std::string& value);
Int128 At(size_t i) const;
Int64 AtAsInt64(size_t i) const; /// result will overflow if value doesn't fit into Int64.
public:
void Append(ColumnRef column) override;
bool Load(CodedInputStream* input, size_t rows) override;
void Save(CodedOutputStream* output) override;
void Clear() override;
size_t Size() const override;
ColumnRef Slice(size_t begin, size_t len) const override;
void Swap(Column& other) override;
ItemView GetItem(size_t index) const override;
size_t GetScale() const;
size_t GetPrecision() const;
private:
/// Depending on a precision it can be one of:
/// - ColumnInt32
/// - ColumnInt64
/// - ColumnInt128
ColumnRef data_;
explicit ColumnDecimal(TypeRef type, ColumnRef data);
};
}