MCPcopy Create free account
hub / github.com/ByConity/ByConity / sendDataFrom

Method sendDataFrom

programs/client/Client.cpp:1979–2030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1977
1978
1979 void sendDataFrom(ReadBuffer & buf, Block & sample, const ColumnsDescription & columns_description)
1980 {
1981 String current_format = insert_format;
1982
1983 /// Data format can be specified in the INSERT query.
1984 if (const auto * insert = parsed_query->as<ASTInsertQuery>())
1985 {
1986 if (!insert->format.empty())
1987 current_format = insert->format;
1988 }
1989
1990 auto source = FormatFactory::instance().getInput(current_format, buf, sample, context, insert_format_max_block_size);
1991 Pipe pipe(source);
1992
1993 if (columns_description.hasDefaults())
1994 {
1995 pipe.addSimpleTransform([&](const Block & header) {
1996 return std::make_shared<AddingDefaultsTransform>(header, columns_description, *source, context);
1997 });
1998 }
1999
2000 QueryPipeline pipeline;
2001 pipeline.init(std::move(pipe));
2002 PullingAsyncPipelineExecutor executor(pipeline);
2003
2004 Block block;
2005 while (executor.pull(block))
2006 {
2007 /// Check if server send Log packet
2008 receiveLogs();
2009
2010 /// Check if server send Exception packet
2011 auto packet_type = connection->checkPacket();
2012 if (packet_type && *packet_type == Protocol::Server::Exception)
2013 {
2014 /*
2015 * We're exiting with error, so it makes sense to kill the
2016 * input stream without waiting for it to complete.
2017 */
2018 executor.cancel();
2019 return;
2020 }
2021
2022 if (block)
2023 {
2024 connection->sendData(block);
2025 processed_rows += block.rows();
2026 }
2027 }
2028
2029 connection->sendData({});
2030 }
2031
2032
2033 /// Flush all buffers.

Callers

nothing calls this directly

Calls 10

hasDefaultsMethod · 0.80
checkPacketMethod · 0.80
emptyMethod · 0.45
getInputMethod · 0.45
addSimpleTransformMethod · 0.45
initMethod · 0.45
pullMethod · 0.45
cancelMethod · 0.45
sendDataMethod · 0.45
rowsMethod · 0.45

Tested by

no test coverage detected