Class: Druid::Query

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/druid/query.rb

Defined Under Namespace

Classes: AggregationsValidator, Builder, DimensionsValidator, FilterValidator, GranularityValidator, IntervalsValidator, PostaggregationsValidator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Query

Returns a new instance of Query.



288
289
290
291
# File 'lib/druid/query.rb', line 288

def initialize(attributes = {})
  super
  @context ||= Context.new
end

Instance Attribute Details

#aggregationsObject

Returns the value of attribute aggregations.



139
140
141
# File 'lib/druid/query.rb', line 139

def aggregations
  @aggregations
end

#boundObject

timeBoundary



255
256
257
# File 'lib/druid/query.rb', line 255

def bound
  @bound
end

#contextObject

Returns the value of attribute context.



278
279
280
# File 'lib/druid/query.rb', line 278

def context
  @context
end

#dataSourceObject

Returns the value of attribute dataSource.



22
23
24
# File 'lib/druid/query.rb', line 22

def dataSource
  @dataSource
end

#dimensionObject

topN



270
271
272
# File 'lib/druid/query.rb', line 270

def dimension
  @dimension
end

#dimensionsObject

Returns the value of attribute dimensions.



100
101
102
# File 'lib/druid/query.rb', line 100

def dimensions
  @dimensions
end

#filterObject

Returns the value of attribute filter.



217
218
219
# File 'lib/druid/query.rb', line 217

def filter
  @filter
end

#granularityObject

Returns the value of attribute granularity.



67
68
69
# File 'lib/druid/query.rb', line 67

def granularity
  @granularity
end

#havingObject

groupBy



229
230
231
# File 'lib/druid/query.rb', line 229

def having
  @having
end

#intervalsObject

Returns the value of attribute intervals.



43
44
45
# File 'lib/druid/query.rb', line 43

def intervals
  @intervals
end

#limitObject

search



243
244
245
# File 'lib/druid/query.rb', line 243

def limit
  @limit
end

#limitSpecObject

groupBy



240
241
242
# File 'lib/druid/query.rb', line 240

def limitSpec
  @limitSpec
end

#mergeObject

segementMetadata



261
262
263
# File 'lib/druid/query.rb', line 261

def merge
  @merge
end

#metricObject

topN



273
274
275
# File 'lib/druid/query.rb', line 273

def metric
  @metric
end

#metricsObject

select



264
265
266
# File 'lib/druid/query.rb', line 264

def metrics
  @metrics
end

#pagingSpecObject

select



267
268
269
# File 'lib/druid/query.rb', line 267

def pagingSpec
  @pagingSpec
end

#postAggregationsObject

Returns the value of attribute postAggregations.



186
187
188
# File 'lib/druid/query.rb', line 186

def postAggregations
  @postAggregations
end

#queryObject

search



249
250
251
# File 'lib/druid/query.rb', line 249

def query
  @query
end

#queryTypeObject

Returns the value of attribute queryType.



19
20
21
# File 'lib/druid/query.rb', line 19

def queryType
  @queryType
end

#searchDimensionsObject

search



246
247
248
# File 'lib/druid/query.rb', line 246

def searchDimensions
  @searchDimensions
end

#sortObject

search



252
253
254
# File 'lib/druid/query.rb', line 252

def sort
  @sort
end

#thresholdObject

topN



276
277
278
# File 'lib/druid/query.rb', line 276

def threshold
  @threshold
end

#toIncludeObject

segementMetadata



258
259
260
# File 'lib/druid/query.rb', line 258

def toInclude
  @toInclude
end

Instance Method Details

#aggregation_namesObject



164
165
166
167
168
# File 'lib/druid/query.rb', line 164

def aggregation_names
  Set.new(@aggregations.map do |aggregation|
    [aggregation.fieldName] + [aggregation.fieldNames]
  end.flatten.compact)
end

#aggregation_typesObject



158
159
160
161
162
# File 'lib/druid/query.rb', line 158

def aggregation_types
  Set.new(@aggregations.map do |aggregation|
    aggregation.type
  end.flatten.compact)
end

#as_json(options = {}) ⇒ Object



293
294
295
# File 'lib/druid/query.rb', line 293

def as_json(options = {})
  super(options.merge(except: %w(errors validation_context)))
end

#contains_aggregation?(metric) ⇒ Boolean

Returns:

  • (Boolean)


297
298
299
# File 'lib/druid/query.rb', line 297

def contains_aggregation?(metric)
  aggregations.any? { |a| a.name.to_s == metric.to_s }
end