Skip to content

Commit 7deffc4

Browse files
committed
change int128 lib
1 parent cc53825 commit 7deffc4

File tree

1,254 files changed

+1778
-192267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,254 files changed

+1778
-192267
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ PROJECT (CLICKHOUSE-CLIENT)
2929
SUBDIRS (
3030
clickhouse
3131
contrib/cityhash
32-
contrib/abseil-cpp
3332
contrib/lz4
33+
contrib/bigint
3434
)
3535

3636
IF (BUILD_BENCHMARK)

clickhouse/CMakeLists.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,12 @@ SET_TARGET_PROPERTIES(clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX)
3232
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
3333
cityhash-lib
3434
lz4-lib
35-
absl::numeric
36-
absl::strings
3735
)
3836

3937
ADD_LIBRARY (clickhouse-cpp-lib-static STATIC ${clickhouse-cpp-lib-src})
4038
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
4139
cityhash-lib
4240
lz4-lib
43-
absl::numeric
44-
absl::strings
4541
)
4642

4743
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
@@ -55,7 +51,6 @@ INSTALL(TARGETS clickhouse-cpp-lib clickhouse-cpp-lib-static
5551
LIBRARY DESTINATION lib
5652
)
5753

58-
5954
# general
6055
INSTALL(FILES block.h DESTINATION include/clickhouse/)
6156
INSTALL(FILES client.h DESTINATION include/clickhouse/)
@@ -95,4 +90,4 @@ INSTALL(FILES columns/uuid.h DESTINATION include/clickhouse/columns/)
9590

9691
# types
9792
INSTALL(FILES types/type_parser.h DESTINATION include/clickhouse/types/)
98-
INSTALL(FILES types/types.h DESTINATION include/clickhouse/types/)
93+
INSTALL(FILES types/types.h DESTINATION include/clickhouse/types/)

clickhouse/columns/decimal.cpp

+7-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "decimal.h"
22

3-
#include <absl/strings/numbers.h>
43
#include <iostream>
54

65
namespace clickhouse {
@@ -22,21 +21,21 @@ ColumnDecimal::ColumnDecimal(TypeRef type)
2221
{
2322
}
2423

25-
void ColumnDecimal::Append(const Int128& value) {
24+
void ColumnDecimal::Append(const BigInt& value) {
2625
if (data_->Type()->GetCode() == Type::Int32) {
2726
//data_->As<ColumnInt32>()->Append(static_cast<ColumnInt32::DataType>(value));
28-
static_cast<std::shared_ptr<ColumnInt32>>(data_->As<ColumnInt32>())->Append(static_cast<ColumnInt32::DataType>(value));
27+
static_cast<std::shared_ptr<ColumnInt32>>(data_->As<ColumnInt32>())->Append(static_cast<ColumnInt32::DataType>(value.to_long()));
2928
} else if (data_->Type()->GetCode() == Type::Int64) {
3029
//data_->As<ColumnInt64>()->Append(static_cast<ColumnInt64::DataType>(value));
31-
static_cast<std::shared_ptr<ColumnInt64>>(data_->As<ColumnInt64>())->Append(static_cast<ColumnInt64::DataType>(value));
30+
static_cast<std::shared_ptr<ColumnInt64>>(data_->As<ColumnInt64>())->Append(static_cast<ColumnInt64::DataType>(value.to_long_long()));
3231
} else {
3332
//data_->As<ColumnInt128>()->Append(static_cast<ColumnInt128::DataType>(value));
3433
static_cast<std::shared_ptr<ColumnInt128>>(data_->As<ColumnInt128>())->Append(static_cast<ColumnInt128::DataType>(value));
3534
}
3635
}
3736

3837
void ColumnDecimal::Append(const std::string& value) {
39-
Int128 int_value = 0;
38+
BigInt int_value = 0;
4039
auto c = value.begin();
4140
auto end = value.end();
4241
bool sign = true;
@@ -64,11 +63,6 @@ void ColumnDecimal::Append(const std::string& value) {
6463
} else if (*c >= '0' && *c <= '9') {
6564
int_value *= 10;
6665
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-
//}
7266
} else {
7367
throw std::runtime_error(std::string("unexpected symbol '") + (*c) + "' in decimal value");
7468
}
@@ -81,21 +75,17 @@ void ColumnDecimal::Append(const std::string& value) {
8175

8276
while (zeros) {
8377
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-
//}
8878
--zeros;
8979
}
9080

9181
Append(sign ? int_value : -int_value);
9282
}
9383

94-
Int128 ColumnDecimal::At(size_t i) const {
84+
BigInt ColumnDecimal::At(size_t i) const {
9585
if (data_->Type()->GetCode() == Type::Int32) {
96-
return static_cast<Int128>(data_->As<ColumnInt32>()->At(i));
86+
return static_cast<BigInt>(data_->As<ColumnInt32>()->At(i));
9787
} else if (data_->Type()->GetCode() == Type::Int64) {
98-
return static_cast<Int128>(data_->As<ColumnInt64>()->At(i));
88+
return static_cast<BigInt>(data_->As<ColumnInt64>()->At(i));
9989
} else {
10090
return data_->As<ColumnInt128>()->At(i);
10191
}

clickhouse/columns/decimal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class ColumnDecimal : public Column {
1212
public:
1313
ColumnDecimal(size_t precision, size_t scale);
1414

15-
void Append(const Int128& value);
15+
void Append(const BigInt& value);
1616
void Append(const std::string& value);
1717

18-
Int128 At(size_t i) const;
18+
BigInt At(size_t i) const;
1919

2020
public:
2121
void Append(ColumnRef column) override;

clickhouse/columns/numeric.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ template class ColumnVector<uint8_t>;
7474
template class ColumnVector<uint16_t>;
7575
template class ColumnVector<uint32_t>;
7676
template class ColumnVector<uint64_t>;
77-
template class ColumnVector<Int128>;
77+
template class ColumnVector<BigInt>;
7878

7979
template class ColumnVector<float>;
8080
template class ColumnVector<double>;

clickhouse/columns/numeric.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#include <absl/numeric/int128.h>
43
#include "column.h"
54

65
namespace clickhouse {
@@ -49,8 +48,6 @@ class ColumnVector : public Column {
4948
std::vector<T> data_;
5049
};
5150

52-
using Int128 = absl::int128;
53-
5451
using ColumnUInt8 = ColumnVector<uint8_t>;
5552
using ColumnUInt16 = ColumnVector<uint16_t>;
5653
using ColumnUInt32 = ColumnVector<uint32_t>;
@@ -60,7 +57,7 @@ using ColumnInt8 = ColumnVector<int8_t>;
6057
using ColumnInt16 = ColumnVector<int16_t>;
6158
using ColumnInt32 = ColumnVector<int32_t>;
6259
using ColumnInt64 = ColumnVector<int64_t>;
63-
using ColumnInt128 = ColumnVector<Int128>;
60+
using ColumnInt128 = ColumnVector<BigInt>;
6461

6562
using ColumnFloat32 = ColumnVector<float>;
6663
using ColumnFloat64 = ColumnVector<double>;

clickhouse/types/types.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <absl/numeric/int128.h>
3+
#include <BigInt.hpp>
44

55
#include <map>
66
#include <memory>
@@ -9,7 +9,6 @@
99

1010
namespace clickhouse {
1111

12-
using Int128 = absl::int128;
1312
using TypeRef = std::shared_ptr<class Type>;
1413

1514
class Type {
@@ -203,7 +202,7 @@ inline TypeRef Type::CreateSimple<int64_t>() {
203202
}
204203

205204
template <>
206-
inline TypeRef Type::CreateSimple<Int128>() {
205+
inline TypeRef Type::CreateSimple<BigInt>() {
207206
return TypeRef(new Type(Int128));
208207
}
209208

contrib/abseil-cpp/.clang-format

-4
This file was deleted.

contrib/abseil-cpp/.gitignore

-15
This file was deleted.

contrib/abseil-cpp/ABSEIL_ISSUE_TEMPLATE.md

-22
This file was deleted.

contrib/abseil-cpp/AUTHORS

-6
This file was deleted.

0 commit comments

Comments
 (0)