Build fix

This commit is contained in:
Amos Bird 2020-02-22 16:44:23 +08:00
parent f5d6043a5d
commit 693cf211fa
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
7 changed files with 36 additions and 24 deletions

View File

@ -11,7 +11,7 @@ using Int16 = int16_t;
using Int32 = int32_t;
using Int64 = int64_t;
using UInt8 = uint8_t;
using UInt8 = char8_t;
using UInt16 = uint16_t;
using UInt32 = uint32_t;
using UInt64 = uint64_t;

View File

@ -78,7 +78,7 @@ static void printInteger(char *& out, T value)
}
}
void formatIPv6(const unsigned char * src, char *& dst, UInt8 zeroed_tail_bytes_count)
void formatIPv6(const unsigned char * src, char *& dst, uint8_t zeroed_tail_bytes_count)
{
struct { int base, len; } best{-1, 0}, cur{-1, 0};
std::array<UInt16, IPV6_BINARY_LENGTH / sizeof(UInt16)> words{};
@ -139,12 +139,12 @@ void formatIPv6(const unsigned char * src, char *& dst, UInt8 zeroed_tail_bytes_
/// Is this address an encapsulated IPv4?
if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffffu)))
{
UInt8 ipv4_buffer[IPV4_BINARY_LENGTH] = {0};
uint8_t ipv4_buffer[IPV4_BINARY_LENGTH] = {0};
memcpy(ipv4_buffer, src + 12, IPV4_BINARY_LENGTH);
// Due to historical reasons formatIPv4() takes ipv4 in BE format, but inside ipv6 we store it in LE-format.
std::reverse(std::begin(ipv4_buffer), std::end(ipv4_buffer));
formatIPv4(ipv4_buffer, dst, std::min(zeroed_tail_bytes_count, static_cast<UInt8>(IPV4_BINARY_LENGTH)), "0");
formatIPv4(ipv4_buffer, dst, std::min(zeroed_tail_bytes_count, static_cast<uint8_t>(IPV4_BINARY_LENGTH)), "0");
// formatIPv4 has already added a null-terminator for us.
return;
}

View File

@ -92,7 +92,7 @@ AsHexStringHelper<T> AsHexString(const T & container)
template <typename T>
std::string bin(const T & value, size_t bits = sizeof(T)*8)
{
static const UInt8 MAX_BITS = sizeof(T)*8;
static const uint8_t MAX_BITS = sizeof(T)*8;
assert(bits <= MAX_BITS);
return std::bitset<sizeof(T) * 8>(static_cast<unsigned long long>(value))
@ -270,7 +270,7 @@ template <typename T, typename ContainerLeft, typename ContainerRight>
}
template <typename ContainerLeft, typename ContainerRight>
::testing::AssertionResult EqualByteContainers(UInt8 element_size, const ContainerLeft & left, const ContainerRight & right)
::testing::AssertionResult EqualByteContainers(uint8_t element_size, const ContainerLeft & left, const ContainerRight & right)
{
switch (element_size)
{

View File

@ -12,7 +12,7 @@ struct DecimalUtilsSplitAndCombineTestParam
const char * description;
Decimal64 decimal_value;
UInt8 scale;
uint8_t scale;
DecimalUtils::DecimalComponents<typename Decimal64::NativeType> components;
};

View File

@ -120,13 +120,13 @@ public:
if constexpr (std::is_same_v<Func, Base64Encode>)
{
outlen = _tb64e(source, srclen, dst_pos);
outlen = _tb64e(reinterpret_cast<const uint8_t *>(source), srclen, reinterpret_cast<uint8_t *>(dst_pos));
}
else if constexpr (std::is_same_v<Func, Base64Decode>)
{
if (srclen > 0)
{
outlen = _tb64d(source, srclen, dst_pos);
outlen = _tb64d(reinterpret_cast<const uint8_t *>(source), srclen, reinterpret_cast<uint8_t *>(dst_pos));
if (!outlen)
throw Exception("Failed to " + getName() + " input '" + String(reinterpret_cast<const char *>(source), srclen) + "'", ErrorCodes::INCORRECT_DATA);
}
@ -138,7 +138,7 @@ public:
// during decoding character array can be partially polluted
// if fail, revert back and clean
auto savepoint = dst_pos;
outlen = _tb64d(source, srclen, dst_pos);
outlen = _tb64d(reinterpret_cast<const uint8_t *>(source), srclen, reinterpret_cast<uint8_t *>(dst_pos));
if (!outlen)
{
outlen = 0;

View File

@ -24,12 +24,12 @@ using namespace DB;
// each prime bit is set to 0.
// v-61 v-53 v-47 v-41 v-37 v-31 v-23 v-17 v-11 v-5
const UInt64 BIT_PATTERN = 0b11101011'11101111'10111010'11101111'10101111'10111010'11101011'10101001;
const UInt8 PRIMES[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61};
const uint8_t PRIMES[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61};
template <typename T>
std::string bin(const T & value, size_t bits = sizeof(T)*8)
{
static const UInt8 MAX_BITS = sizeof(T)*8;
static const uint8_t MAX_BITS = sizeof(T)*8;
assert(bits <= MAX_BITS);
return std::bitset<sizeof(T) * 8>(static_cast<unsigned long long>(value))
@ -38,7 +38,7 @@ std::string bin(const T & value, size_t bits = sizeof(T)*8)
// gets N low bits of value
template <typename T>
T getBits(UInt8 bits, const T & value)
T getBits(uint8_t bits, const T & value)
{
return value & maskLowBits<T>(bits);
}
@ -109,10 +109,10 @@ template <typename ValueLeft, typename ValueRight>
struct TestCaseParameter
{
std::vector<std::pair<UInt8, UInt64>> bits_and_vals;
std::vector<std::pair<uint8_t, UInt64>> bits_and_vals;
std::string expected_buffer_binary;
TestCaseParameter(std::vector<std::pair<UInt8, UInt64>> vals, std::string binary = std::string{})
TestCaseParameter(std::vector<std::pair<uint8_t, UInt64>> vals, std::string binary = std::string{})
: bits_and_vals(std::move(vals)),
expected_buffer_binary(binary)
{}
@ -168,7 +168,7 @@ TEST_P(BitIO, WriteAndRead)
<< ", at bit position: " << std::dec << reader.count()
<< ".\nBuffer memory:\n" << dumpContents(data));
// const UInt8 next_byte = getBits(bv.first, bv.second) &
// const uint8_t next_byte = getBits(bv.first, bv.second) &
ASSERT_TRUE(BinaryEqual(getBits(bv.first, bv.second), reader.readBits(bv.first)));
++item;
@ -224,12 +224,12 @@ INSTANTIATE_TEST_SUITE_P(Simple,
})
);
TestCaseParameter primes_case(UInt8 repeat_times, UInt64 pattern)
TestCaseParameter primes_case(uint8_t repeat_times, UInt64 pattern)
{
std::vector<std::pair<UInt8, UInt64>> test_data;
std::vector<std::pair<uint8_t, UInt64>> test_data;
{
for (UInt8 r = 0; r < repeat_times; ++r)
for (uint8_t r = 0; r < repeat_times; ++r)
{
for (const auto p : PRIMES)
{
@ -251,15 +251,15 @@ INSTANTIATE_TEST_SUITE_P(Primes,
TEST(BitHelpers, maskLowBits)
{
EXPECT_EQ(0b00000111, ::maskLowBits<UInt8>(3));
EXPECT_EQ(0b01111111, ::maskLowBits<UInt8>(7));
EXPECT_EQ(0b00000111, ::maskLowBits<uint8_t>(3));
EXPECT_EQ(0b01111111, ::maskLowBits<uint8_t>(7));
EXPECT_EQ(0b0000000001111111, ::maskLowBits<UInt16>(7));
EXPECT_EQ(0b0001111111111111, ::maskLowBits<UInt16>(13));
EXPECT_EQ(0b00000111111111111111111111111111, ::maskLowBits<UInt32>(27));
EXPECT_EQ(0b111111111111111111111111111111111, ::maskLowBits<UInt64>(33));
EXPECT_EQ(0b11111111111111111111111111111111111, ::maskLowBits<UInt64>(35));
EXPECT_EQ(0xFF, ::maskLowBits<UInt8>(8));
EXPECT_EQ(0xFF, ::maskLowBits<uint8_t>(8));
EXPECT_EQ(0xFFFF, ::maskLowBits<UInt16>(16));
EXPECT_EQ(0xFFFFFFFF, ::maskLowBits<UInt32>(32));
EXPECT_EQ(0xFFFFFFFFFFFFFFFF, ::maskLowBits<UInt64>(64));

View File

@ -66,7 +66,13 @@ static void fillArrowArrayWithNumericColumnData(
arrow_null_bytemap_raw_ptr = arrow_null_bytemap.data();
}
status = builder.AppendValues(internal_data.data(), internal_data.size(), arrow_null_bytemap_raw_ptr);
if constexpr (std::is_same_v<NumericType, UInt8>)
status = builder.AppendValues(
reinterpret_cast<const uint8_t *>(internal_data.data()),
internal_data.size(),
reinterpret_cast<const uint8_t *>(arrow_null_bytemap_raw_ptr));
else
status = builder.AppendValues(internal_data.data(), internal_data.size(), reinterpret_cast<const uint8_t *>(arrow_null_bytemap_raw_ptr));
checkStatus(status, write_column->getName());
status = builder.Finish(&arrow_array);
@ -188,7 +194,13 @@ static void fillArrowArrayWithDecimalColumnData(
arrow_null_bytemap_raw_ptr = arrow_null_bytemap.data();
}
status = builder.AppendValues(reinterpret_cast<const uint8_t*>(internal_data.data()), internal_data.size(), arrow_null_bytemap_raw_ptr);
if constexpr (std::is_same_v<NumericType, UInt8>)
status = builder.AppendValues(
reinterpret_cast<const uint8_t *>(internal_data.data()),
internal_data.size(),
reinterpret_cast<const uint8_t *>(arrow_null_bytemap_raw_ptr));
else
status = builder.AppendValues(internal_data.data(), internal_data.size(), reinterpret_cast<const uint8_t *>(arrow_null_bytemap_raw_ptr));
checkStatus(status, write_column->getName());
status = builder.Finish(&arrow_array);