Class: Cardinality

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

Overview

Simple helper class to facilitate cardinality estimates

Class Method Summary collapse

Class Method Details

.filter(cardinality, eq_filter, range_filter) ⇒ Fixnum

Update the cardinality based on filtering implicit to the index

Returns:

  • (Fixnum)


170
171
172
173
174
175
176
177
# File 'lib/nose/util.rb', line 170

def self.filter(cardinality, eq_filter, range_filter)
  filtered = (range_filter.nil? ? 1.0 : 0.1) * cardinality
  filtered *= eq_filter.map do |field|
    1.0 / field.cardinality
  end.inject(1.0, &:*)

  filtered
end