Class: ClickHouse::Response::Summary
- Inherits:
-
Object
- Object
- ClickHouse::Response::Summary
- Defined in:
- lib/click_house/response/summary.rb
Constant Summary collapse
- SUMMARY_HEADER =
'x-clickhouse-summary'
- KEY_TOTALS =
'totals'
- KEY_STATISTICS =
'statistics'
- KEY_ROWS_BEFORE_LIMIT_AT_LEAST =
'rows_before_limit_at_least'
- KEY_STAT_ELAPSED =
'elapsed'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#rows_before_limit_at_least ⇒ Object
readonly
Returns the value of attribute rows_before_limit_at_least.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#totals ⇒ Object
readonly
Returns the value of attribute totals.
Instance Method Summary collapse
- #elapsed ⇒ Float
- #elapsed_pretty ⇒ String
-
#initialize(config, headers: Faraday::Utils::Headers.new, body: {}) ⇒ Summary
constructor
TOTALS [Array|Hash|NilClass] Support for ‘GROUP BY WITH TOTALS’ modifier clickhouse.tech/docs/en/sql-reference/statements/select/group-by/#with-totals-modifier Hash in JSON format and Array in JSONCompact.
- #read_bytes ⇒ Integer
- #read_bytes_pretty ⇒ String
- #read_rows ⇒ Integer
- #result_bytes ⇒ Integer
- #result_rows ⇒ Integer
- #total_rows_to_read ⇒ Integer
- #written_bytes ⇒ Integer
- #written_bytes_pretty ⇒ String
- #written_rows ⇒ Integer
Constructor Details
#initialize(config, headers: Faraday::Utils::Headers.new, body: {}) ⇒ Summary
TOTALS [Array|Hash|NilClass] Support for ‘GROUP BY WITH TOTALS’ modifier
https://clickhouse.tech/docs/en/sql-reference/statements/select/group-by/#with-totals-modifier
Hash in JSON format and Array in JSONCompact
26 27 28 29 30 31 32 33 |
# File 'lib/click_house/response/summary.rb', line 26 def initialize(config, headers: Faraday::Utils::Headers.new, body: {}) @headers = headers @config = config @statistics = body.fetch(config.key(KEY_STATISTICS), {}) @totals = body[config.key(KEY_TOTALS)] @rows_before_limit_at_least = body[config.key(KEY_ROWS_BEFORE_LIMIT_AT_LEAST)] @summary = parse_summary(headers[SUMMARY_HEADER]) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/click_house/response/summary.rb', line 12 def config @config end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
12 13 14 |
# File 'lib/click_house/response/summary.rb', line 12 def headers @headers end |
#rows_before_limit_at_least ⇒ Object (readonly)
Returns the value of attribute rows_before_limit_at_least.
12 13 14 |
# File 'lib/click_house/response/summary.rb', line 12 def rows_before_limit_at_least @rows_before_limit_at_least end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
12 13 14 |
# File 'lib/click_house/response/summary.rb', line 12 def statistics @statistics end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
12 13 14 |
# File 'lib/click_house/response/summary.rb', line 12 def summary @summary end |
#totals ⇒ Object (readonly)
Returns the value of attribute totals.
12 13 14 |
# File 'lib/click_house/response/summary.rb', line 12 def totals @totals end |
Instance Method Details
#elapsed ⇒ Float
81 82 83 |
# File 'lib/click_house/response/summary.rb', line 81 def elapsed statistics[config.key(KEY_STAT_ELAPSED)].to_f end |
#elapsed_pretty ⇒ String
86 87 88 |
# File 'lib/click_house/response/summary.rb', line 86 def elapsed_pretty Util::Pretty.measure(elapsed * 1000) end |
#read_bytes ⇒ Integer
41 42 43 |
# File 'lib/click_house/response/summary.rb', line 41 def read_bytes summary[config.key('read_bytes')].to_i end |
#read_bytes_pretty ⇒ String
46 47 48 |
# File 'lib/click_house/response/summary.rb', line 46 def read_bytes_pretty Util::Pretty.size(read_bytes) end |
#read_rows ⇒ Integer
36 37 38 |
# File 'lib/click_house/response/summary.rb', line 36 def read_rows summary[config.key('read_rows')].to_i end |
#result_bytes ⇒ Integer
76 77 78 |
# File 'lib/click_house/response/summary.rb', line 76 def result_bytes summary[config.key('result_bytes')].to_i end |
#result_rows ⇒ Integer
71 72 73 |
# File 'lib/click_house/response/summary.rb', line 71 def result_rows summary[config.key('result_rows')].to_i end |
#total_rows_to_read ⇒ Integer
66 67 68 |
# File 'lib/click_house/response/summary.rb', line 66 def total_rows_to_read summary[config.key('total_rows_to_read')].to_i end |
#written_bytes ⇒ Integer
56 57 58 |
# File 'lib/click_house/response/summary.rb', line 56 def written_bytes summary[config.key('written_bytes')].to_i end |
#written_bytes_pretty ⇒ String
61 62 63 |
# File 'lib/click_house/response/summary.rb', line 61 def written_bytes_pretty Util::Pretty.size(written_bytes) end |
#written_rows ⇒ Integer
51 52 53 |
# File 'lib/click_house/response/summary.rb', line 51 def written_rows summary[config.key('written_rows')].to_i end |