2019-03-26 18:28:37 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Processors/ISimpleTransform.h>
|
|
|
|
#include <DataStreams/SizeLimits.h>
|
|
|
|
#include <Poco/Timespan.h>
|
|
|
|
#include <Interpreters/ProcessList.h>
|
|
|
|
|
2019-04-05 10:52:07 +00:00
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Information for profiling.
|
|
|
|
struct ProcessorProfileInfo
|
|
|
|
{
|
|
|
|
bool started = false;
|
|
|
|
Stopwatch total_stopwatch {CLOCK_MONOTONIC_COARSE}; /// Time with waiting time
|
|
|
|
|
|
|
|
size_t rows = 0;
|
|
|
|
size_t blocks = 0;
|
|
|
|
size_t bytes = 0;
|
|
|
|
|
|
|
|
void update(const Chunk & block);
|
|
|
|
};
|
|
|
|
|
|
|
|
class LimitsCheckingTransform : public ISimpleTransform
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2019-04-05 10:52:07 +00:00
|
|
|
using LocalLimits = IBlockInputStream::LocalLimits;
|
|
|
|
using LimitsMode = IBlockInputStream::LimitsMode;
|
2019-03-26 18:28:37 +00:00
|
|
|
|
2019-08-03 11:02:40 +00:00
|
|
|
LimitsCheckingTransform(const Block & header_, LocalLimits limits_);
|
2019-03-26 18:28:37 +00:00
|
|
|
|
|
|
|
String getName() const override { return "LimitsCheckingTransform"; }
|
|
|
|
|
2020-03-07 17:37:38 +00:00
|
|
|
void setQuota(const std::shared_ptr<const EnabledQuota> & quota_) { quota = quota_; }
|
2019-03-26 18:28:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void transform(Chunk & chunk) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
LocalLimits limits;
|
|
|
|
|
2020-03-07 17:37:38 +00:00
|
|
|
std::shared_ptr<const EnabledQuota> quota;
|
2019-11-04 19:17:27 +00:00
|
|
|
UInt64 prev_elapsed = 0;
|
2019-03-26 18:28:37 +00:00
|
|
|
|
|
|
|
ProcessorProfileInfo info;
|
|
|
|
|
|
|
|
bool checkTimeLimit();
|
2019-04-05 10:52:07 +00:00
|
|
|
void checkQuota(Chunk & chunk);
|
2019-03-26 18:28:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|