Class: InfluxDB::Query::Batch
- Inherits:
-
Object
- Object
- InfluxDB::Query::Batch
- Defined in:
- lib/influxdb/query/batch.rb
Overview
Batch collects multiple queries and executes them together.
You shouldn’t use Batch directly, instead call Client.batch, which constructs a new batch for you.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
Instance Method Summary collapse
- #add(query, params: nil) ⇒ Object
- #execute(denormalize: config.denormalize, chunk_size: config.chunk_size, **opts, &block) ⇒ Object
-
#initialize(client) {|_self| ... } ⇒ Batch
constructor
A new instance of Batch.
Constructor Details
#initialize(client) {|_self| ... } ⇒ Batch
Returns a new instance of Batch.
10 11 12 13 14 15 |
# File 'lib/influxdb/query/batch.rb', line 10 def initialize(client) @client = client @statements = [] yield self if block_given? end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/influxdb/query/batch.rb', line 8 def client @client end |
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
8 9 10 |
# File 'lib/influxdb/query/batch.rb', line 8 def statements @statements end |
Instance Method Details
#add(query, params: nil) ⇒ Object
17 18 19 20 |
# File 'lib/influxdb/query/batch.rb', line 17 def add(query, params: nil) statements << client.builder.build(query.chomp(";"), params) statements.size - 1 end |
#execute(denormalize: config.denormalize, chunk_size: config.chunk_size, **opts, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/influxdb/query/batch.rb', line 22 def execute( denormalize: config.denormalize, chunk_size: config.chunk_size, **opts, &block ) return [] if statements.empty? url = full_url "/query".freeze, query_params(statements.join(";"), opts) series = fetch_series get(url, parse: true, json_streaming: !chunk_size.nil?) if denormalize build_denormalized_result(series, &block) else build_result(series, &block) end end |