Class: NoSE::Search::Search

Inherits:
Object show all
Defined in:
lib/nose/search.rb

Overview

Searches for the optimal indices for a given workload

Instance Method Summary collapse

Constructor Details

#initialize(workload, cost_model, objective = Objective::COST, by_id_graph = false) ⇒ Search

Returns a new instance of Search.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nose/search.rb', line 16

def initialize(workload, cost_model, objective = Objective::COST,
               by_id_graph = false)
  @logger = Logging.logger['nose::search']
  @workload = workload
  @cost_model = cost_model
  @objective = objective
  @by_id_graph = by_id_graph

  # For now we only support optimization based on cost when grouping by
  # ID graphs, but support for other objectives is still feasible
  fail 'Only cost-based optimization allowed when using ID graphs' \
    if @by_id_graph && objective != Objective::COST
end

Instance Method Details

#search_overlap(indexes, max_space = Float::INFINITY) ⇒ Results

Search for optimal indices using an ILP which searches for non-overlapping indices

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/nose/search.rb', line 33

def search_overlap(indexes, max_space = Float::INFINITY)
  return if indexes.empty?

  # Get the costs of all queries and updates
  query_weights = combine_query_weights indexes
  costs, trees = query_costs query_weights, indexes
  update_costs, update_plans = update_costs trees, indexes

  log_search_start costs, query_weights

  solver_params = {
    max_space: max_space,
    costs: costs,
    update_costs: update_costs,
    cost_model: @cost_model,
    by_id_graph: @by_id_graph
  }
  search_result query_weights, indexes, solver_params, trees,
                update_plans
end