Class: NoSE::Cost::FieldSizeCost

Inherits:
Cost show all
Includes:
Subtype
Defined in:
lib/nose/cost/field_size.rb

Overview

A cost model which estimates the total size of data transferred

Instance Method Summary collapse

Methods included from Subtype

included

Methods inherited from Cost

#filter_cost, #initialize, #limit_cost, #pruned_cost, #sort_cost

Methods included from Supertype

included

Methods included from Listing

included

Constructor Details

This class inherits a constructor from NoSE::Cost::Cost

Instance Method Details

#delete_cost(step) ⇒ Object

Cost estimate as the size of an index entry



21
22
23
# File 'lib/nose/cost/field_size.rb', line 21

def delete_cost(step)
  step.index.entry_size
end

#index_lookup_cost(step) ⇒ Numeric

Rough cost estimate as the size of data returned

Returns:

  • (Numeric)


11
12
13
14
15
16
17
18
# File 'lib/nose/cost/field_size.rb', line 11

def index_lookup_cost(step)
  # If we have an answer to the query, we only need
  # to fetch the data fields which are selected
  fields = step.index.all_fields
  fields &= step.state.query.select if step.state.answered?

  step.state.cardinality * fields.sum_by(&:size)
end

#insert_cost(step) ⇒ Object

Cost estimate as the size of an index entry



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

def insert_cost(step)
  step.index.entry_size
end