Class: DruidDB::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/druiddb/query.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Query

Returns a new instance of Query.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/druiddb/query.rb', line 15

def initialize(opts)
  @aggregations = opts[:aggregations].map { |agg| agg[:name] }
  @broker = opts[:broker]
  @dimensions = opts[:dimensions]
  @fill_value = opts[:fill_value]
  @granularity = opts[:granularity]
  @range = parse_range(opts[:intervals])
  @query_type = opts[:queryType]
  @end_interval = calculate_end_interval
  @start_interval = calculate_start_interval
  @query_opts = opts_for_query(opts)
end

Instance Attribute Details

#aggregationsObject (readonly)

Returns the value of attribute aggregations.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def aggregations
  @aggregations
end

#brokerObject (readonly)

Returns the value of attribute broker.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def broker
  @broker
end

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def dimensions
  @dimensions
end

#end_intervalObject (readonly)

Returns the value of attribute end_interval.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def end_interval
  @end_interval
end

#fill_valueObject (readonly)

Returns the value of attribute fill_value.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def fill_value
  @fill_value
end

#granularityObject (readonly)

Returns the value of attribute granularity.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def granularity
  @granularity
end

#query_optsObject (readonly)

Returns the value of attribute query_opts.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def query_opts
  @query_opts
end

#query_typeObject (readonly)

Returns the value of attribute query_type.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def query_type
  @query_type
end

#rangeObject (readonly)

Returns the value of attribute range.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def range
  @range
end

#result_keyObject (readonly)

Returns the value of attribute result_key.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def result_key
  @result_key
end

#start_intervalObject (readonly)

Returns the value of attribute start_interval.



3
4
5
# File 'lib/druiddb/query.rb', line 3

def start_interval
  @start_interval
end

Class Method Details

.create(opts) ⇒ Object



176
177
178
# File 'lib/druiddb/query.rb', line 176

def create(opts)
  new(opts).execute
end

Instance Method Details

#executeObject



28
29
30
31
# File 'lib/druiddb/query.rb', line 28

def execute
  result = broker.query(query_opts)
  fill_query_results(result)
end