2012-03-11 08:55:04 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <DataStreams/IBlockStream_fwd.h>
|
2012-03-11 08:55:04 +00:00
|
|
|
|
2019-05-17 18:45:42 +00:00
|
|
|
#include <functional>
|
2012-03-11 08:55:04 +00:00
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
#include <Processors/QueryPipeline.h>
|
|
|
|
|
2012-03-11 08:55:04 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2015-06-21 06:06:04 +00:00
|
|
|
class ProcessListEntry;
|
|
|
|
|
2012-03-11 08:55:04 +00:00
|
|
|
struct BlockIO
|
|
|
|
{
|
2019-03-29 20:31:06 +00:00
|
|
|
BlockIO() = default;
|
|
|
|
BlockIO(const BlockIO &) = default;
|
|
|
|
~BlockIO() = default;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/** process_list_entry should be destroyed after in and after out,
|
2018-02-01 17:55:08 +00:00
|
|
|
* since in and out contain pointer to objects inside process_list_entry (query-level MemoryTracker for example),
|
2017-04-01 07:20:54 +00:00
|
|
|
* which could be used before destroying of in and out.
|
|
|
|
*/
|
|
|
|
std::shared_ptr<ProcessListEntry> process_list_entry;
|
|
|
|
|
2019-05-23 13:54:11 +00:00
|
|
|
BlockOutputStreamPtr out;
|
|
|
|
BlockInputStreamPtr in;
|
|
|
|
|
2019-06-25 17:00:54 +00:00
|
|
|
QueryPipeline pipeline;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/// Callbacks for query logging could be set here.
|
2017-04-13 16:12:56 +00:00
|
|
|
std::function<void(IBlockInputStream *, IBlockOutputStream *)> finish_callback;
|
2017-04-01 07:20:54 +00:00
|
|
|
std::function<void()> exception_callback;
|
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/// Call these functions if you want to log the request.
|
2017-04-01 07:20:54 +00:00
|
|
|
void onFinish()
|
|
|
|
{
|
|
|
|
if (finish_callback)
|
|
|
|
finish_callback(in.get(), out.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void onException()
|
|
|
|
{
|
|
|
|
if (exception_callback)
|
|
|
|
exception_callback();
|
|
|
|
}
|
|
|
|
|
2019-03-29 20:31:06 +00:00
|
|
|
BlockIO & operator= (const BlockIO & rhs)
|
2018-06-06 20:57:07 +00:00
|
|
|
{
|
2019-04-05 16:21:46 +00:00
|
|
|
if (this == &rhs)
|
|
|
|
return *this;
|
|
|
|
|
2018-06-06 20:57:07 +00:00
|
|
|
out.reset();
|
|
|
|
in.reset();
|
|
|
|
process_list_entry.reset();
|
2017-04-13 16:12:56 +00:00
|
|
|
|
|
|
|
process_list_entry = rhs.process_list_entry;
|
|
|
|
in = rhs.in;
|
|
|
|
out = rhs.out;
|
2019-04-05 10:52:07 +00:00
|
|
|
pipeline = rhs.pipeline;
|
2017-04-13 16:12:56 +00:00
|
|
|
|
|
|
|
finish_callback = rhs.finish_callback;
|
|
|
|
exception_callback = rhs.exception_callback;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2012-03-11 08:55:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|