Class: Rgviz::MemoryExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/rgviz/memory_executor.rb

Defined Under Namespace

Classes: EvalGroupVisitor, EvalSelectVisitor, EvalWhereVisitor, SimpleOrderedHash

Instance Method Summary collapse

Constructor Details

#initialize(rows, types) ⇒ MemoryExecutor

Returns a new instance of MemoryExecutor.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rgviz/memory_executor.rb', line 3

def initialize(rows, types)
  @rows = rows
  @types = types
  @types_to_indices = {}
  i = 0
  @types.each do |k, v|
    @types_to_indices[k.to_s] = i
    i += 1
  end
  @labels = {}
end

Instance Method Details

#execute(query, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rgviz/memory_executor.rb', line 15

def execute(query, options = {})
  @query = query
  @query = Parser.parse(@query) unless @query.kind_of?(Query)
  @table = Table.new

  process_labels

  check_has_aggregation

  generate_columns

  if @has_aggregation
    filter_and_group_rows
  else
    filter_rows
  end

  sort_rows
  limit_rows
  generate_rows

  @table
end