void registerOutputFormatTabSeparated(FormatFactory & factory)
{
    for (auto name : {"TabSeparated", "TSV"})
    {
        factory.registerOutputFormat(name, [](
            WriteBuffer & buf,
            const Block & sample,
            const Context &,
            const FormatSettings & settings)
        {
            return std::make_shared<BlockOutputStreamFromRowOutputStream>(
                std::make_shared<TabSeparatedRowOutputStream>(buf, sample, false, false, settings), sample);
        });
    }

    for (auto name : {"TabSeparatedRaw", "TSVRaw"})
    {
        factory.registerOutputFormat(name, [](
            WriteBuffer & buf,
            const Block & sample,
            const Context &,
            const FormatSettings & settings)
        {
            return std::make_shared<BlockOutputStreamFromRowOutputStream>(
                std::make_shared<TabSeparatedRawRowOutputStream>(buf, sample, false, false, settings), sample);
        });
    }

    for (auto name : {"TabSeparatedWithNames", "TSVWithNames"})
    {
        factory.registerOutputFormat(name, [](
            WriteBuffer & buf,
            const Block & sample,
            const Context &,
            const FormatSettings & settings)
        {
            return std::make_shared<BlockOutputStreamFromRowOutputStream>(
                std::make_shared<TabSeparatedRowOutputStream>(buf, sample, true, false, settings), sample);
        });
    }

    for (auto name : {"TabSeparatedWithNamesAndTypes", "TSVWithNamesAndTypes"})
    {
        factory.registerOutputFormat(name, [](
            WriteBuffer & buf,
            const Block & sample,
            const Context &,
            const FormatSettings & settings)
        {
            return std::make_shared<BlockOutputStreamFromRowOutputStream>(
                std::make_shared<TabSeparatedRowOutputStream>(buf, sample, true, true, settings), sample);
        });
    }
}
void registerOutputFormatProtobuf(FormatFactory & factory)
{
    factory.registerOutputFormat(
        "Protobuf", [](WriteBuffer & buf, const Block & header, const Context & context, const FormatSettings &)
        {
            return std::make_shared<BlockOutputStreamFromRowOutputStream>(
                std::make_shared<ProtobufRowOutputStream>(buf, header, FormatSchemaInfo(context, "Protobuf")), header);
        });
}
Exemple #3
0
void registerOutputFormatNull(FormatFactory & factory)
{
    factory.registerOutputFormat("Null", [](
        WriteBuffer &,
        const Block & sample,
        const Context &,
        const FormatSettings &)
    {
        return std::make_shared<NullBlockOutputStream>(sample);
    });
}
void registerOutputFormatJSONCompact(FormatFactory & factory)
{
    factory.registerOutputFormat("JSONCompact", [](
        WriteBuffer & buf,
        const Block & sample,
        const Context &,
        const FormatSettings & format_settings)
    {
        return std::make_shared<BlockOutputStreamFromRowOutputStream>(
            std::make_shared<JSONCompactRowOutputStream>(buf, sample, format_settings), sample);
    });
}
void registerOutputFormatTSKV(FormatFactory & factory)
{
    factory.registerOutputFormat("TSKV", [](
        WriteBuffer & buf,
        const Block & sample,
        const Context &,
        const FormatSettings & settings)
    {
        return std::make_shared<BlockOutputStreamFromRowOutputStream>(
            std::make_shared<TSKVRowOutputStream>(buf, sample, settings), sample);
    });
}
void registerOutputFormatRowBinary(FormatFactory & factory)
{
    factory.registerOutputFormat("RowBinary", [](
        WriteBuffer & buf,
        const Block & sample,
        const Context &,
        const FormatSettings &)
    {
        return std::make_shared<BlockOutputStreamFromRowOutputStream>(
            std::make_shared<BinaryRowOutputStream>(buf, sample, false, false), sample);
    });

    factory.registerOutputFormat("RowBinaryWithNamesAndTypes", [](
        WriteBuffer & buf,
        const Block & sample,
        const Context &,
        const FormatSettings &)
    {
        return std::make_shared<BlockOutputStreamFromRowOutputStream>(
            std::make_shared<BinaryRowOutputStream>(buf, sample, true, true), sample);
    });
}