Merge pull request #25152 from ClickHouse/move-code-in-more-local-place

Move code to more appropriate place
This commit is contained in:
Nikolai Kochetov 2021-06-10 11:08:27 +03:00 committed by GitHub
commit 4185c5954f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -269,20 +269,6 @@ public:
void operator() (const AggregateFunctionStateData & x) const;
};
/// This is a special visitor which is used to get partition ID.
/// Calculate hash for UUID the same way as for UInt128.
/// It worked this way until 21.5, and we cannot change it,
/// or partition ID will be different in case UUID is used in partition key.
/// (It is not recommended to use UUID as partition key).
class LegacyFieldVisitorHash : public FieldVisitorHash
{
public:
using FieldVisitorHash::FieldVisitorHash;
using FieldVisitorHash::operator();
void operator() (const UUID & x) const { FieldVisitorHash::operator()(x.toUnderType()); }
};
template <typename T> constexpr bool isDecimalField() { return false; }
template <> constexpr bool isDecimalField<DecimalField<Decimal32>>() { return true; }
template <> constexpr bool isDecimalField<DecimalField<Decimal64>>() { return true; }

View File

@ -14,11 +14,28 @@
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
namespace
{
/// This is a special visitor which is used to get partition ID.
/// Calculate hash for UUID the same way as for UInt128.
/// It worked this way until 21.5, and we cannot change it,
/// or partition ID will be different in case UUID is used in partition key.
/// (It is not recommended to use UUID as partition key).
class LegacyFieldVisitorHash : public FieldVisitorHash
{
public:
using FieldVisitorHash::FieldVisitorHash;
using FieldVisitorHash::operator();
void operator() (const UUID & x) const { FieldVisitorHash::operator()(x.toUnderType()); }
};
}
static std::unique_ptr<ReadBufferFromFileBase> openForReading(const DiskPtr & disk, const String & path)
{
return disk->readFile(path, std::min(size_t(DBMS_DEFAULT_BUFFER_SIZE), disk->getFileSize(path)));