Class: NoSE::Cost::CassandraCost

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

Overview

A cost model which estimates the number of requests to the backend

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 number of entities deleted



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

def delete_cost(step)
  return nil if step.state.nil?
  step.state.cardinality * @options[:delete_cost]
end

#index_lookup_cost(step) ⇒ Numeric

Rough cost estimate as the number of requests made

Returns:

  • (Numeric)


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

def index_lookup_cost(step)
  return nil if step.state.nil?
  rows = step.state.cardinality
  parts = step.state.hash_cardinality

  @options[:index_cost] + parts * @options[:partition_cost] +
    rows * @options[:row_cost]
end

#insert_cost(step) ⇒ Object

Cost estimate as number of entities inserted



27
28
29
30
# File 'lib/nose/cost/cassandra.rb', line 27

def insert_cost(step)
  return nil if step.state.nil?
  step.state.cardinality * @options[:insert_cost]
end