Class: NoSE::Cost::Cost

Inherits:
Object show all
Includes:
Listing, Supertype
Defined in:
lib/nose/cost.rb

Overview

Cost model for a backend database

Instance Method Summary collapse

Methods included from Supertype

included

Methods included from Listing

included

Constructor Details

#initialize(**options) ⇒ Cost



11
12
13
# File 'lib/nose/cost.rb', line 11

def initialize(**options)
  @options = options
end

Instance Method Details

#delete_cost(_step) ⇒ Fixnum

The cost of performing a deletion from an index



47
48
49
# File 'lib/nose/cost.rb', line 47

def delete_cost(_step)
  fail NotImplementedError, 'Must be implemented in a subclass'
end

#filter_cost(_step) ⇒ Fixnum

The cost of filtering intermediate results



17
18
19
20
21
# File 'lib/nose/cost.rb', line 17

def filter_cost(_step)
  # Assume this has no cost and the cost is captured in the fact that we
  # have to retrieve more data earlier. All this does is skip records.
  0
end

#index_lookup_cost(_step) ⇒ Fixnum

The cost of performing a lookup via an index



41
42
43
# File 'lib/nose/cost.rb', line 41

def index_lookup_cost(_step)
  fail NotImplementedError, 'Must be implemented in a subclass'
end

#insert_cost(_step) ⇒ Fixnum

The cost of performing an insert into an index



53
54
55
# File 'lib/nose/cost.rb', line 53

def insert_cost(_step)
  fail NotImplementedError, 'Must be implemented in a subclass'
end

#limit_cost(_step) ⇒ Fixnum

The cost of limiting a result set



25
26
27
28
# File 'lib/nose/cost.rb', line 25

def limit_cost(_step)
  # This is basically free since we just discard data
  0
end

#pruned_cost(_step) ⇒ Fixnum

This is here for debugging purposes because we need a cost



59
60
61
# File 'lib/nose/cost.rb', line 59

def pruned_cost(_step)
  0
end

#sort_cost(_step) ⇒ Fixnum

The cost of sorting a set of results



32
33
34
35
36
37
# File 'lib/nose/cost.rb', line 32

def sort_cost(_step)
  # TODO: Find some estimate of sort cost
  #       This could be partially captured by the fact that sort + limit
  #       effectively removes the limit
  1
end