ClickHouse/dbms/src/DataStreams/BlockIO.h

71 lines
1.7 KiB
C++
Raw Normal View History

2012-03-11 08:55:04 +00:00
#pragma once
#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
{
class ProcessListEntry;
2012-03-11 08:55:04 +00:00
struct BlockIO
{
BlockIO() = default;
BlockIO(const BlockIO &) = default;
~BlockIO() = default;
/** process_list_entry should be destroyed after in and after out,
* since in and out contain pointer to objects inside process_list_entry (query-level MemoryTracker for example),
* 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;
/// Callbacks for query logging could be set here.
std::function<void(IBlockInputStream *, IBlockOutputStream *)> finish_callback;
std::function<void()> exception_callback;
2017-05-13 22:19:04 +00:00
/// Call these functions if you want to log the request.
void onFinish()
{
if (finish_callback)
finish_callback(in.get(), out.get());
}
void onException()
{
if (exception_callback)
exception_callback();
}
BlockIO & operator= (const BlockIO & rhs)
{
2019-04-05 16:21:46 +00:00
if (this == &rhs)
return *this;
out.reset();
in.reset();
process_list_entry.reset();
process_list_entry = rhs.process_list_entry;
in = rhs.in;
out = rhs.out;
2019-04-05 10:52:07 +00:00
pipeline = rhs.pipeline;
finish_callback = rhs.finish_callback;
exception_callback = rhs.exception_callback;
return *this;
}
2012-03-11 08:55:04 +00:00
};
}