mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +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.
|
/** 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
|
class TabSeparatedRawRowInputFormat : public TabSeparatedRowInputFormat
|
||||||
{
|
{
|
||||||
@ -33,23 +33,12 @@ public:
|
|||||||
|
|
||||||
bool readField(IColumn & column, const DataTypePtr & type, bool) override
|
bool readField(IColumn & column, const DataTypePtr & type, bool) override
|
||||||
{
|
{
|
||||||
// TODO: possible to optimize
|
char * pos = find_first_symbols<'\n', '\t'>(in.position(), in.buffer().end());
|
||||||
std::string buf;
|
ReadBufferFromMemory cell(in.position(), pos - in.position());
|
||||||
|
|
||||||
while (!in.eof())
|
type->deserializeAsWholeText(column, cell, format_settings);
|
||||||
{
|
|
||||||
char c = *in.position();
|
|
||||||
|
|
||||||
if (c == '\n' || c == '\t')
|
in.position() = pos;
|
||||||
break;
|
|
||||||
|
|
||||||
in.ignore();
|
|
||||||
buf.push_back(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReadBufferFromString line_in(buf);
|
|
||||||
|
|
||||||
type->deserializeAsWholeText(column, line_in, format_settings);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1 +1,2 @@
|
|||||||
"a 1
|
"a 1 \ \\ "\"" "\\""
|
||||||
|
["\"a ", "1", "\\", "\\\\", "\"\\\"\"", "\"\\\\\"\""]
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
drop table if exists tsv_raw;
|
drop table if exists tsv_raw;
|
||||||
create table tsv_raw (a String, b Int64) engine = Memory;
|
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
|
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;
|
drop table tsv_raw;
|
||||||
|
Loading…
Reference in New Issue
Block a user