mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Remove mention of UUID type for dictonnary
This commit is contained in:
parent
525851ec68
commit
d6ab06437a
@ -25,41 +25,41 @@ struct UInt128
|
||||
UInt64 second;
|
||||
|
||||
UInt128() = default;
|
||||
explicit UInt128(const UInt64 rhs) : first(rhs), second(0) { }
|
||||
explicit UInt128(const UInt64 rhs) : first(0), second(rhs) { }
|
||||
|
||||
bool operator== (const UInt128 & rhs) const { return second == rhs.second && first == rhs.first; }
|
||||
bool operator!= (const UInt128 & rhs) const { return second != rhs.second || first != rhs.first; }
|
||||
bool operator>= (const UInt128 & rhs) const { return (second == rhs.second) ? first >= rhs.first : second > rhs.second; }
|
||||
bool operator> (const UInt128 & rhs) const { return second > rhs.second || first > rhs.first; }
|
||||
bool operator<= (const UInt128 & rhs) const { return (second == rhs.second) ? first <= rhs.first : second < rhs.second; }
|
||||
bool operator< (const UInt128 & rhs) const { return second < rhs.second || first < rhs.first; }
|
||||
bool operator>= (const UInt128 & rhs) const { return (first == rhs.first) ? second >= rhs.second : first > rhs.first; }
|
||||
bool operator> (const UInt128 & rhs) const { return (first == rhs.first) ? second > rhs.second : first > rhs.first; }
|
||||
bool operator<= (const UInt128 & rhs) const { return (first == rhs.first) ? second <= rhs.second : first < rhs.first; }
|
||||
bool operator< (const UInt128 & rhs) const { return (first == rhs.first) ? second < rhs.second : first < rhs.first; }
|
||||
|
||||
/** Type stored in the database will contains no more than 64 bits at the moment, don't need
|
||||
* to check the `second` element
|
||||
*/
|
||||
template<typename T> bool operator== (const T rhs) const { return second == 0 && static_cast<T>(first) == rhs; }
|
||||
template<typename T> bool operator!= (const T rhs) const { return second != 0 || static_cast<T>(first) != rhs; }
|
||||
template<typename T> bool operator>= (const T rhs) const { return second != 0 && static_cast<T>(first) >= rhs; }
|
||||
template<typename T> bool operator> (const T rhs) const { return second != 0 && static_cast<T>(first) > rhs; }
|
||||
template<typename T> bool operator<= (const T rhs) const { return second == 0 && static_cast<T>(first) <= rhs; }
|
||||
template<typename T> bool operator< (const T rhs) const { return second == 0 && static_cast<T>(first) > rhs; }
|
||||
template<typename T> bool operator== (const T rhs) const { return first == 0 && static_cast<T>(second) == rhs; }
|
||||
template<typename T> bool operator!= (const T rhs) const { return first != 0 || static_cast<T>(second) != rhs; }
|
||||
template<typename T> bool operator>= (const T rhs) const { return first != 0 && static_cast<T>(second) >= rhs; }
|
||||
template<typename T> bool operator> (const T rhs) const { return first != 0 && static_cast<T>(second) > rhs; }
|
||||
template<typename T> bool operator<= (const T rhs) const { return first == 0 && static_cast<T>(second) <= rhs; }
|
||||
template<typename T> bool operator< (const T rhs) const { return first == 0 && static_cast<T>(second) > rhs; }
|
||||
|
||||
template<typename T> explicit operator T() const { return static_cast<T>(first); }
|
||||
template<typename T> explicit operator T() const { return static_cast<T>(second); }
|
||||
operator UInt128() const { return *this; }
|
||||
|
||||
#if !__clang__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
UInt128 & operator= (const UInt64 rhs) { first = rhs; second = 0; return *this; }
|
||||
UInt128 & operator= (const UInt64 rhs) { first = 0; second = rhs; return *this; }
|
||||
};
|
||||
|
||||
template<typename T> bool operator== (T a, const UInt128 & b) { return b == a; }
|
||||
template<typename T> bool operator!= (T a, const UInt128 & b) { return b != a; }
|
||||
template<typename T> bool operator>= (T a, const UInt128 & b) { return b.second == 0 && a >= static_cast<T>(b.first); }
|
||||
template<typename T> bool operator> (T a, const UInt128 & b) { return b.second == 0 && a > static_cast<T>(b.first); }
|
||||
template<typename T> bool operator<= (T a, const UInt128 & b) { return b.second != 0 || a <= static_cast<T>(b.first); }
|
||||
template<typename T> bool operator< (T a, const UInt128 & b) { return b.second != 0 || a < static_cast<T>(b.first); }
|
||||
template<typename T> bool operator>= (T a, const UInt128 & b) { return b.first == 0 && a >= static_cast<T>(b.second); }
|
||||
template<typename T> bool operator> (T a, const UInt128 & b) { return b.first == 0 && a > static_cast<T>(b.second); }
|
||||
template<typename T> bool operator<= (T a, const UInt128 & b) { return b.first != 0 || a <= static_cast<T>(b.second); }
|
||||
template<typename T> bool operator< (T a, const UInt128 & b) { return b.first != 0 || a < static_cast<T>(b.second); }
|
||||
|
||||
struct UInt128Hash
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <DataTypes/DataTypeDate.h>
|
||||
#include <DataTypes/DataTypeDateTime.h>
|
||||
#include <DataTypes/DataTypeUuid.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -55,8 +54,6 @@ void ExternalResultDescription::init(const Block & sample_block_)
|
||||
types.push_back(ValueType::Date);
|
||||
else if (typeid_cast<const DataTypeDateTime *>(type))
|
||||
types.push_back(ValueType::DateTime);
|
||||
else if (typeid_cast<const DataTypeUuid *>(type))
|
||||
types.push_back(ValueType::Uuid);
|
||||
else
|
||||
throw Exception{
|
||||
"Unsupported type " + type->getName(),
|
||||
|
@ -24,8 +24,7 @@ struct ExternalResultDescription
|
||||
Float64,
|
||||
String,
|
||||
Date,
|
||||
DateTime,
|
||||
Uuid
|
||||
DateTime
|
||||
};
|
||||
|
||||
Block sample_block;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <ext/range.h>
|
||||
#include <Core/FieldVisitors.h>
|
||||
#include <Poco/UUID.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -134,7 +133,6 @@ namespace
|
||||
break;
|
||||
}
|
||||
|
||||
case ValueType::Uuid: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ namespace
|
||||
case ValueType::String: static_cast<ColumnString *>(column)->insert(value.convert<String>()); break;
|
||||
case ValueType::Date: static_cast<ColumnUInt16 *>(column)->insert(UInt16{LocalDate{value.convert<String>()}.getDayNum()}); break;
|
||||
case ValueType::DateTime: static_cast<ColumnUInt32 *>(column)->insert(time_t{LocalDateTime{value.convert<String>()}}); break;
|
||||
case ValueType::Uuid: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +687,6 @@ public:
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
std::cout << "err" << std::endl;
|
||||
/// More convenient error message.
|
||||
if (e.code() == ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF)
|
||||
{
|
||||
@ -1104,16 +1103,37 @@ struct ToStringMonotonicity
|
||||
static IFunction::Monotonicity get(const IDataType & type, const Field & left, const Field & right)
|
||||
{
|
||||
IFunction::Monotonicity positive(true, true);
|
||||
//IFunction::Monotonicity not_monotonic;
|
||||
IFunction::Monotonicity not_monotonic;
|
||||
|
||||
/// `toString` function is monotonous if the argument is Date or DateTime, or non-negative numbers with the same number of symbols.
|
||||
|
||||
if (typeid_cast<const DataTypeDate *>(&type)
|
||||
|| typeid_cast<const DataTypeDateTime *>(&type))
|
||||
return positive;
|
||||
|
||||
if (left.isNull() || right.isNull())
|
||||
return {};
|
||||
|
||||
return positive;
|
||||
if (left.getType() == Field::Types::UInt64
|
||||
&& right.getType() == Field::Types::UInt64)
|
||||
{
|
||||
return (left.get<Int64>() == 0 && right.get<Int64>() == 0)
|
||||
|| (floor(log10(left.get<UInt64>())) == floor(log10(right.get<UInt64>())))
|
||||
? positive : not_monotonic;
|
||||
}
|
||||
|
||||
if (left.getType() == Field::Types::Int64
|
||||
&& right.getType() == Field::Types::Int64)
|
||||
{
|
||||
return (left.get<Int64>() == 0 && right.get<Int64>() == 0)
|
||||
|| (left.get<Int64>() > 0 && right.get<Int64>() > 0 && floor(log10(left.get<Int64>())) == floor(log10(right.get<Int64>())))
|
||||
? positive : not_monotonic;
|
||||
}
|
||||
|
||||
return not_monotonic;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct NameToUInt8 { static constexpr auto name = "toUInt8"; };
|
||||
struct NameToUInt16 { static constexpr auto name = "toUInt16"; };
|
||||
struct NameToUInt32 { static constexpr auto name = "toUInt32"; };
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <IO/WriteBufferFromString.h>
|
||||
#include <IO/Operators.h>
|
||||
#include <common/find_first_symbols.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -41,6 +41,24 @@ void parseUUID(const UInt8 * src36, UInt8 * dst16)
|
||||
parseHex(&src36[24], &dst16[10], 6);
|
||||
}
|
||||
|
||||
void parseUUID(const UInt8 * src36, Uuid & uuid)
|
||||
{
|
||||
char s[16 + 1];
|
||||
|
||||
s[16] = '\0';
|
||||
|
||||
memcpy(&s[0], &src36[0], 8);
|
||||
memcpy(&s[8], &src36[9], 4);
|
||||
memcpy(&s[12], &src36[14], 4);
|
||||
|
||||
uuid.first = strtoull(s, nullptr, 16);
|
||||
|
||||
memcpy(&s[0], &src36[19], 4);
|
||||
memcpy(&s[4], &src36[24], 12);
|
||||
|
||||
uuid.second = strtoull(s, nullptr, 16);
|
||||
}
|
||||
|
||||
static void __attribute__((__noinline__)) throwAtAssertionFailed(const char * s, ReadBuffer & buf)
|
||||
{
|
||||
std::string message;
|
||||
|
@ -558,6 +558,7 @@ struct NullSink
|
||||
};
|
||||
|
||||
void parseUUID(const UInt8 * src36, UInt8 * dst16);
|
||||
void parseUUID(const UInt8 * src36, Uuid & uuid);
|
||||
void formatHex(const UInt8 * __restrict src, UInt8 * __restrict dst, const size_t num_bytes);
|
||||
|
||||
/// In YYYY-MM-DD format
|
||||
@ -601,11 +602,10 @@ inline void readUuidText(Uuid & uuid, ReadBuffer & buf)
|
||||
if (size != 36)
|
||||
{
|
||||
s[size] = 0;
|
||||
std:: cout << "wat" << s << std::endl;
|
||||
throw Exception(std::string("Cannot parse uuid ") + s, ErrorCodes::CANNOT_PARSE_UUID);
|
||||
}
|
||||
|
||||
parseUUID((const UInt8 *)s, (UInt8 *)&uuid);
|
||||
parseUUID((const UInt8 *)s, uuid);
|
||||
}
|
||||
|
||||
|
||||
@ -700,7 +700,7 @@ inline void readText(bool & x, ReadBuffer & buf) { readBoolText(x, buf); }
|
||||
inline void readText(String & x, ReadBuffer & buf) { readEscapedString(x, buf); }
|
||||
inline void readText(LocalDate & x, ReadBuffer & buf) { readDateText(x, buf); }
|
||||
inline void readText(LocalDateTime & x, ReadBuffer & buf) { readDateTimeText(x, buf); }
|
||||
inline void readText(Uuid & x, ReadBuffer & buf) { readUuidText(x, buf); }
|
||||
inline void readText(Uuid & x, ReadBuffer & buf) { readUuidText(x, buf); }
|
||||
|
||||
|
||||
/// Generic methods to read value in text format,
|
||||
@ -773,7 +773,7 @@ readCSV(T & x, ReadBuffer & buf) { readCSVSimple(x, buf); }
|
||||
inline void readCSV(String & x, ReadBuffer & buf, const char delimiter = ',') { readCSVString(x, buf, delimiter); }
|
||||
inline void readCSV(LocalDate & x, ReadBuffer & buf) { readCSVSimple(x, buf); }
|
||||
inline void readCSV(LocalDateTime & x, ReadBuffer & buf) { readCSVSimple(x, buf); }
|
||||
inline void readCSV(Uuid & x, ReadBuffer & buf) { readCSVSimple(x, buf); }
|
||||
inline void readCSV(Uuid & x, ReadBuffer & buf) { readCSVSimple(x, buf); }
|
||||
|
||||
|
||||
template <typename T>
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -46,6 +48,29 @@ void formatUUID(const UInt8 * src16, UInt8 * dst36)
|
||||
formatHex(&src16[10], &dst36[24], 6);
|
||||
}
|
||||
|
||||
void formatUUID(const Uuid & uuid, UInt8 * dst36)
|
||||
{
|
||||
char s[16+1];
|
||||
|
||||
dst36[8] = '-';
|
||||
dst36[13] = '-';
|
||||
dst36[18] = '-';
|
||||
dst36[23] = '-';
|
||||
|
||||
snprintf(s, sizeof(s), "%016llx", static_cast<long long>(uuid.first));
|
||||
|
||||
memcpy(&dst36[0], &s, 8);
|
||||
memcpy(&dst36[9], &s[8], 4);
|
||||
memcpy(&dst36[14], &s[12], 4);
|
||||
|
||||
snprintf(s, sizeof(s), "%016llx", static_cast<long long>(uuid.second));
|
||||
|
||||
memcpy(&dst36[19], &s[0], 4);
|
||||
memcpy(&dst36[24], &s[4], 12);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void writeException(const Exception & e, WriteBuffer & buf)
|
||||
{
|
||||
writeBinary(e.code(), buf);
|
||||
|
@ -475,12 +475,13 @@ inline void writeXMLString(const StringRef & s, WriteBuffer & buf)
|
||||
|
||||
void formatHex(const UInt8 * __restrict src, UInt8 * __restrict dst, const size_t num_bytes);
|
||||
void formatUUID(const UInt8 * src16, UInt8 * dst36);
|
||||
void formatUUID(const Uuid & uuid, UInt8 * dst36);
|
||||
|
||||
inline void writeUuidText(const Uuid & uuid, WriteBuffer & buf)
|
||||
{
|
||||
char s[36];
|
||||
|
||||
formatUUID((const UInt8 *)&uuid, (UInt8 *)s);
|
||||
formatUUID(uuid, (UInt8 *)s);
|
||||
buf.write(s, sizeof(s));
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TYPE_MISMATCH;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int UNKNOWN_LOAD_BALANCING;
|
||||
extern const int UNKNOWN_OVERFLOW_MODE;
|
||||
extern const int ILLEGAL_OVERFLOW_MODE;
|
||||
|
Loading…
Reference in New Issue
Block a user