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
|
|
|
|
|
|
|
/// LIMITS_CURRENT
|
2019-08-03 11:02:40 +00:00
|
|
|
LimitsCheckingTransform(const Block & header_, LocalLimits limits_);
|
2019-03-26 18:28:37 +00:00
|
|
|
/// LIMITS_TOTAL
|
2019-04-05 13:09:11 +00:00
|
|
|
/// LimitsCheckingTransform(const Block & header, LocalLimits limits, QueryStatus * process_list_elem);
|
2019-03-26 18:28:37 +00:00
|
|
|
|
|
|
|
String getName() const override { return "LimitsCheckingTransform"; }
|
|
|
|
|
|
|
|
void setQuota(QuotaForIntervals & quota_) { quota = "a_; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void transform(Chunk & chunk) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
LocalLimits limits;
|
|
|
|
|
|
|
|
QuotaForIntervals * quota = nullptr;
|
|
|
|
double prev_elapsed = 0;
|
|
|
|
|
|
|
|
ProcessorProfileInfo info;
|
|
|
|
|
|
|
|
bool checkTimeLimit();
|
2019-04-05 10:52:07 +00:00
|
|
|
void checkQuota(Chunk & chunk);
|
2019-03-26 18:28:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|