2011-10-24 12:10:59 +00:00
|
|
|
#include <DB/DataStreams/NativeBlockInputStream.h>
|
|
|
|
#include <DB/DataStreams/NativeBlockOutputStream.h>
|
|
|
|
#include <DB/DataStreams/TabSeparatedRowInputStream.h>
|
|
|
|
#include <DB/DataStreams/TabSeparatedRowOutputStream.h>
|
2011-10-30 05:19:41 +00:00
|
|
|
#include <DB/DataStreams/ValuesRowInputStream.h>
|
|
|
|
#include <DB/DataStreams/ValuesRowOutputStream.h>
|
2011-11-06 06:22:52 +00:00
|
|
|
#include <DB/DataStreams/TabSeparatedBlockOutputStream.h>
|
2011-11-07 01:15:37 +00:00
|
|
|
#include <DB/DataStreams/PrettyBlockOutputStream.h>
|
2011-11-28 04:05:53 +00:00
|
|
|
#include <DB/DataStreams/PrettyCompactBlockOutputStream.h>
|
|
|
|
#include <DB/DataStreams/PrettySpaceBlockOutputStream.h>
|
|
|
|
#include <DB/DataStreams/VerticalRowOutputStream.h>
|
2011-10-24 12:10:59 +00:00
|
|
|
#include <DB/DataStreams/BlockInputStreamFromRowInputStream.h>
|
|
|
|
#include <DB/DataStreams/BlockOutputStreamFromRowOutputStream.h>
|
|
|
|
#include <DB/DataStreams/FormatFactory.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
BlockInputStreamPtr FormatFactory::getInput(const String & name, ReadBuffer & buf,
|
|
|
|
Block & sample, size_t max_block_size, DataTypeFactory & data_type_factory) const
|
|
|
|
{
|
|
|
|
if (name == "Native")
|
|
|
|
return new NativeBlockInputStream(buf, data_type_factory);
|
|
|
|
else if (name == "TabSeparated")
|
2011-11-06 05:01:42 +00:00
|
|
|
return new BlockInputStreamFromRowInputStream(new TabSeparatedRowInputStream(buf, sample), sample, max_block_size);
|
2011-11-06 06:22:52 +00:00
|
|
|
else if (name == "TabSeparatedWithNames")
|
|
|
|
return new BlockInputStreamFromRowInputStream(new TabSeparatedRowInputStream(buf, sample, true), sample, max_block_size);
|
|
|
|
else if (name == "TabSeparatedWithNamesAndTypes")
|
|
|
|
return new BlockInputStreamFromRowInputStream(new TabSeparatedRowInputStream(buf, sample, true, true), sample, max_block_size);
|
2011-11-28 04:05:53 +00:00
|
|
|
else if (name == "BlockTabSeparated" || name == "Pretty" || name == "PrettyCompact" || name == "PrettySpace" || name == "Vertical")
|
2011-11-07 01:15:37 +00:00
|
|
|
throw Exception("Format " + name + " is not suitable for input", ErrorCodes::FORMAT_IS_NOT_SUITABLE_FOR_INPUT);
|
2011-10-30 05:19:41 +00:00
|
|
|
else if (name == "Values")
|
2011-11-06 05:01:42 +00:00
|
|
|
return new BlockInputStreamFromRowInputStream(new ValuesRowInputStream(buf, sample), sample, max_block_size);
|
2011-10-24 12:10:59 +00:00
|
|
|
else
|
|
|
|
throw Exception("Unknown format " + name, ErrorCodes::UNKNOWN_FORMAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockOutputStreamPtr FormatFactory::getOutput(const String & name, WriteBuffer & buf,
|
|
|
|
Block & sample) const
|
|
|
|
{
|
|
|
|
if (name == "Native")
|
|
|
|
return new NativeBlockOutputStream(buf);
|
|
|
|
else if (name == "TabSeparated")
|
2011-11-06 05:01:42 +00:00
|
|
|
return new BlockOutputStreamFromRowOutputStream(new TabSeparatedRowOutputStream(buf, sample));
|
2011-11-06 06:22:52 +00:00
|
|
|
else if (name == "TabSeparatedWithNames")
|
|
|
|
return new BlockOutputStreamFromRowOutputStream(new TabSeparatedRowOutputStream(buf, sample, true));
|
|
|
|
else if (name == "TabSeparatedWithNamesAndTypes")
|
|
|
|
return new BlockOutputStreamFromRowOutputStream(new TabSeparatedRowOutputStream(buf, sample, true, true));
|
|
|
|
else if (name == "BlockTabSeparated")
|
|
|
|
return new TabSeparatedBlockOutputStream(buf);
|
2011-11-07 01:15:37 +00:00
|
|
|
else if (name == "Pretty")
|
|
|
|
return new PrettyBlockOutputStream(buf);
|
2011-11-28 04:05:53 +00:00
|
|
|
else if (name == "PrettyCompact")
|
|
|
|
return new PrettyCompactBlockOutputStream(buf);
|
|
|
|
else if (name == "PrettySpace")
|
|
|
|
return new PrettySpaceBlockOutputStream(buf);
|
|
|
|
else if (name == "Vertical")
|
|
|
|
return new BlockOutputStreamFromRowOutputStream(new VerticalRowOutputStream(buf, sample));
|
2011-10-30 05:19:41 +00:00
|
|
|
else if (name == "Values")
|
2011-11-06 05:01:42 +00:00
|
|
|
return new BlockOutputStreamFromRowOutputStream(new ValuesRowOutputStream(buf, sample));
|
2011-10-24 12:10:59 +00:00
|
|
|
else
|
|
|
|
throw Exception("Unknown format " + name, ErrorCodes::UNKNOWN_FORMAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|