mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Optimize and fix
This commit is contained in:
parent
cfcfe32fda
commit
e284bf83d0
@ -10,7 +10,7 @@ namespace DB
|
||||
{
|
||||
|
||||
/** A stream to input data in tsv format, but without escaping individual values.
|
||||
* It only supports one string column
|
||||
* It only supports columns without '\n' or '\t'
|
||||
*/
|
||||
class TabSeparatedRawRowInputFormat : public TabSeparatedRowInputFormat
|
||||
{
|
||||
@ -33,23 +33,12 @@ public:
|
||||
|
||||
bool readField(IColumn & column, const DataTypePtr & type, bool) override
|
||||
{
|
||||
// TODO: possible to optimize
|
||||
std::string buf;
|
||||
char * pos = find_first_symbols<'\n', '\t'>(in.position(), in.buffer().end());
|
||||
ReadBufferFromMemory cell(in.position(), pos - in.position());
|
||||
|
||||
while (!in.eof())
|
||||
{
|
||||
char c = *in.position();
|
||||
type->deserializeAsWholeText(column, cell, format_settings);
|
||||
|
||||
if (c == '\n' || c == '\t')
|
||||
break;
|
||||
|
||||
in.ignore();
|
||||
buf.push_back(c);
|
||||
}
|
||||
|
||||
ReadBufferFromString line_in(buf);
|
||||
|
||||
type->deserializeAsWholeText(column, line_in, format_settings);
|
||||
in.position() = pos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
"a 1
|
||||
"a 1 \ \\ "\"" "\\""
|
||||
["\"a ", "1", "\\", "\\\\", "\"\\\"\"", "\"\\\\\"\""]
|
||||
|
@ -1,7 +1,8 @@
|
||||
drop table if exists tsv_raw;
|
||||
create table tsv_raw (a String, b Int64) engine = Memory;
|
||||
insert into tsv_raw format TSVRaw "a 1
|
||||
create table tsv_raw (strval String, intval Int64, b1 String, b2 String, b3 String, b4 String) engine = Memory;
|
||||
insert into tsv_raw format TSVRaw "a 1 \ \\ "\"" "\\""
|
||||
;
|
||||
|
||||
select * from tsv_raw;
|
||||
select * from tsv_raw format TSVRaw;
|
||||
select * from tsv_raw format JSONCompactEachRow;
|
||||
drop table tsv_raw;
|
||||
|
Loading…
Reference in New Issue
Block a user