| 1 | #include <Access/Quota.h> |
|---|---|
| 2 | #include <boost/range/algorithm/equal.hpp> |
| 3 | #include <boost/range/algorithm/fill.hpp> |
| 4 | |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | Quota::Limits::Limits() |
| 9 | { |
| 10 | boost::range::fill(max, 0); |
| 11 | } |
| 12 | |
| 13 | |
| 14 | bool operator ==(const Quota::Limits & lhs, const Quota::Limits & rhs) |
| 15 | { |
| 16 | return boost::range::equal(lhs.max, rhs.max) && (lhs.duration == rhs.duration) |
| 17 | && (lhs.randomize_interval == rhs.randomize_interval); |
| 18 | } |
| 19 | |
| 20 | |
| 21 | bool Quota::equal(const IAccessEntity & other) const |
| 22 | { |
| 23 | if (!IAccessEntity::equal(other)) |
| 24 | return false; |
| 25 | const auto & other_quota = typeid_cast<const Quota &>(other); |
| 26 | return (all_limits == other_quota.all_limits) && (key_type == other_quota.key_type) && (roles == other_quota.roles) |
| 27 | && (all_roles == other_quota.all_roles) && (except_roles == other_quota.except_roles); |
| 28 | } |
| 29 | |
| 30 | |
| 31 | const char * Quota::resourceTypeToColumnName(ResourceType resource_type) |
| 32 | { |
| 33 | switch (resource_type) |
| 34 | { |
| 35 | case Quota::QUERIES: return "queries"; |
| 36 | case Quota::ERRORS: return "errors"; |
| 37 | case Quota::RESULT_ROWS: return "result_rows"; |
| 38 | case Quota::RESULT_BYTES: return "result_bytes"; |
| 39 | case Quota::READ_ROWS: return "read_rows"; |
| 40 | case Quota::READ_BYTES: return "read_bytes"; |
| 41 | case Quota::EXECUTION_TIME: return "execution_time"; |
| 42 | } |
| 43 | __builtin_unreachable(); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 |