mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Remove ODBCDriver2BlockOutputStream.
This commit is contained in:
parent
d57d8a609f
commit
51bd715781
@ -239,7 +239,6 @@ void registerOutputFormatPrettySpace(FormatFactory & factory);
|
||||
void registerOutputFormatVertical(FormatFactory & factory);
|
||||
void registerOutputFormatXML(FormatFactory & factory);
|
||||
void registerOutputFormatODBCDriver(FormatFactory & factory);
|
||||
void registerOutputFormatODBCDriver2(FormatFactory & factory);
|
||||
void registerOutputFormatNull(FormatFactory & factory);
|
||||
|
||||
void registerOutputFormatProcessorPretty(FormatFactory & factory);
|
||||
@ -300,7 +299,6 @@ FormatFactory::FormatFactory()
|
||||
registerOutputFormatVertical(*this);
|
||||
registerOutputFormatXML(*this);
|
||||
registerOutputFormatODBCDriver(*this);
|
||||
registerOutputFormatODBCDriver2(*this);
|
||||
registerOutputFormatNull(*this);
|
||||
|
||||
registerOutputFormatProcessorPretty(*this);
|
||||
|
@ -1,103 +0,0 @@
|
||||
#include <Core/Block.h>
|
||||
#include <Formats/FormatFactory.h>
|
||||
#include <Formats/ODBCDriver2BlockOutputStream.h>
|
||||
#include <IO/WriteBuffer.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <DataTypes/DataTypeLowCardinality.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
ODBCDriver2BlockOutputStream::ODBCDriver2BlockOutputStream(
|
||||
WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings)
|
||||
: out(out_), header(header_), format_settings(format_settings)
|
||||
{
|
||||
}
|
||||
|
||||
void ODBCDriver2BlockOutputStream::flush()
|
||||
{
|
||||
out.next();
|
||||
}
|
||||
|
||||
void writeODBCString(WriteBuffer & out, const std::string & str)
|
||||
{
|
||||
writeIntBinary(Int32(str.size()), out);
|
||||
out.write(str.data(), str.size());
|
||||
}
|
||||
|
||||
static void writeRow(const Block & block, size_t row_idx, WriteBuffer & out, const FormatSettings & format_settings, std::string & buffer)
|
||||
{
|
||||
size_t columns = block.columns();
|
||||
for (size_t column_idx = 0; column_idx < columns; ++column_idx)
|
||||
{
|
||||
buffer.clear();
|
||||
const ColumnWithTypeAndName & col = block.getByPosition(column_idx);
|
||||
|
||||
if (col.column->isNullAt(row_idx))
|
||||
{
|
||||
writeIntBinary(Int32(-1), out);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
WriteBufferFromString text_out(buffer);
|
||||
col.type->serializeAsText(*col.column, row_idx, text_out, format_settings);
|
||||
}
|
||||
writeODBCString(out, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ODBCDriver2BlockOutputStream::write(const Block & block)
|
||||
{
|
||||
String text_value;
|
||||
const size_t rows = block.rows();
|
||||
for (size_t i = 0; i < rows; ++i)
|
||||
writeRow(block, i, out, format_settings, text_value);
|
||||
}
|
||||
|
||||
void ODBCDriver2BlockOutputStream::writeSuffix()
|
||||
{
|
||||
if (totals)
|
||||
write(totals);
|
||||
}
|
||||
|
||||
void ODBCDriver2BlockOutputStream::writePrefix()
|
||||
{
|
||||
const size_t columns = header.columns();
|
||||
|
||||
/// Number of header rows.
|
||||
writeIntBinary(Int32(2), out);
|
||||
|
||||
/// Names of columns.
|
||||
/// Number of columns + 1 for first name column.
|
||||
writeIntBinary(Int32(columns + 1), out);
|
||||
writeODBCString(out, "name");
|
||||
for (size_t i = 0; i < columns; ++i)
|
||||
{
|
||||
const ColumnWithTypeAndName & col = header.getByPosition(i);
|
||||
writeODBCString(out, col.name);
|
||||
}
|
||||
|
||||
/// Types of columns.
|
||||
writeIntBinary(Int32(columns + 1), out);
|
||||
writeODBCString(out, "type");
|
||||
for (size_t i = 0; i < columns; ++i)
|
||||
{
|
||||
auto type = header.getByPosition(i).type;
|
||||
if (type->lowCardinality())
|
||||
type = recursiveRemoveLowCardinality(type);
|
||||
writeODBCString(out, type->getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void registerOutputFormatODBCDriver2(FormatFactory & factory)
|
||||
{
|
||||
factory.registerOutputFormat(
|
||||
"ODBCDriver2", [](WriteBuffer & buf, const Block & sample, const Context &, const FormatSettings & format_settings)
|
||||
{
|
||||
return std::make_shared<ODBCDriver2BlockOutputStream>(buf, sample, format_settings);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <Core/Block.h>
|
||||
#include <DataStreams/IBlockOutputStream.h>
|
||||
#include <Formats/FormatSettings.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class WriteBuffer;
|
||||
|
||||
|
||||
/** A data format designed to simplify the implementation of the ODBC driver.
|
||||
* ODBC driver is designed to be build for different platforms without dependencies from the main code,
|
||||
* so the format is made that way so that it can be as easy as possible to parse it.
|
||||
* A header is displayed with the required information.
|
||||
* The data is then output in the order of the rows. Each value is displayed as follows: length in Int32 format (-1 for NULL), then data in text form.
|
||||
*/
|
||||
class ODBCDriver2BlockOutputStream final : public IBlockOutputStream
|
||||
{
|
||||
public:
|
||||
ODBCDriver2BlockOutputStream(WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings);
|
||||
|
||||
Block getHeader() const override
|
||||
{
|
||||
return header;
|
||||
}
|
||||
void write(const Block & block) override;
|
||||
void writePrefix() override;
|
||||
void writeSuffix() override;
|
||||
|
||||
void flush() override;
|
||||
std::string getContentType() const override
|
||||
{
|
||||
return "application/octet-stream";
|
||||
}
|
||||
void setTotals(const Block & totals_) override { totals = totals_; }
|
||||
|
||||
private:
|
||||
WriteBuffer & out;
|
||||
const Block header;
|
||||
const FormatSettings format_settings;
|
||||
|
||||
protected:
|
||||
Block totals;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user