File tree Expand file tree Collapse file tree 5 files changed +24
-9
lines changed Expand file tree Collapse file tree 5 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ PROJECT (CLICKHOUSE-CLIENT)
29
29
SUBDIRS (
30
30
clickhouse
31
31
contrib/cityhash
32
+ contrib/abseil-cpp
32
33
contrib/lz4
33
34
)
34
35
Original file line number Diff line number Diff line change @@ -32,12 +32,16 @@ SET_TARGET_PROPERTIES(clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX)
32
32
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
33
33
cityhash-lib
34
34
lz4-lib
35
+ absl::numeric
36
+ absl::strings
35
37
)
36
38
37
39
ADD_LIBRARY (clickhouse-cpp-lib-static STATIC ${clickhouse-cpp-lib-src} )
38
40
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
39
41
cityhash-lib
40
42
lz4-lib
43
+ absl::numeric
44
+ absl::strings
41
45
)
42
46
43
47
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
Original file line number Diff line number Diff line change 1
1
#include " decimal.h"
2
2
3
+ #include < absl/strings/numbers.h>
3
4
#include < iostream>
4
5
5
6
namespace clickhouse {
@@ -61,10 +62,13 @@ void ColumnDecimal::Append(const std::string& value) {
61
62
62
63
has_dot = true ;
63
64
} else if (*c >= ' 0' && *c <= ' 9' ) {
64
- if (__builtin_mul_overflow (int_value, 10 , &int_value) ||
65
- __builtin_add_overflow (int_value, *c - ' 0' , &int_value)) {
66
- throw std::runtime_error (" value is too big for 128-bit integer" );
67
- }
65
+ int_value *= 10 ;
66
+ int_value += *c - ' 0' ;
67
+ // TODO: check overflows
68
+ // if (__builtin_mul_overflow(int_value, 10, &int_value) ||
69
+ // __builtin_add_overflow(int_value, *c - '0', &int_value)) {
70
+ // throw std::runtime_error("value is too big for 128-bit integer");
71
+ // }
68
72
} else {
69
73
throw std::runtime_error (std::string (" unexpected symbol '" ) + (*c) + " ' in decimal value" );
70
74
}
@@ -76,9 +80,11 @@ void ColumnDecimal::Append(const std::string& value) {
76
80
}
77
81
78
82
while (zeros) {
79
- if (__builtin_mul_overflow (int_value, 10 , &int_value)) {
80
- throw std::runtime_error (" value is too big for 128-bit integer" );
81
- }
83
+ int_value *= 10 ;
84
+ // TODO: check overflows
85
+ // if (__builtin_mul_overflow(int_value, 10, &int_value)) {
86
+ // throw std::runtime_error("value is too big for 128-bit integer");
87
+ // }
82
88
--zeros;
83
89
}
84
90
Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
+ #include < absl/numeric/int128.h>
3
4
#include " column.h"
4
5
5
6
namespace clickhouse {
@@ -48,7 +49,7 @@ class ColumnVector : public Column {
48
49
std::vector<T> data_;
49
50
};
50
51
51
- using Int128 = __int128 ;
52
+ using Int128 = absl::int128 ;
52
53
53
54
using ColumnUInt8 = ColumnVector<uint8_t >;
54
55
using ColumnUInt16 = ColumnVector<uint16_t >;
Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
+ #include < absl/numeric/int128.h>
4
+
3
5
#include < map>
4
6
#include < memory>
5
7
#include < string>
6
8
#include < vector>
7
9
8
10
namespace clickhouse {
9
11
12
+ using Int128 = absl::int128;
10
13
using TypeRef = std::shared_ptr<class Type >;
11
14
12
15
class Type {
@@ -200,7 +203,7 @@ inline TypeRef Type::CreateSimple<int64_t>() {
200
203
}
201
204
202
205
template <>
203
- inline TypeRef Type::CreateSimple<__int128 >() {
206
+ inline TypeRef Type::CreateSimple<Int128 >() {
204
207
return TypeRef (new Type (Int128));
205
208
}
206
209
You can’t perform that action at this time.
0 commit comments