changes made

This commit is contained in:
Mikhail Korotov 2020-01-21 23:00:43 +03:00
parent 584826424a
commit 3b7fdaa534
3 changed files with 28 additions and 58 deletions

View File

@ -966,76 +966,40 @@ readTextWithSuffix(T & x, ReadBuffer & buf)
readIntText(x, buf);
if (buf.eof())
return;
auto F = [&buf, &x] (long long base, int power_of_two) mutable
{
++buf.position();
if (buf.eof())
{
x *= base;
}
else if (*buf.position() == 'i')
{
x = (x << power_of_two);
++buf.position();
}
return;
};
switch (*buf.position())
{
case 'k':
++buf.position();
if (buf.eof())
{
x *= 1000;
return;
}
else if (*buf.position() == 'i')
{
x = (x << 10);
}
else
{
return;
}
case 'k': [[fallthrough]];
case 'K':
F(1000, 10);
break;
case 'M':
++buf.position();
if (buf.eof())
{
x *= 1000000; /// 1e+6
return;
}
else if (*buf.position() == 'i')
{
x = (x << 20);
}
else
{
return;
}
F(1000000, 20);
break;
case 'G':
++buf.position();
if (buf.eof())
{
x *= 1000000000; /// 1e+9
return;
}
else if (*buf.position() == 'i')
{
x = (x << 30);
}
else
{
return;
}
F(1000000000, 30);
break;
case 'T':
++buf.position();
if (buf.eof())
{
x *= 1000000000000; /// 1e+12
return;
}
else if (*buf.position() == 'i')
{
x = (x << 40);
}
else
{
return;
}
F(1000000000000ULL, 40);
break;
default:
return;
}
++buf.position();
return;
}

View File

@ -2,6 +2,8 @@
3221225472
1567000
125952
1567000
125952
12000000
32505856
1000000000000

View File

@ -6,6 +6,10 @@ SET max_memory_usage = '1567k';
SELECT value FROM system.settings WHERE name = 'max_memory_usage';
SET max_memory_usage = '123ki';
SELECT value FROM system.settings WHERE name = 'max_memory_usage';
SET max_memory_usage = '1567K';
SELECT value FROM system.settings WHERE name = 'max_memory_usage';
SET max_memory_usage = '123Ki';
SELECT value FROM system.settings WHERE name = 'max_memory_usage';
SET max_memory_usage = '12M';
SELECT value FROM system.settings WHERE name = 'max_memory_usage';
SET max_memory_usage = '31Mi';