Fixed parsing of floats in CSV file with custom delimiter #3142

This commit is contained in:
Alexey Milovidov 2018-09-17 21:17:30 +03:00
parent 8ba2ec9365
commit c00147f37d
2 changed files with 6 additions and 5 deletions

View File

@ -3,6 +3,7 @@
#include <Core/Defines.h>
#include <common/shift10.h>
#include <common/likely.h>
#include <Common/StringUtils/StringUtils.h>
#include <double-conversion/double-conversion.h>
@ -274,7 +275,7 @@ static inline void readUIntTextUpToNSignificantDigits(T & x, ReadBuffer & buf)
{
for (size_t i = 0; i < N; ++i)
{
if ((*buf.position() & 0xF0) == 0x30)
if (isNumericASCII(*buf.position()))
{
x *= 10;
x += *buf.position() & 0x0F;
@ -284,14 +285,14 @@ static inline void readUIntTextUpToNSignificantDigits(T & x, ReadBuffer & buf)
return;
}
while (!buf.eof() && (*buf.position() & 0xF0) == 0x30)
while (!buf.eof() && isNumericASCII(*buf.position()))
++buf.position();
}
else
{
for (size_t i = 0; i < N; ++i)
{
if (!buf.eof() && (*buf.position() & 0xF0) == 0x30)
if (!buf.eof() && isNumericASCII(*buf.position()))
{
x *= 10;
x += *buf.position() & 0x0F;
@ -301,7 +302,7 @@ static inline void readUIntTextUpToNSignificantDigits(T & x, ReadBuffer & buf)
return;
}
while (!buf.eof() && (*buf.position() & 0xF0) == 0x30)
while (!buf.eof() && isNumericASCII(*buf.position()))
++buf.position();
}
}

View File

@ -32,7 +32,7 @@ $ clickhouse-local --query="SELECT toString(rand64(1)) || toString(rand64(2)) ||
# Run test
$ for i in {1..10}; do echo $i; time ./read_float_perf < numbers$i.tsv; done
$ for i in {1..10}; do echo $i; time ./read_float_perf 2 < numbers$i.tsv; done
*/