blob: 2f96a17c17be5c7afc3b28f2c59394f4a6235225 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#pragma once
#include <Access/EnabledQuota.h>
#include <Processors/ISimpleTransform.h>
#include <QueryPipeline/SizeLimits.h>
#include <Poco/Timespan.h>
#include <Common/Stopwatch.h>
#include <QueryPipeline/StreamLocalLimits.h>
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:
LimitsCheckingTransform(const Block & header_, StreamLocalLimits limits_);
String getName() const override { return "LimitsCheckingTransform"; }
void setQuota(const std::shared_ptr<const EnabledQuota> & quota_) { quota = quota_; }
protected:
void transform(Chunk & chunk) override;
private:
StreamLocalLimits limits;
std::shared_ptr<const EnabledQuota> quota;
UInt64 prev_elapsed = 0;
ProcessorProfileInfo info;
bool checkTimeLimit();
void checkQuota(Chunk & chunk);
};
}
|