mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-13 19:14:30 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#include <DataStreams/SizeLimits.h>
|
|
#include <Common/formatReadable.h>
|
|
#include <Common/Exception.h>
|
|
#include <string>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
bool SizeLimits::check(UInt64 rows, UInt64 bytes, const char * what, int too_many_rows_exception_code, int too_many_bytes_exception_code) const
|
|
{
|
|
if (overflow_mode == OverflowMode::THROW)
|
|
{
|
|
if (max_rows && rows > max_rows)
|
|
throw Exception("Limit for " + std::string(what) + " exceeded, max rows: " + formatReadableQuantity(max_rows)
|
|
+ ", current rows: " + formatReadableQuantity(rows), too_many_rows_exception_code);
|
|
|
|
if (max_bytes && bytes > max_bytes)
|
|
throw Exception("Limit for " + std::string(what) + " exceeded, max bytes: " + formatReadableSizeWithBinarySuffix(max_bytes)
|
|
+ ", current bytes: " + formatReadableSizeWithBinarySuffix(bytes), too_many_bytes_exception_code);
|
|
|
|
return true;
|
|
}
|
|
|
|
return softCheck(rows, bytes);
|
|
}
|
|
|
|
bool SizeLimits::softCheck(UInt64 rows, UInt64 bytes) const
|
|
{
|
|
if (max_rows && rows > max_rows)
|
|
return false;
|
|
if (max_bytes && bytes > max_bytes)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
bool SizeLimits::check(UInt64 rows, UInt64 bytes, const char * what, int exception_code) const
|
|
{
|
|
return check(rows, bytes, what, exception_code, exception_code);
|
|
}
|
|
|
|
}
|