Module: Cubicle::Aggregation

Includes:
Dsl
Included in:
AdHoc
Defined in:
lib/cubicle/aggregation.rb,
lib/cubicle/aggregation/dsl.rb,
lib/cubicle/aggregation/ad_hoc.rb,
lib/cubicle/aggregation/profiler.rb,
lib/cubicle/aggregation/aggregation_view.rb,
lib/cubicle/aggregation/cubicle_metadata.rb,
lib/cubicle/aggregation/map_reduce_helper.rb,
lib/cubicle/aggregation/aggregation_manager.rb,
lib/cubicle/aggregation/aggregation_metadata.rb

Defined Under Namespace

Modules: Dsl Classes: AdHoc, AggregationManager, AggregationMetadata, AggregationView, CubicleMetadata, MapReduceHelper, Profiler

Instance Method Summary collapse

Methods included from Dsl

#aggregation, #average, #average_duration, #bucketize, #count, #define, #difference, #dimension, #dimensions, #duration, #duration_since, #durations_in, #expand, #expansions, #filter, #measure, #measures, #named_expressions, #ratio, #source_collection_name, #sum, #target_collection_name, #time_dimension, #total_duration

Instance Method Details

#aggregationsObject



25
26
27
# File 'lib/cubicle/aggregation.rb', line 25

def aggregations
  return (@aggregations ||= [])
end

#aggregatorObject



5
6
7
# File 'lib/cubicle/aggregation.rb', line 5

def aggregator
  @aggregator ||= AggregationManager.new(self)
end

#dimension_namesObject



29
30
31
# File 'lib/cubicle/aggregation.rb', line 29

def dimension_names
  return @dimensions.map{|dim|dim.name.to_s}
end

#execute_query(query, options) ⇒ Object



57
58
59
# File 'lib/cubicle/aggregation.rb', line 57

def execute_query(query,options)
  aggregator.execute_query(query,options)
end

#expire!Object



17
18
19
# File 'lib/cubicle/aggregation.rb', line 17

def expire!
  aggregator.expire!
end

#find_member(member_name) ⇒ Object



33
34
35
36
# File 'lib/cubicle/aggregation.rb', line 33

def find_member(member_name)
  @dimensions[member_name] ||
          @measures[member_name]
end

#process(*args) ⇒ Object



21
22
23
# File 'lib/cubicle/aggregation.rb', line 21

def process(*args)
  aggregator.process(*args)
end

#query(*args, &block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cubicle/aggregation.rb', line 38

def query(*args,&block)
    options = args.extract_options!
    query = Cubicle::Query.new(self)
    query.source_collection_name = options.delete(:source_collection) if options[:source_collection]
    query.select(*args) if args.length > 0
    if block_given?
      block.arity == 1 ? (yield query) : (query.instance_eval(&block))
    end
    query.select_all unless query.selected?
    return query if options[:defer]
    results = execute_query(query,options)
    #return results if results.blank?
    #If the 'by' clause was used in the the query,
    #we'll hierarchize by the members indicated,
    #as the next step would otherwise almost certainly
    #need to be a call to hierarchize anyway.
    query.respond_to?(:by) && query.by.length > 0 ? results.hierarchize(*query.by) : results
end

#transient!Object



13
14
15
# File 'lib/cubicle/aggregation.rb', line 13

def transient!
  @transient = true
end

#transient?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/cubicle/aggregation.rb', line 9

def transient?
  @transient ||= false
end